Skip to content

Commit 13ece49

Browse files
Adding experimental online parser (#2770)
* Adding experimental online parser * Improve Typings * Update grammar structure * Move rules to js * Fix build Co-authored-by: Ivan Goncharov <[email protected]>
1 parent 3b10b17 commit 13ece49

File tree

7 files changed

+2890
-0
lines changed

7 files changed

+2890
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
## Experimental Online Parser
2+
3+
This directory contains an experimental online parser based on JSON rules set. It is a state-full parser which parses a source string incrementally i.e. emits a token each time.
4+
5+
The parser is being migrated from graphiql to graphql-js and may have frequent breaking changes.
6+
7+
Example:
8+
9+
```js
10+
import { OnlineParser } from 'graphql/language/experimentalOnlineParser';
11+
12+
const source = `
13+
query SomeQuery {
14+
some_field {
15+
another_field
16+
}
17+
}
18+
`;
19+
20+
const parser = new OnlineParser(source);
21+
let token;
22+
23+
do {
24+
token = parser.parseToken();
25+
} while (token.kind !== '<EOF>' && token.kind !== 'Invalid');
26+
```

0 commit comments

Comments
 (0)