Extract a list of "schema coordinates" contained in a GraphQL document
$ yarn add extract-schema-coordinates
e.g. for the following query:
query GET_BUSINESS($BizId: String) {
business(id: $BizId) {
name
location {
city
}
}
}
We would return the following set of schema coordinates:
["Query.business", "Business.name", "Business.location", "Location.city"]
extractSchemaCoordinates(
/**
* The text of the document to analyse, in raw string format
*/
documentText: string,
/**
* The text of your schema, in string SDL format (e.g. as created by printSchema)
* @see https://graphql.org/graphql-js/utilities/#printschema
*/
schemaText: string,
): Set<string>
import extractSchemaCoordinates from 'extract-schema-coordinates';
const coordinates = extractSchemaCoordinates(documentString, schemaText);