platform/packages/graphql/graphql_parser
2021-02-14 13:22:25 +08:00
..
example Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca' 2020-02-15 18:22:07 -05:00
lib Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca' 2020-02-15 18:22:07 -05:00
test Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca' 2020-02-15 18:22:07 -05:00
.gitignore Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca' 2020-02-15 18:22:07 -05:00
analysis_options.yaml Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca' 2020-02-15 18:22:07 -05:00
CHANGELOG.md Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca' 2020-02-15 18:22:07 -05:00
graphql_parser.iml Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca' 2020-02-15 18:22:07 -05:00
LICENSE Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca' 2020-02-15 18:22:07 -05:00
mono_pkg.yaml Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca' 2020-02-15 18:22:07 -05:00
pubspec.yaml Updated dart requirements to 2.10 2021-02-14 13:22:25 +08:00
README.md Add 'packages/graphql/' from commit '33e2f86ba73d559197b6270df036256104726aca' 2020-02-15 18:22:07 -05: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 = 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...
}