Skip to content

sharkcore/extract-schema-coordinates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

4499ed9 · Nov 20, 2023

History

42 Commits
Nov 13, 2023
Nov 13, 2023
Nov 13, 2023
Nov 13, 2023
Nov 13, 2023
Apr 23, 2020
Jan 25, 2023
Nov 13, 2023
Jan 25, 2023
Nov 13, 2023
Nov 13, 2023
Nov 20, 2023
Nov 13, 2023
Nov 19, 2023
Nov 13, 2023

Repository files navigation

extract-schema-coordinates

Extract a list of "schema coordinates" contained in a GraphQL document

Install

$ yarn add extract-schema-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 schema coordinates:

["Query.business", "Business.name", "Business.location", "Location.city"]

API

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>

Usage:

import extractSchemaCoordinates from 'extract-schema-coordinates';
const coordinates = extractSchemaCoordinates(documentString, schemaText);