Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/sharkcore/extract-schema-coordinates
- Owner: sharkcore
- Created: 2020-04-23T02:30:25.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-11-20T15:13:20.000Z (about 1 year ago)
- Last Synced: 2024-10-08T22:05:01.368Z (4 months ago)
- Topics: graphql, graphql-js, graphql-schema, query
- Language: JavaScript
- Homepage:
- Size: 199 KB
- Stars: 12
- Watchers: 6
- Forks: 0
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
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);
```