Language

Tanka GraphQL implements lexer and parser for GraphQL. Implementation is done following the latest draft specification (2020).

Lexer reads stream of tokens from UTF8 byte array (ReadOnlySpan) and parser turns these tokens into syntax tree.

Example: Parser usage

        [Fact]
        public void ExecutableDocument()
        {
            /* Given */
            var source = @"query {
                                field
                            }
                            mutation {
                                field
                            }
                            subscription {
                                field
                            }
                            ";

            var sut = Parser.Create(source);
            
            /* When */
            var actual = sut.ParseExecutableDocument();

            /* Then */
            Assert.Equal(3, actual.OperationDefinitions?.Count);
        }

Example: Parser usage simplified

        
        [Fact]
        public void FromString()
        {
            /* Given */
            /* When */
            ObjectDefinition original =
                @"type Obj {
                    field1: String
                }";

            /* Then */
            Assert.Equal("Obj", original.Name);
            Assert.NotNull(original.Fields);
        }