https://github.com/graphql-editor/graphql-js-tree
Simpler structure for GraphQL AST
https://github.com/graphql-editor/graphql-js-tree
Last synced: 7 months ago
JSON representation
Simpler structure for GraphQL AST
- Host: GitHub
- URL: https://github.com/graphql-editor/graphql-js-tree
- Owner: graphql-editor
- License: mit
- Created: 2021-08-17T08:16:22.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2024-12-04T12:26:56.000Z (about 1 year ago)
- Last Synced: 2024-12-11T10:37:20.546Z (about 1 year ago)
- Language: TypeScript
- Size: 146 KB
- Stars: 18
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE.md
Awesome Lists containing this project
- awesome-list - graphql-js-tree - editor | 8 | (TypeScript)
README

[](https://www.npmjs.com/package/graphql-js-tree) [](http://commitizen.github.io/cz-cli/) [](https://www.npmjs.com/package/graphql-js-tree)
Simplier approach to GraphQL parsing. Using graphql-js library and parsing AST to simplier types. It is a backbone of `graphql-zeus` and `graphql-editor`
## How it works
### SDL GraphQL
It creates very simple `ParserTree` from GraphQL schema
```js
import { Parser, TreeToGraphQL } from 'graphql-js-tree';
const schemaFileContents = `
type Query{
hello: String!
}
schema{
query: Query
}
`;
const parsedSchema = Parser.parse(schemaFileContents);
// Backwards
const graphqlString = TreeToGraphQL.parse(parsedSchema);
```
### GQL
```js
import { parseGql } from 'graphql-js-tree';
const schemaFileContents = `
type Query{
hello: String!
}
schema{
query: Query
}
`;
const gqlQuery = `
query MyQuery{
hello
}
`;
const parsedTrees = parseGql(gqlQuery, schemaFileContents);
// Backwards
const gqlString = parseGqlTrees(parsedTrees);
```
## Table of contents
- [How it works](#how-it-works)
- [SDL GraphQL](#sdl-graphql)
- [GQL](#gql)
- [Table of contents](#table-of-contents)
- [License](#license)
- [Support](#support)
- [Contribute](#contribute)
## License
MIT
## Support
[Join our GraphQL Editor Channel](https://join.slack.com/t/graphqleditor/shared_invite/enQtNDkwOTgyOTM5OTc1LWI4YjU3N2U5NGVkNzQ2NzY5MGUxMTJiNjFlZDM1Zjc2OWRmNTI0NDM3OWUxYTk4Yjk3MzZlY2QwOWUzZmM2NDI)
Leave a star ;)
## Contribute
For a complete guide to contributing to GraphQL Editor, see the [Contribution Guide](CONTRIBUTING.md).
1. Fork this repo
2. Create your feature branch: git checkout -b feature-name
3. Commit your changes: git commit -am 'Add some feature'
4. Push to the branch: git push origin my-new-feature
5. Submit a pull request