(w io.Writer, schema *ast.Schema, def *ast.Definition, f *ast.FieldDefinition)
| 154 | } |
| 155 | |
| 156 | func writeGraphQLField(w io.Writer, schema *ast.Schema, def *ast.Definition, f *ast.FieldDefinition) { |
| 157 | input := def.Kind == ast.InputObject |
| 158 | fmt.Fprintf(w, "%s.%s: %s\n", def.Name, f.Name, f.Type.String()) |
| 159 | fmt.Fprintln(w, nullability(f.Type, input)) |
| 160 | writeDescription(w, f.Description) |
| 161 | if d := f.Directives.ForName("deprecated"); d != nil { |
| 162 | reason := "No longer supported" |
| 163 | if arg := d.Arguments.ForName("reason"); arg != nil && arg.Value != nil { |
| 164 | reason = arg.Value.Raw |
| 165 | } |
| 166 | fmt.Fprintf(w, "Deprecated: %s\n", firstLine(reason)) |
| 167 | } |
| 168 | if len(f.Arguments) > 0 { |
| 169 | fmt.Fprintln(w, "Arguments (a type ending in ! is required):") |
| 170 | for _, a := range f.Arguments { |
| 171 | line := fmt.Sprintf(" %s: %s", a.Name, a.Type.String()) |
| 172 | if a.DefaultValue != nil { |
| 173 | line += " = " + a.DefaultValue.String() |
| 174 | } |
| 175 | fmt.Fprintln(w, line) |
| 176 | } |
| 177 | } |
| 178 | if t := schema.Types[f.Type.Name()]; t != nil && t.Kind != ast.Scalar { |
| 179 | fmt.Fprintf(w, "See also: ghmock schema %s\n", t.Name) |
| 180 | } |
| 181 | } |
| 182 | |
| 183 | // nullability says whether a field's value can be null, or for input fields, |
| 184 | // whether the field is required. |
no test coverage detected