Working on a project that uses primarily the gql tagged template literal for defining queries, but .graphql|.gql files for defining fragments.
Currently persistgraphql seems to be an either-or proposition. If you pass in the --js --extension=js arguments, the fragments aren't in the docMap, and as a result the following throws
export function isOperationDefinition(defn: DefinitionNode): defn is OperationDefinitionNode {
return (defn.kind === 'OperationDefinition');
}
Trace:
TypeError: Cannot read property 'kind' of undefined
at isOperationDefinition (/Users/mergebandit/dev/super-top-secret-but-totes-badass-project/node_modules/persistgraphql/lib/src/extractFromAST.js:5:17)
at Array.filter (<anonymous>)
at Object.getOperationDefinitions (/Users/mergebandit/dev/super-top-secret-but-totes-badass-project/node_modules/persistgraphql/lib/src/extractFromAST.js:46:28)
at ExtractGQL.createMapFromDocument (/Users/mergebandit/dev/super-top-secret-but-totes-badass-project/node_modules/persistgraphql/lib/src/ExtractGQL.js:70:49)
at /Users/mergebandit/dev/super-top-secret-but-totes-badass-project/node_modules/persistgraphql/lib/src/ExtractGQL.js:99:26
at Array.map (<anonymous>)
at ExtractGQL.createOutputMapFromString (/Users/mergebandit/dev/super-top-secret-but-totes-badass-project/node_modules/persistgraphql/lib/src/ExtractGQL.js:95:46)
at /Users/mergebandit/dev/super-top-secret-but-totes-badass-project/node_modules/persistgraphql/lib/src/ExtractGQL.js:132:31
at <anonymous>
Seems to me that, if you choose the .js argument, it should still be able to extract .graphql files and merge them into the output document mapping.
Working on a project that uses primarily the
gql
tagged template literal for defining queries, but.graphql|.gql
files for defining fragments.Currently persistgraphql seems to be an either-or proposition. If you pass in the
--js --extension=js
arguments, the fragments aren't in the docMap, and as a result the following throwsextractFromAST
Trace:
Seems to me that, if you choose the
.js
argument, it should still be able to extract.graphql
files and merge them into the output document mapping.