extract-field-coordinates

1.0.3 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i extract-field-coordinates

Weekly Downloads

2

Version

1.0.3

License

MIT

Unpacked Size

36.2 kB

Total Files

5

Last publish

Collaborators

  • magicmark