Utilities useful for language services across runtimes
extract all operation nodes, and if schema is present, variable definitions, in a map
{DocumentNode} a graphql-js compatible AST node
Optional
{GraphQLSchema} optional schema
const { variablesToType, operations } = getOperationASTFacts( parse('documentString'), ); operations.forEach(op => { console.log(op.name, op.operation, op.loc); }); Object.entries(variablesToType).forEach(([variableName, type]) => { console.log(variableName, type); }); Copy
const { variablesToType, operations } = getOperationASTFacts( parse('documentString'), ); operations.forEach(op => { console.log(op.name, op.operation, op.loc); }); Object.entries(variablesToType).forEach(([variableName, type]) => { console.log(variableName, type); });
Utilities useful for language services across runtimes