platform/graphql_parser
2019-04-18 10:44:37 -04:00
..
example Bump graphql_parser -> 1.1.0 2018-08-04 20:44:41 -04:00
lib Add "exclude" to Parser.next to explicitly ignore "on" when necessary 2019-03-31 16:29:10 -04:00
test Finish next_name_test 2019-03-31 16:31:58 -04:00
.gitignore ignore dart tool 2018-08-04 20:58:59 -04:00
analysis_options.yaml Fix type errors in tests 2018-08-02 09:05:52 -04:00
CHANGELOG.md Add nextName instead of using reserved names 2019-03-31 16:07:25 -04:00
graphql_parser.iml Fix type errors in tests 2018-08-02 09:05:52 -04:00
LICENSE Restructure 2018-08-02 08:48:53 -04:00
mono_pkg.yaml mono_repo 2019-01-23 14:52:02 -05:00
pubspec.yaml Bump to 1.1.3 2019-03-31 16:32:09 -04:00
README.md Add June 2018 link to gql_parser 2019-04-18 10:44:37 -04:00

graphql_parser

Pub build status

Parses GraphQL queries and schemas.

This library is merely a parser/visitor. Any sort of actual GraphQL API functionality must be implemented by you, or by a third-party package.

Angel framework users should consider package:angel_graphql as a dead-simple way to add GraphQL functionality to their servers.

Installation

Add graphql_parser as a dependency in your pubspec.yaml file:

dependencies:
  graphql_parser: ^1.0.0

Usage

The AST featured in this library was originally directly based off this ANTLR4 grammar created by Joseph T. McBride: https://github.com/antlr/grammars-v4/blob/master/graphql/GraphQL.g4

It has since been updated to reflect upon the grammar in the official GraphQL specification ( June 2018).

import 'package:graphql_parser/graphql_parser.dart';

doSomething(String text) {
  var tokens = scan(text);
  var parser = new Parser(tokens);
  
  if (parser.errors.isNotEmpty) {
    // Handle errors...
  }
  
  // Parse the GraphQL document using recursive descent
  var doc = parser.parseDocument();
  
  // Do something with the parsed GraphQL document...
}