private void MergeTypes( ISchemaMergeContext context, ISet <string> typeNames, IEnumerable <ISchemaInfo> schemas, MergeTypeRuleDelegate merge) { var types = new List <ITypeInfo>(); foreach (string typeName in typeNames) { SetTypes(typeName, schemas, types); merge(context, types); } }
public DocumentNode Merge() { MergeTypeRuleDelegate merge = CompileMergeDelegate(); IReadOnlyList <ISchemaInfo> schemas = CreateSchemaInfos(); var context = new SchemaMergeContext(); // merge root types MergeRootType(context, OperationType.Query, schemas, merge); MergeRootType(context, OperationType.Mutation, schemas, merge); MergeRootType(context, OperationType.Subscription, schemas, merge); // merge all other types MergeTypes(context, CreateNameSet(schemas), schemas, merge); return(RewriteTypeReferences(schemas, context.CreateSchema())); }
private static void MergeRootType( ISchemaMergeContext context, OperationType operation, IEnumerable <ISchemaInfo> schemas, MergeTypeRuleDelegate merge) { var types = new List <TypeInfo>(); foreach (ISchemaInfo schema in schemas) { ObjectTypeDefinitionNode rootType = schema.GetRootType(operation); if (rootType is not null) { types.Add(new ObjectTypeInfo(rootType, schema)); } } if (types.Count > 0) { merge(context, types); } }
private MergeTypeRuleDelegate CompileMergeTypeDelegate() { MergeTypeRuleDelegate current = (c, t) => { if (t.Count > 0) { throw new NotSupportedException( "The type definitions could not be handled."); } }; var handlers = new List <MergeTypeRuleFactory>(); handlers.AddRange(_mergeRules); handlers.AddRange(_defaultMergeRules); for (int i = handlers.Count - 1; i >= 0; i--) { current = handlers[i].Invoke(current); } return(current); }
public ScalarTypeMergeHandler(MergeTypeRuleDelegate next) { _next = next ?? throw new ArgumentNullException(nameof(next)); }
public InputObjectTypeMergeHandler(MergeTypeRuleDelegate next) : base(next) { }
public CustomTypeMergeHandler(MergeTypeRuleDelegate next) { }
protected TypeMergeHanlderBase(MergeTypeRuleDelegate next) { _next = next ?? throw new ArgumentNullException(nameof(next)); }
public InterfaceTypeMergeHandler(MergeTypeRuleDelegate next) : base(next) { }
public MergeTypesHandler(MergeTypeRuleDelegate next) => _next = next;