From 856626b276eefee9e5fd596c018760b7466a9965 Mon Sep 17 00:00:00 2001 From: Ivan Maximov Date: Thu, 20 Apr 2023 19:03:27 +0300 Subject: [PATCH] Update readme --- README.md | 26 ++++++++++++------- .../ParserTests.CustomAST.cs | 2 +- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index f8e25f76..12a4a908 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,18 @@ # GraphQL.NET Parser -[![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) -[![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) - -[![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) -[![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) +[![License](https://img.shields.io/github/license/graphql-dotnet/parser)](LICENSE.md) [![codecov](https://codecov.io/gh/graphql-dotnet/parser/branch/master/graph/badge.svg?token=GEjwg1by60)](https://codecov.io/gh/graphql-dotnet/parser) - -[![NuGet](https://img.shields.io/nuget/v/GraphQL-Parser.svg)](https://www.nuget.org/packages/GraphQL-Parser) [![Nuget](https://img.shields.io/nuget/dt/GraphQL-Parser)](https://www.nuget.org/packages/GraphQL-Parser) +[![NuGet](https://img.shields.io/nuget/v/GraphQL-Parser.svg)](https://www.nuget.org/packages/GraphQL-Parser) +[![GitHub Release Date](https://img.shields.io/github/release-date/graphql-dotnet/parser?label=released)](https://github.com/graphql-dotnet/parser/releases) +[![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) +![Size](https://img.shields.io/github/repo-size/graphql-dotnet/parser) +[![GitHub contributors](https://img.shields.io/github/contributors/graphql-dotnet/parser)](https://github.com/graphql-dotnet/parser/graphs/contributors) ![Activity](https://img.shields.io/github/commit-activity/w/graphql-dotnet/parser) ![Activity](https://img.shields.io/github/commit-activity/m/graphql-dotnet/parser) ![Activity](https://img.shields.io/github/commit-activity/y/graphql-dotnet/parser) -![Size](https://img.shields.io/github/repo-size/graphql-dotnet/parser) - This library contains a lexer and parser as well as the complete [GraphQL AST model](http://spec.graphql.org/October2021/#sec-Appendix-Grammar-Summary) that allows you to work with GraphQL documents compatible with the [October 2021 spec](https://spec.graphql.org/October2021/). @@ -63,6 +60,17 @@ information about tokens locations in the source document, then use flag `IgnoreOptions.Locations`. Or just use `IgnoreOptions.All` and this will maximize the saving of memory allocated in the managed heap for AST. +You can parse not only entire `GraphQLDocument` but also concrete AST +nodes. Use generic overload. + +```csharp +string text1 = "enum Color { RED }" +var ast1 = Parser.Parse(text1); + +string text2 = "{ a: 1, b: \"abc\", c: RED, d: $id }"; +var ast2 = Parser.Parse(text2); // returns GraphQLObjectValue +``` + ## 3. ASTVisitor `ASTVisitor` provides API to traverse AST of the parsed GraphQL document. diff --git a/src/GraphQLParser.Tests/ParserTests.CustomAST.cs b/src/GraphQLParser.Tests/ParserTests.CustomAST.cs index 7bda9cb3..23b8909f 100644 --- a/src/GraphQLParser.Tests/ParserTests.CustomAST.cs +++ b/src/GraphQLParser.Tests/ParserTests.CustomAST.cs @@ -26,7 +26,7 @@ public void Should_Parse_Value_Literal_But_Not_Entire_Document(string text, ASTN { Should.Throw(() => Parser.Parse(text)); - var value = Parser.Parse(text); + var value = text.Parse(); value.ShouldNotBeNull(); value.Kind.ShouldBe(kind); if (expected != null)