extract-field-coordinates
v1.0.3
Published
extract field coordinates from GraphQL documents
Downloads
5
Readme
extract-field-coordinates
Statically extract a list of "field coordinates" contained in a GraphQL document
Install
$ yarn add --dev extract-field-coordinates
Example
e.g. for the following query:
query GET_BUSINESS($BizId: String) {
business(id: $BizId) {
name
location {
city
}
}
}
We would return the following set of field coordinates:
["Query.business", "Business.name", "Business.location", "Location.city"]
API
extractFieldCoordinates(
/**
* 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>
Sample Usage:
import extractFieldCoordinates from 'extract-field-coordinates';
const fieldCoordinates = extractFieldCoordinates(documentString, schemaText);