/// <summary> /// Returns a <see cref="FieldType"/> for the specified AST <see cref="Field"/> within a specified parent /// output graph type within a given schema. For meta-fields, returns the proper meta-field field type. /// </summary> public static FieldType GetFieldDefinition(ISchema schema, IObjectGraphType parentType, Field field) { if (field.Name == schema.SchemaMetaFieldType.Name && schema.Query == parentType) { return(schema.SchemaMetaFieldType); } if (field.Name == schema.TypeMetaFieldType.Name && schema.Query == parentType) { return(schema.TypeMetaFieldType); } if (field.Name == schema.TypeNameMetaFieldType.Name) { return(schema.TypeNameMetaFieldType); } if (parentType == null) { throw new ArgumentNullException(nameof(parentType), $"Schema is not configured correctly to fetch field '{field.Name}'. Are you missing a root type?"); } return(parentType.GetField(field.Name)); }
public static FieldType GetFieldDefinition(Document document, ISchema schema, IObjectGraphType parentType, Field field) { if (field.Name == SchemaIntrospection.SchemaMeta.Name && schema.Query == parentType) { return(SchemaIntrospection.SchemaMeta); } if (field.Name == SchemaIntrospection.TypeMeta.Name && schema.Query == parentType) { return(SchemaIntrospection.TypeMeta); } if (field.Name == SchemaIntrospection.TypeNameMeta.Name) { return(SchemaIntrospection.TypeNameMeta); } if (parentType == null) { var error = new ExecutionError($"Schema is not configured correctly to fetch {field.Name}. Are you missing a root type?"); error.AddLocation(field, document); throw error; } return(parentType.GetField(field.Name)); }