private string PrintField(GraphQLFieldInfo field, bool firstInBlock) { var type = field.GetGraphQLType(this.schema.SchemaRepository); return (PrintDescription(field, " ", firstInBlock) + $" {field.Name}{this.PrintArguments(field.Arguments.Values, " ")}: " + $"{type}{PrintDeprecated(field)}"); }
private Result GetValueFromField( ISchemaRepository schemaRepository, GraphQLFieldInfo field, GraphQLObjectField astField) { var graphQLType = schemaRepository.GetSchemaInputTypeFor(field.SystemType); var result = graphQLType.GetFromAst(astField?.Value, schemaRepository); return(result); }
private string PrintInputValue(GraphQLFieldInfo arg) { var argType = arg.GetGraphQLType(this.schema.SchemaRepository) as GraphQLInputType; var argDeclaration = $"{arg.Name}: {argType}"; if (arg.DefaultValue.IsSet) { argDeclaration += $" = {arg.DefaultValue.GetSerialized(argType, this.schema.SchemaRepository)}"; } return(argDeclaration); }
private static string PrintDeprecated(GraphQLFieldInfo type) { var reason = type.DeprecationReason; if (reason == null) { return(string.Empty); } if (reason == string.Empty || reason == "No longer supported") { return(" @deprecated"); } return($" @deprecated(reason: \"{reason}\")"); }
private void CheckFieldArgument(GraphQLArgument node, GraphQLFieldInfo fieldInfo, string argumentName) { if (!fieldInfo.Arguments.ContainsKey(argumentName)) { var parentType = this.GetParentType(); var errorMessage = this.ComposeUnknownArgumentMessage( argumentName, fieldInfo.Name, parentType, StringUtils.SuggestionList(argumentName, fieldInfo.Arguments.Select(e => e.Value.Name))); this.Errors.Add(new GraphQLException(errorMessage, new[] { node })); } }
private void ValidateArgument( GraphQLFieldSelection node, GraphQLObjectTypeArgumentInfo argument, GraphQLFieldInfo field, IEnumerable <GraphQLArgument> providedArguments) { var providedArgument = providedArguments.FirstOrDefault(e => e.Name.Value == argument.Name); var argumentType = argument.GetGraphQLType(this.SchemaRepository); if (providedArgument == null && argumentType is GraphQLNonNull) { this.Errors.Add( new GraphQLException( $"Field \"{field.Name}\" argument \"{argument.Name}\" of type \"{argumentType}\" is required but not provided.", new[] { node })); } }
private List <GraphQLArgument> GetArgumentsFromSelection(GraphQLFieldSelection selection, GraphQLFieldInfo fieldInfo) { if (fieldInfo == null || fieldInfo.Arguments?.Count == 0) { return(null); } return(this.MergeArgumentsWithDefault(selection.Arguments, fieldInfo.Arguments)); }
private static string PrintDescription(GraphQLFieldInfo field, string indentation = "", bool firstInBlock = true) { return(PrintDescription(field.Description, indentation, firstInBlock)); }