public void AddType(GraphType type, TypeCollectionContext context) { if (type == null) { return; } var name = type.CollectTypes(context); _types[name] = type; type.Fields.Apply(field => { AddTypeIfNotRegistered(field.Type, context); if (field.Arguments != null) { field.Arguments.Apply(arg => { AddTypeIfNotRegistered(arg.Type, context); }); } }); if (type is ObjectGraphType) { var obj = (ObjectGraphType)type; obj.Interfaces.Apply(objectInterface => { AddTypeIfNotRegistered(objectInterface, context); }); } }
public void AddType(GraphType type, TypeCollectionContext context) { if (type == null) { return; } var name = type.CollectTypes(context); _types[name] = type; type.Fields.Apply(field => { var foundType = this[field.Type]; if (foundType == null) { AddType(context.ResolveType(field.Type), context); } }); if (type is ObjectGraphType) { var obj = (ObjectGraphType)type; obj.Interfaces.Apply(objectInterface => { var foundType = this[objectInterface]; if (foundType == null) { AddType(context.ResolveType(objectInterface), context); } }); } }
public void AddType(GraphType type, TypeCollectionContext context) { if (type == null) { return; } var name = type.CollectTypes(context); _types[name] = type; type.Fields.Apply(field => { AddTypeIfNotRegistered(field.Type, context); field.Arguments?.Apply(arg => { AddTypeIfNotRegistered(arg.Type, context); }); }); if (type is ObjectGraphType) { var obj = (ObjectGraphType)type; obj.Interfaces.Apply(objectInterface => { AddTypeIfNotRegistered(objectInterface, context); var interfaceInstance = this[objectInterface] as InterfaceGraphType; if (interfaceInstance != null) { interfaceInstance.AddPossibleType(obj); if (interfaceInstance.ResolveType == null && obj.IsTypeOf == null) { throw new ExecutionError(( "Interface type {0} does not provide a \"resolveType\" function " + "and possible Type \"{1}\" does not provide a \"isTypeOf\" function. " + "There is no way to resolve this possible type during execution.") .ToFormat(interfaceInstance, obj)); } } }); } if (type is UnionGraphType) { var union = (UnionGraphType)type; if (!union.Types.Any()) { throw new ExecutionError("Must provide types for Union {0}.".ToFormat(union)); } union.Types.Apply(unionedType => { AddTypeIfNotRegistered(unionedType, context); var objType = this[unionedType] as ObjectGraphType; if (union.ResolveType == null && objType != null && objType.IsTypeOf == null) { throw new ExecutionError(( "Union type {0} does not provide a \"resolveType\" function" + "and possible Type \"{1}\" does not provide a \"isTypeOf\" function. " + "There is no way to resolve this possible type during execution.") .ToFormat(union, objType)); } union.AddPossibleType(objType); }); } }