-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add fragment concat support
- Loading branch information
Showing
5 changed files
with
272 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
test/fixtures/graphql-tag/converts inline gql tag with fragment interpolation/actual.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import gql from 'graphql-tag'; | ||
|
||
const bar = gql` | ||
fragment barFragment on Foo { | ||
field1 | ||
field2 | ||
} | ||
`; | ||
|
||
const baz = { | ||
fragments: { | ||
foo: gql` | ||
fragment bazFragment on Foo { | ||
field2 | ||
field3 | ||
} | ||
` | ||
} | ||
}; | ||
|
||
const foo = gql` | ||
query foo { | ||
foo { | ||
...barFragment | ||
...bazFragment | ||
} | ||
} | ||
${bar} | ||
${baz.fragments.foo} | ||
`; |
170 changes: 170 additions & 0 deletions
170
test/fixtures/graphql-tag/converts inline gql tag with fragment interpolation/expected.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
const bar = { | ||
'kind': 'Document', | ||
'definitions': [{ | ||
'kind': 'FragmentDefinition', | ||
'name': { | ||
'kind': 'Name', | ||
'value': 'barFragment' | ||
}, | ||
'typeCondition': { | ||
'kind': 'NamedType', | ||
'name': { | ||
'kind': 'Name', | ||
'value': 'Foo' | ||
} | ||
}, | ||
'directives': [], | ||
'selectionSet': { | ||
'kind': 'SelectionSet', | ||
'selections': [{ | ||
'kind': 'Field', | ||
'alias': null, | ||
'name': { | ||
'kind': 'Name', | ||
'value': 'field1' | ||
}, | ||
'arguments': [], | ||
'directives': [], | ||
'selectionSet': null | ||
}, { | ||
'kind': 'Field', | ||
'alias': null, | ||
'name': { | ||
'kind': 'Name', | ||
'value': 'field2' | ||
}, | ||
'arguments': [], | ||
'directives': [], | ||
'selectionSet': null | ||
}] | ||
} | ||
}], | ||
'loc': { | ||
'start': 0, | ||
'end': 59, | ||
'source': { | ||
'body': '\n fragment barFragment on Foo {\n field1\n field2\n }\n', | ||
'name': 'GraphQL request', | ||
'locationOffset': { | ||
'line': 1, | ||
'column': 1 | ||
} | ||
} | ||
} | ||
}; | ||
|
||
const baz = { | ||
fragments: { | ||
foo: { | ||
'kind': 'Document', | ||
'definitions': [{ | ||
'kind': 'FragmentDefinition', | ||
'name': { | ||
'kind': 'Name', | ||
'value': 'bazFragment' | ||
}, | ||
'typeCondition': { | ||
'kind': 'NamedType', | ||
'name': { | ||
'kind': 'Name', | ||
'value': 'Foo' | ||
} | ||
}, | ||
'directives': [], | ||
'selectionSet': { | ||
'kind': 'SelectionSet', | ||
'selections': [{ | ||
'kind': 'Field', | ||
'alias': null, | ||
'name': { | ||
'kind': 'Name', | ||
'value': 'field2' | ||
}, | ||
'arguments': [], | ||
'directives': [], | ||
'selectionSet': null | ||
}, { | ||
'kind': 'Field', | ||
'alias': null, | ||
'name': { | ||
'kind': 'Name', | ||
'value': 'field3' | ||
}, | ||
'arguments': [], | ||
'directives': [], | ||
'selectionSet': null | ||
}] | ||
} | ||
}], | ||
'loc': { | ||
'start': 0, | ||
'end': 79, | ||
'source': { | ||
'body': '\n fragment bazFragment on Foo {\n field2\n field3\n }\n ', | ||
'name': 'GraphQL request', | ||
'locationOffset': { | ||
'line': 1, | ||
'column': 1 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
|
||
const foo = { | ||
'kind': 'Document', | ||
'definitions': [{ | ||
'kind': 'OperationDefinition', | ||
'operation': 'query', | ||
'name': { | ||
'kind': 'Name', | ||
'value': 'foo' | ||
}, | ||
'variableDefinitions': [], | ||
'directives': [], | ||
'selectionSet': { | ||
'kind': 'SelectionSet', | ||
'selections': [{ | ||
'kind': 'Field', | ||
'alias': null, | ||
'name': { | ||
'kind': 'Name', | ||
'value': 'foo' | ||
}, | ||
'arguments': [], | ||
'directives': [], | ||
'selectionSet': { | ||
'kind': 'SelectionSet', | ||
'selections': [{ | ||
'kind': 'FragmentSpread', | ||
'name': { | ||
'kind': 'Name', | ||
'value': 'barFragment' | ||
}, | ||
'directives': [] | ||
}, { | ||
'kind': 'FragmentSpread', | ||
'name': { | ||
'kind': 'Name', | ||
'value': 'bazFragment' | ||
}, | ||
'directives': [] | ||
}] | ||
} | ||
}] | ||
} | ||
}].concat(bar.definitions, baz.fragments.foo.definitions), | ||
'loc': { | ||
'start': 0, | ||
'end': 84, | ||
'source': { | ||
'body': '\n query foo {\n foo {\n ...barFragment\n ...bazFragment\n }\n }\n\n \n \n', | ||
'name': 'GraphQL request', | ||
'locationOffset': { | ||
'line': 1, | ||
'column': 1 | ||
} | ||
} | ||
} | ||
}; |
7 changes: 7 additions & 0 deletions
7
test/fixtures/graphql-tag/converts inline gql tag with fragment interpolation/options.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"plugins": [ | ||
[ | ||
"../../../../src" | ||
] | ||
] | ||
} |