Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null input for slice should convert to nil rather than a empty slice #1203

Closed
NateScarlet opened this issue Jun 2, 2020 · 1 comment
Closed

Comments

@NateScarlet
Copy link

What happened?

gqlgen always make a slice if field is set, even it set to null.

res := make([]{{$type.GO.Elem | ref}}, len(vSlice))
for i := range vSlice {
res[i], err = ec.{{ $type.Elem.UnmarshalFunc }}(ctx, vSlice[i])
if err != nil {
return nil, err
}
}
return res, nil

#1023 mentioned this as a question, but i believe this is a bug.

What did you expect?

got nil for fields that set to null.

Minimal graphql.schema and models to reproduce

type Item {
  name: String!
}

type Query{
   items(name: [String!]): [Item!]
}
query {
  items(name: null) {
    name  
  }
}

versions

  • gqlgen version? v0.11.3
  • go version? 1.14
  • dep or go modules? go modules
NateScarlet added a commit to NateScarlet/gqlgen that referenced this issue Jun 2, 2020
NateScarlet added a commit to NateScarlet/gqlgen that referenced this issue Jun 2, 2020
…than a empty slice

not change IsNilable because other tests will fail if we do
@lwc
Copy link
Member

lwc commented Jul 10, 2020

Fixed via: #1242

@lwc lwc closed this as completed Jul 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants