1.0.3 • Published 1 year ago

extract-field-coordinates v1.0.3

Weekly downloads
10
License
MIT
Repository
github
Last release
1 year ago

extract-field-coordinates

npm (scoped) Build Status

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);
1.0.3

1 year ago

1.0.2

4 years ago