public void Serialize_ObjectTypeImplementsXYZ_InOutShouldBeTheSame()
        {
            // arrange
            string query = "type Foo implements X & Y & Z " +
                           "{ bar: String baz: [Int] }";

            var serializer = new SchemaSyntaxSerializer();
            var content    = new StringBuilder();
            var writer     = new StringWriter(content);

            DocumentNode queryDocument = Parser.Default.Parse(query);

            // act
            serializer.Visit(queryDocument, new DocumentWriter(writer));

            // assert
            Assert.Equal(
                query,
                content.ToString());
        }
        public void Serialize_ObjectTypeDefWithDescriptionWithIndent_OutHasIndentation()
        {
            // arrange
            string query = "\"abc\" type Foo @a { \"abc\" bar: String " +
                           "\"abc\" baz: [Int] } " +
                           "\"abc\" type Foo @a @b { \"abc\" bar: String @foo " +
                           "\"abc\" baz(\"abc\" a: String = \"abc\"): [Int] @foo @bar }";

            var serializer = new SchemaSyntaxSerializer(true);
            var content    = new StringBuilder();
            var writer     = new StringWriter(content);

            DocumentNode queryDocument = Parser.Default.Parse(query);

            // act
            serializer.Visit(queryDocument, new DocumentWriter(writer));

            // assert
            content.ToString().Snapshot();
        }
        public void Serialize_InputObjectTypeDefWithDirectiveNoIndent_InOutShouldBeTheSame()
        {
            // arrange
            string query = "input A @a @b(c: 1) { b: String @a @b(c: 1) " +
                           "c: [String!]! @a @b(c: 1) d: Int = 1 @a @b(c: 1) }";

            var serializer = new SchemaSyntaxSerializer();
            var content    = new StringBuilder();
            var writer     = new StringWriter(content);

            DocumentNode queryDocument = Parser.Default.Parse(query);

            // act
            serializer.Visit(queryDocument, new DocumentWriter(writer));

            // assert
            Assert.Equal(
                query,
                content.ToString());
        }
Exemple #4
0
        public void Serialize_ObjectTypeDefWithDirectivesNoIndent_InOutShouldBeTheSame()
        {
            // arrange
            string query = "type Foo @a(x: \"y\") { bar: String baz: [Int] } " +
                           "type Foo @a @b { bar: String @foo " +
                           "baz(a: String = \"abc\"): [Int] @foo @bar }";

            var serializer = new SchemaSyntaxSerializer();
            var content    = new StringBuilder();
            var writer     = new StringWriter(content);

            DocumentNode queryDocument = Utf8GraphQLParser.Parse(query);

            // act
            serializer.Visit(queryDocument, new DocumentWriter(writer));

            // assert
            Assert.Equal(
                query,
                content.ToString());
        }
        public void Serialize_ObjectTypeDefWithDescriptionNoIndent_InOutShouldBeTheSame()
        {
            // arrange
            string query = "\"abc\" type Foo @a { \"abc\" bar: String " +
                           "\"abc\" baz: [Int] } " +
                           "\"abc\" type Foo @a @b { \"abc\" bar: String @foo " +
                           "\"abc\" baz(\"abc\" a: String = \"abc\"): [Int] @foo @bar }";

            var serializer = new SchemaSyntaxSerializer();
            var content    = new StringBuilder();
            var writer     = new StringWriter(content);

            DocumentNode queryDocument = Parser.Default.Parse(query);

            // act
            serializer.Visit(queryDocument, new DocumentWriter(writer));

            // assert
            Assert.Equal(
                query,
                content.ToString());
        }
Exemple #6
0
        public static void Serialize(DocumentNode node, TextWriter writer, bool useIndentation)
        {
            var serializer = new SchemaSyntaxSerializer(useIndentation);

            serializer.Visit(node, new DocumentWriter(writer));
        }