99designs / 99designs/gqlgen

Introspection "field" results don't follow GraphQL spec

Aperta
#1,867 2 commenti 1 reazione 0 assegnatari Vedi su GitHub
Lingua principale
Go
Stelle
10.8k
Fork
1.3k
Merge medio
2g 36m
PR unite (30g)
26

Descrizione

### What happened?

When running an introspection query against a GraphQL schema implemented with gqlgen, I receive the following (snippet of the full response):

```
...
{
"description": "An enum that represents the various recipe statuses.",
"enumValues": [
...
],
"fields": [],
"inputFields": [],
"interfaces": [],
"kind": "ENUM",
"name": "RecipeStatusType",
"possibleTypes": []
},
{
"kind": "SCALAR",
"name": "SemVer",
"description": "A version designation conforming to the SemVer specification.",
"fields": [],
"inputFields": [],
"interfaces": [],
"enumValues": [],
"possibleTypes": []
}
```

### What did you expect?

Per the [GraphQL spec](https://spec.graphql.org/October2021/#sec-Schema-Introspection.Schema-Introspection-Schema), I expect `"fields"` to be `null` for all types except OBJECT and iNTERFACE, from this documentation:

```
# must be non-null for OBJECT and INTERFACE, otherwise null.
fields(includeDeprecated: Boolean = false): [__Field!]
```

Ie, I'd expect any OBJECT or INTERFACE to have `"fields": []` but other types to return `"fields": null`. The spec behavior is what I've seen with other GraphQL APIs.

### Minimal graphql.schema and models to reproduce

```
schema {
query: Query
}

type Query {
cliVersion: SemVer
status: RecipeStatusType
}

enum RecipeStatusType {
AVAILABLE
CANCELED
}

scalar SemVer

```

### versions
- `gqlgen version`? `gqlgen v0.13.0` (I don't see a fix in the changelog after this version, apologies if I've missed it)
- `go version`? `1.16`
- dep or go modules? Go modules

Thanks for your time!

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.