Gqlgen: `[String]` returns `[]` on nil instead of `null`

Created on 20 Feb 2019  路  2Comments  路  Source: 99designs/gqlgen

Expected Behaviour

Given this type:

type Test {
  test1: [String]
  test2: [String!]
  test3: [String]!
  test4: [String!]!
}

I'd expect returning nil in each resolver to produce:

{
  "data": {
    "test": {
      "test1": null,
      "test2": null,
      "test3": [],
      "test4": []
    }
  }
}

Actual Behavior

This is what's returned instead:

{
  "data": {
    "test": {
      "test1": [],
      "test2": [],
      "test3": [],
      "test4": []
    }
  }
}

https://github.com/facebook/graphql/issues/171 for context.

Is this an error or by design? Thanks in advance.

bug v0.8.2

All 2 comments

Looks like a bug. Go treats nils like empty arrays so it would be an easy one to make.

Same problem here! Any update about it? :disappointed:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

andrewmunro picture andrewmunro  路  4Comments

RobertoOrtis picture RobertoOrtis  路  3Comments

itsbalamurali picture itsbalamurali  路  4Comments

steebchen picture steebchen  路  3Comments

sumanthakannantha picture sumanthakannantha  路  3Comments