public override void OnBeforeCreate( IDescriptorContext context, ISchemaBuilder schemaBuilder) { var allSchemas = new OrderedDictionary <NameString, DocumentNode>(); foreach (KeyValuePair <NameString, IRequestExecutor> executor in context.GetRemoteExecutors()) { allSchemas.Add( executor.Key, Utf8GraphQLParser.Parse(executor.Value.Schema.Print())); } IReadOnlyList <DocumentNode> typeExtensions = context.GetTypeExtensions(); // merge schemas DocumentNode mergedSchema = MergeSchemas(context, allSchemas); mergedSchema = AddExtensions(mergedSchema, typeExtensions); mergedSchema = RewriteMerged(context, mergedSchema); mergedSchema = mergedSchema.RemoveBuiltInTypes(); VisitMerged(context, mergedSchema); MarkExternalFields(schemaBuilder, mergedSchema); BuildNameLookup(context, schemaBuilder, mergedSchema, allSchemas.Keys); schemaBuilder .AddDocument(mergedSchema) .AddDirectiveType <DelegateDirectiveType>() .AddDirectiveType <ComputedDirectiveType>() .AddDirectiveType <SourceDirectiveType>() .SetTypeResolver(IsOfTypeFallback); }
public static ISchemaBuilder AddDocument( this ISchemaBuilder builder, DocumentNode document) { if (builder is null) { throw new ArgumentNullException(nameof(builder)); } if (document is null) { throw new ArgumentNullException(nameof(document)); } return(builder.AddDocument(sp => document)); }
public static ISchemaBuilder AddDocumentFromString( this ISchemaBuilder builder, string schema) { if (builder is null) { throw new ArgumentNullException(nameof(builder)); } if (string.IsNullOrEmpty(schema)) { throw new ArgumentException( TypeResources.SchemaBuilderExtensions_SchemaIsEmpty, nameof(schema)); } return(builder.AddDocument(sp => Utf8GraphQLParser.Parse(schema))); }
public static ISchemaBuilder AddDocumentFromFile( this ISchemaBuilder builder, string filePath) { if (builder is null) { throw new ArgumentNullException(nameof(builder)); } if (string.IsNullOrEmpty(filePath)) { throw new ArgumentException( "", nameof(filePath)); } return(builder.AddDocument(sp => Utf8GraphQLParser.Parse( File.ReadAllBytes(filePath)))); }