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

Generated array field unmarshalling handles errors incorrectly for input types #487

Closed
trotterdylan opened this issue Jan 3, 2019 · 1 comment
Labels
bug Something isn't working v0.8 For release in v0.8

Comments

@trotterdylan
Copy link

Expected Behaviour

If any element in an array field fails to unmarshal in an input type, it should be reported to clients as an error.

Actual Behavior

If an error occurs unmarshalling any of the array elements but the last, the error is ignored.

Minimal graphql.schema and models to reproduce

input Foo {
    dateAnswers: [Date!]
}

And the generated code:

			it.DateAnswers = make([]model.Date, len(rawIf1))
			for idx1 := range rawIf1 {
				err = (&it.DateAnswers[idx1]).UnmarshalGQL(rawIf1[idx1])
			}
			if err != nil {
				return it, err
			}

The error check should be inside the loop, not done at the end.

@vektah vektah added the bug Something isn't working label Jan 8, 2019
vektah added a commit that referenced this issue Feb 7, 2019
@vektah
Copy link
Collaborator

vektah commented Feb 7, 2019

Looks like this has already been fixed on next.

@vektah vektah closed this as completed Feb 7, 2019
@vektah vektah added the v0.8 For release in v0.8 label Feb 7, 2019
vektah added a commit that referenced this issue Feb 7, 2019
cgxxv pushed a commit to cgxxv/gqlgen that referenced this issue Mar 25, 2022
cgxxv pushed a commit to cgxxv/gqlgen that referenced this issue Mar 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working v0.8 For release in v0.8
Projects
None yet
Development

No branches or pull requests

2 participants