@acrool/graphql-codegen-apollo-subscription
Advanced tools
Comparing version 3.0.1-test.6 to 3.0.1-test.7
@@ -20,12 +20,17 @@ "use strict"; | ||
const allAst = (0, graphql_1.concatAST)(documents.map(v => v.document)); | ||
console.log('allAst', allAst); | ||
const allFragments = [ | ||
...allAst.definitions.filter(d => d.kind === graphql_1.Kind.FRAGMENT_DEFINITION).map(fragmentDef => { | ||
return { | ||
node: fragmentDef, | ||
name: fragmentDef.name.value, | ||
onType: fragmentDef.typeCondition.name.value, | ||
isExternal: false, | ||
}; | ||
}), | ||
...(config.externalFragments || []), | ||
// ...( | ||
// allAst.definitions.filter( | ||
// d => d.kind === Kind.FRAGMENT_DEFINITION, | ||
// ) as FragmentDefinitionNode[] | ||
// ).map(fragmentDef => { | ||
// return { | ||
// node: fragmentDef, | ||
// name: fragmentDef.name.value, | ||
// onType: fragmentDef.typeCondition.name.value, | ||
// isExternal: false, | ||
// }; | ||
// }), | ||
// ...(config.externalFragments || []), | ||
]; | ||
@@ -35,16 +40,2 @@ const visitor = new visitor_1.ReactQueryVisitor(schema, allFragments, config, documents); | ||
const visitorResult = (0, plugin_helpers_1.oldVisit)(allAst, { leave: visitor }); | ||
// 產生 Keys | ||
const operationNames = documents.reduce((curr, row) => { | ||
row.document.definitions.map(x => { | ||
if ('name' in x && 'kind' in x && 'operation' in x) { | ||
if (x.operation === 'query' && x.name.kind === 'Name') { | ||
curr.queryKey.push(`${x.name.value} = '${x.name.value}'`); | ||
} | ||
if (x.operation === 'mutation' && x.name.kind === 'Name') { | ||
curr.mutationKey.push(`${x.name.value} = '${x.name.value}'`); | ||
} | ||
} | ||
}); | ||
return curr; | ||
}, { queryKey: [], mutationKey: [] }); | ||
if (visitor.hasOperations) { | ||
@@ -54,4 +45,2 @@ return { | ||
content: [ | ||
`export enum EQueryKey{\n${operationNames.queryKey.join(',\n')}}`, | ||
`export enum EMutationKey{\n${operationNames.mutationKey.join(',\n')}}`, | ||
visitor.fragments, | ||
@@ -58,0 +47,0 @@ ...visitorResult.definitions.filter(t => typeof t === 'string'), |
{ | ||
"name": "@acrool/graphql-codegen-apollo-subscription", | ||
"version": "3.0.1-test.6", | ||
"version": "3.0.1-test.7", | ||
"description": "react-query for graphql-code-generator", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
42253
583