Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sharkcore/extract-schema-coordinates

Extract field coordinates from GraphQL documents
https://github.com/sharkcore/extract-schema-coordinates

graphql graphql-js graphql-schema query

Last synced: 3 months ago
JSON representation

Extract field coordinates from GraphQL documents

Awesome Lists containing this project

README

        

# extract-schema-coordinates

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

## Install

```bash
$ yarn add extract-schema-coordinates
```

## Example

e.g. for the following query:

```graphql
query GET_BUSINESS($BizId: String) {
business(id: $BizId) {
name
location {
city
}
}
}
```

We would return the following set of schema coordinates:

```json
["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
```

### Usage:

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