Ejemplo n.º 1
0
 public void Values_Parse_Successfully(ASTNodeKind kind, string valueString)
 {
     //note: thousand separators and/or culture-specific characters are invalid graphql literals, and will not be returned by graphql-parser
     //uppercase TRUE and FALSE are also invalid graphql input data, and will not be returned by graphql-parser
     //whitespace will not be returned by graphql-parser
     _ = CoreToVanillaConverter.Value(new GraphQLScalarValue(kind)
     {
         Value = valueString
     });
 }
Ejemplo n.º 2
0
        public Document Build(string body)
        {
            var source = new Source(body);
            var result = _parser.Parse(source);

            var document = CoreToVanillaConverter.Convert(body, result);

            document.OriginalQuery = body;
            return(document);
        }
Ejemplo n.º 3
0
        public void operation_comment_should_not_be_null()
        {
            const string query = @"#comment
query _ {
    person {
        name
    }
}";

            var document = CoreToVanillaConverter.Convert(query, _parser.Parse(new Source(query)));

            document.Operations.First().Comment.ShouldBe("comment");
        }
Ejemplo n.º 4
0
        public void operation_comment_should_be_null()
        {
            const string query = @"
query _ {
    person {
        name
    }
}";

            var document = CoreToVanillaConverter.Convert(Parser.Parse(query));

            document.Operations.First().Comment.ShouldBeNull();
        }
Ejemplo n.º 5
0
        public void operation_comment_should_not_be_null()
        {
            const string query = @"#comment
query _ {
    person {
        name
    }
}";

            var document = CoreToVanillaConverter.Convert(Parser.Parse(query, new ParserOptions {
                Ignore = IgnoreOptions.None
            }));

            document.Operations.First().Comment.ShouldBe("comment");
        }
Ejemplo n.º 6
0
        public void field_comment_should_be_null()
        {
            const string query = @"
query _ {
    person {
        name
    }
}";

            var document = CoreToVanillaConverter.Convert(query, _parser.Parse(new Source(query)));

            document.Operations.First()
            .SelectionSet.Selections.OfType <Field>().First().Comment.ShouldBeNull();
            document.Operations.First()
            .SelectionSet.Selections.OfType <Field>().First()
            .SelectionSet.Selections.OfType <Field>().First().Comment.ShouldBeNull();
        }
Ejemplo n.º 7
0
        public void argument_comment_should_not_be_null()
        {
            const string query = @"
query _ {
    person(
        #comment
        _where: ""foo"") {
        name
    }
}";

            var document = CoreToVanillaConverter.Convert(query, _parser.Parse(new Source(query)));

            document.Operations.First()
            .SelectionSet.Selections.OfType <Field>().First()
            .Arguments.First().Comment.ShouldBe("comment");
        }
Ejemplo n.º 8
0
        public void inlinefragment_comment_should_not_be_null()
        {
            const string query = @"
query _ {
    person {
        #comment
        ... on human {
            name
        }
    }
}";

            var document = CoreToVanillaConverter.Convert(query, _parser.Parse(new Source(query)));

            document.Operations.First()
            .SelectionSet.Selections.OfType <Field>().First()
            .SelectionSet.Selections.OfType <InlineFragment>().First().Comment.ShouldBe("comment");
        }
Ejemplo n.º 9
0
        public void fragmentdefinition_comment_should_not_be_null()
        {
            const string query = @"
query _ {
    person {
        ...human
    }
}

#comment
fragment human on person {
        name
}";

            var document = CoreToVanillaConverter.Convert(query, _parser.Parse(new Source(query)));

            document.Fragments.First().Comment.ShouldBe("comment");
        }
Ejemplo n.º 10
0
        public Document Build(string body)
        {
            var             source = new Source(body);
            GraphQLDocument result;

            try
            {
                result = _parser.Parse(source);
            }
            catch (GraphQLSyntaxErrorException ex)
            {
                throw new SyntaxError(ex);
            }

            var document = CoreToVanillaConverter.Convert(body, result);

            document.OriginalQuery = body;
            return(document);
        }
        public Document Build(string body)
        {
            GraphQLDocument result;

            try
            {
                result = Parser.Parse(body, new ParserOptions {
                    Ignore = IgnoreComments ? IgnoreOptions.IgnoreComments : IgnoreOptions.None
                });
            }
            catch (GraphQLSyntaxErrorException ex)
            {
                throw new SyntaxError(ex);
            }

            var document = CoreToVanillaConverter.Convert(result);

            document.OriginalQuery = body;
            return(document);
        }
Ejemplo n.º 12
0
        public void field_comment_should_not_be_null()
        {
            const string query = @"
query _ {
    #comment1
    person {
        #comment2
        name
    }
}";

            var document = CoreToVanillaConverter.Convert(Parser.Parse(query, new ParserOptions {
                Ignore = IgnoreOptions.None
            }));

            document.Operations.First()
            .SelectionSet.Selections.OfType <Field>().First().Comment.ShouldBe("comment1");
            document.Operations.First()
            .SelectionSet.Selections.OfType <Field>().First()
            .SelectionSet.Selections.OfType <Field>().First().Comment.ShouldBe("comment2");
        }
Ejemplo n.º 13
0
        public void fragmentspread_comment_should_not_be_null()
        {
            const string query = @"
query _ {
    person {
        #comment
        ...human
    }
}

fragment human on person {
        name
}";

            var document = CoreToVanillaConverter.Convert(Parser.Parse(query, new ParserOptions {
                Ignore = IgnoreOptions.None
            }));

            document.Operations.First()
            .SelectionSet.Selections.OfType <Field>().First()
            .SelectionSet.Selections.OfType <FragmentSpread>().First().Comment.ShouldBe("comment");
        }
 public FederatedSchemaPrinter(ISchema schema, SchemaPrinterOptions options = null)
     : base(schema, options)
 {
     _converter = new CoreToVanillaConverter("");
 }
        public string PrintAstDirective(GraphQLDirective directive)
        {
            Schema?.Initialize();

            return(AstPrinter.Print(CoreToVanillaConverter.Directive(directive)));
        }
 public Document Convert()
 {
     return(CoreToVanillaConverter.Convert(GraphQLDocument));
 }
Ejemplo n.º 17
0
 public string PrintAstDirective(GraphQLDirective directive) => AstPrinter.Print(CoreToVanillaConverter.Directive(directive));
 public GraphQLDocumentBuilder()
 {
     _lexer = new Lexer();
     _parser = new Parser(_lexer);
     _converter = new CoreToVanillaConverter();
 }
Ejemplo n.º 19
0
 public GraphQLDocumentBuilder()
 {
     _lexer     = new Lexer();
     _parser    = new Parser(_lexer);
     _converter = new CoreToVanillaConverter();
 }