Skip to content

Commit 0e0a871

Browse files
authored
Update readme (#308)
1 parent 7b0e9da commit 0e0a871

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

README.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,18 @@
11
# GraphQL.NET Parser
22

3-
[![Publish release to Nuget registry](https://github.com/graphql-dotnet/parser/actions/workflows/publish-release.yml/badge.svg)](https://github.com/graphql-dotnet/parser/actions/workflows/publish-release.yml)
4-
[![Publish preview to GitHub registry](https://github.com/graphql-dotnet/parser/actions/workflows/publish-preview.yml/badge.svg)](https://github.com/graphql-dotnet/parser/actions/workflows/publish-preview.yml)
5-
6-
[![Run unit tests](https://github.com/graphql-dotnet/parser/actions/workflows/test.yml/badge.svg)](https://github.com/graphql-dotnet/parser/actions/workflows/test.yml)
7-
[![CodeQL analysis](https://github.com/graphql-dotnet/parser/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/graphql-dotnet/parser/actions/workflows/codeql-analysis.yml)
3+
[![License](https://img.shields.io/github/license/graphql-dotnet/parser)](LICENSE.md)
84
[![codecov](https://codecov.io/gh/graphql-dotnet/parser/branch/master/graph/badge.svg?token=GEjwg1by60)](https://codecov.io/gh/graphql-dotnet/parser)
9-
10-
[![NuGet](https://img.shields.io/nuget/v/GraphQL-Parser.svg)](https://www.nuget.org/packages/GraphQL-Parser)
115
[![Nuget](https://img.shields.io/nuget/dt/GraphQL-Parser)](https://www.nuget.org/packages/GraphQL-Parser)
6+
[![NuGet](https://img.shields.io/nuget/v/GraphQL-Parser.svg)](https://www.nuget.org/packages/GraphQL-Parser)
7+
[![GitHub Release Date](https://img.shields.io/github/release-date/graphql-dotnet/parser?label=released)](https://github.com/graphql-dotnet/parser/releases)
8+
[![GitHub commits since latest release (by date)](https://img.shields.io/github/commits-since/graphql-dotnet/parser/latest?label=new+commits)](https://github.com/graphql-dotnet/parser/commits/master)
9+
![Size](https://img.shields.io/github/repo-size/graphql-dotnet/parser)
1210

11+
[![GitHub contributors](https://img.shields.io/github/contributors/graphql-dotnet/parser)](https://github.com/graphql-dotnet/parser/graphs/contributors)
1312
![Activity](https://img.shields.io/github/commit-activity/w/graphql-dotnet/parser)
1413
![Activity](https://img.shields.io/github/commit-activity/m/graphql-dotnet/parser)
1514
![Activity](https://img.shields.io/github/commit-activity/y/graphql-dotnet/parser)
1615

17-
![Size](https://img.shields.io/github/repo-size/graphql-dotnet/parser)
18-
1916
This library contains a lexer and parser as well as the complete [GraphQL AST model](http://spec.graphql.org/October2021/#sec-Appendix-Grammar-Summary)
2017
that allows you to work with GraphQL documents compatible with the [October 2021 spec](https://spec.graphql.org/October2021/).
2118

@@ -63,6 +60,17 @@ information about tokens locations in the source document, then use flag
6360
`IgnoreOptions.Locations`. Or just use `IgnoreOptions.All` and this
6461
will maximize the saving of memory allocated in the managed heap for AST.
6562

63+
You can parse not only entire `GraphQLDocument` but also concrete AST
64+
nodes. Use generic overload.
65+
66+
```csharp
67+
string text1 = "enum Color { RED }"
68+
var ast1 = Parser.Parse<GraphQLEnumTypeDefinition>(text1);
69+
70+
string text2 = "{ a: 1, b: \"abc\", c: RED, d: $id }";
71+
var ast2 = Parser.Parse<GraphQLValue>(text2); // returns GraphQLObjectValue
72+
```
73+
6674
## 3. ASTVisitor
6775

6876
`ASTVisitor` provides API to traverse AST of the parsed GraphQL document.

src/GraphQLParser.Tests/ParserTests.CustomAST.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public void Should_Parse_Value_Literal_But_Not_Entire_Document(string text, ASTN
2626
{
2727
Should.Throw<GraphQLSyntaxErrorException>(() => Parser.Parse(text));
2828

29-
var value = Parser.Parse<GraphQLValue>(text);
29+
var value = text.Parse<GraphQLValue>();
3030
value.ShouldNotBeNull();
3131
value.Kind.ShouldBe(kind);
3232
if (expected != null)

0 commit comments

Comments
 (0)