private DocumentNode MergeSchemaExtensions(DocumentNode schema)
        {
            if (_extensions.Count == 0)
            {
                return(schema);
            }

            var          rewriter      = new AddSchemaExtensionRewriter();
            DocumentNode currentSchema = schema;

            foreach (DocumentNode extension in _extensions)
            {
                currentSchema = rewriter.AddExtensions(
                    currentSchema, extension);
            }

            return(currentSchema);
        }
Exemple #2
0
            private static DocumentNode AddExtensions(
                DocumentNode schema,
                IReadOnlyCollection <DocumentNode> extensions)
            {
                if (extensions.Count == 0)
                {
                    return(schema);
                }

                var          rewriter      = new AddSchemaExtensionRewriter();
                DocumentNode currentSchema = schema;

                foreach (DocumentNode extension in extensions)
                {
                    currentSchema = rewriter.AddExtensions(
                        currentSchema, extension);
                }

                return(currentSchema);
            }
Exemple #3
0
        private DocumentNode MergeSchemaExtensions(DocumentNode schema)
        {
            if (_extensions.Count == 0)
            {
                return(schema);
            }

            var rewriter = new AddSchemaExtensionRewriter(new[]
            {
                new DirectiveDefinitionNode
                (
                    null,
                    new NameNode(GeneratorDirectives.ClrType),
                    null,
                    false,
                    new[]
                {
                    new InputValueDefinitionNode(
                        null,
                        new NameNode(GeneratorDirectives.NameArgument),
                        null,
                        new NonNullTypeNode(new NamedTypeNode("String")),
                        null,
                        Array.Empty <DirectiveNode>()
                        )
                },
                    new []
                {
                    new NameNode(HotChocolate.Language.DirectiveLocation.Scalar.ToString())
                }
                ),
                new DirectiveDefinitionNode
                (
                    null,
                    new NameNode(GeneratorDirectives.SerializationType),
                    null,
                    false,
                    new[]
                {
                    new InputValueDefinitionNode(
                        null,
                        new NameNode(GeneratorDirectives.NameArgument),
                        null,
                        new NonNullTypeNode(new NamedTypeNode("String")),
                        null,
                        Array.Empty <DirectiveNode>()
                        )
                },
                    new []
                {
                    new NameNode(HotChocolate.Language.DirectiveLocation.Scalar.ToString())
                }
                ),
                new DirectiveDefinitionNode
                (
                    null,
                    new NameNode(GeneratorDirectives.Name),
                    null,
                    false,
                    new[]
                {
                    new InputValueDefinitionNode(
                        null,
                        new NameNode(GeneratorDirectives.NameArgument),
                        null,
                        new NonNullTypeNode(new NamedTypeNode("String")),
                        null,
                        Array.Empty <DirectiveNode>()
                        )
                },
                    new []
                {
                    new NameNode(HotChocolate.Language.DirectiveLocation.Scalar.ToString())
                }
                )
            });

            DocumentNode currentSchema = schema;

            foreach (DocumentNode extension in _extensions)
            {
                currentSchema = rewriter.AddExtensions(
                    currentSchema, extension);
            }

            return(currentSchema);
        }