示例#1
0
        public void OneGraph_Schema()
        {
            // arrange
            byte[] sourceText = Encoding.UTF8.GetBytes(FileResource.Open("onegraph.graphql"));

            // act
            DocumentNode document = Utf8GraphQLParser.Parse(sourceText);

            // assert
            document.ToString().MatchSnapshot();
        }
示例#2
0
        public void ParserScalarType()
        {
            // arrange
            var sourceText = "scalar FOO @foo(a: \"123\")";
            var parser     = new Utf8GraphQLParser(
                Encoding.UTF8.GetBytes(sourceText));

            // act
            DocumentNode document = parser.Parse();

            // assert
            document.ToString().MatchSnapshot();
        }
示例#3
0
        public void RewriteEveryFieldOfTheQuery()
        {
            // arange
            DocumentNode document = Utf8GraphQLParser.Parse(
                "{ foo { bar { baz } } }");

            // act
            DocumentNode rewritten = document
                                     .Rewrite <DirectiveQuerySyntaxRewriter, DirectiveNode>(
                new DirectiveNode("upper"));

            // assert
            rewritten.ToString(false).MatchSnapshot();
        }
示例#4
0
        public void ParseUnion()
        {
            // arrange
            var sourceText = "union Foo @foo(a: \"123\") = "
                             + "BAR | BAZ ";
            var parser = new Utf8GraphQLParser(
                Encoding.UTF8.GetBytes(sourceText));

            // act
            DocumentNode document = parser.Parse();

            // assert
            document.ToString().MatchSnapshot();
        }
示例#5
0
        public void ParseEnum()
        {
            // arrange
            var sourceText = "enum Foo @foo(a: \"123\") "
                             + "{ BAR @foo(a: 123) , BAZ }";
            var parser = new Utf8GraphQLParser(
                Encoding.UTF8.GetBytes(sourceText));

            // act
            DocumentNode document = parser.Parse();

            // assert
            document.ToString().MatchSnapshot();
        }
示例#6
0
        public void ParserInputObjectType()
        {
            // arrange
            var sourceText = "input a @foo(a: \"123\") " +
                             "{ b: String @foo(a: \"123\") c: Int = 123 }";
            var parser = new Utf8GraphQLParser(
                Encoding.UTF8.GetBytes(sourceText));

            // act
            DocumentNode document = parser.Parse();

            // assert
            document.ToString().MatchSnapshot();
        }
示例#7
0
        public void ParserSimpleInterfaceType()
        {
            // arrange
            var sourceText = "interface a implements e @foo(a: \"123\") " +
                             "{ b: String @foo(a: \"123\") " +
                             "c(d: F = ENUMVALUE @foo(a: \"123\")): Int }";
            var parser = new Utf8GraphQLParser(
                Encoding.UTF8.GetBytes(sourceText));

            // act
            DocumentNode document = parser.Parse();

            // assert
            document.ToString().MatchSnapshot();
        }
示例#8
0
        public void ParseSchemaDefinition()
        {
            // arrange
            var sourceText = "\"\"\"\nDescription\n\"\"\"" +
                             "schema @foo(a: \"123\") " +
                             "{ query: Foo mutation: Bar subscription: Baz }";
            var parser = new Utf8GraphQLParser(
                Encoding.UTF8.GetBytes(sourceText));

            // act
            DocumentNode document = parser.Parse();

            // assert
            document.ToString().MatchSnapshot();
        }
示例#9
0
        public void ParseFacebookKitchenSinkQuery()
        {
            // arrange
            var querySource =
                FileResource.Open("kitchen-sink.graphql")
                .NormalizeLineBreaks();
            var parser = new Utf8GraphQLParser(
                Encoding.UTF8.GetBytes(querySource));

            // act
            DocumentNode document = parser.Parse();

            // assert
            document.ToString().MatchSnapshot(new SnapshotNameExtension("sdl"));
            document.MatchSnapshot();
        }