예제 #1
0
        private static ISchema CreateSchema(DocumentNode schema)
        {
            SchemaBuilder builder = SchemaBuilder.New();

            foreach (CustomScalarType type in schema.Definitions
                     .OfType <ScalarTypeDefinitionNode>()
                     .Where(t => !Scalars.IsBuiltIn(t.Name.Value))
                     .Select(t => new CustomScalarType(t)))
            {
                builder.AddType(type);
            }

            return(builder.Use(next => context => Task.CompletedTask)
                   .AddDocument(schema)
                   .AddDirectiveType <NameDirectiveType>()
                   .AddDirectiveType <TypeDirectiveType>()
                   .AddDirectiveType <SerializationDirectiveType>()
                   .AddDirectiveType <DelegateDirectiveType>()
                   .ModifyOptions(t => t.StrictValidation = false)
                   .Create());
        }