예제 #1
0
        public Document Build(string body)
        {
            var source   = new Source(body);
            var result   = _parser.Parse(source);
            var document = _converter.Convert(body, result);

            document.OriginalQuery = body;
            return(document);
        }
예제 #2
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");
        }
예제 #3
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();
        }
예제 #4
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");
        }
예제 #5
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();
        }
예제 #6
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");
        }
예제 #7
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");
        }
예제 #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");
        }
예제 #9
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);
        }
예제 #11
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");
        }
예제 #12
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 Document Convert()
 {
     return(CoreToVanillaConverter.Convert(GraphQLDocument));
 }