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

validate method return types #193

Merged
merged 1 commit into from
Jul 14, 2018
Merged

validate method return types #193

merged 1 commit into from
Jul 14, 2018

Conversation

vektah
Copy link
Collaborator

@vektah vektah commented Jul 14, 2018

Wow, this was bigger than I thought it would be.

Fixes a few type validation bugs when binding, and now returns proper error messages if binding fails for input types (its not possible to fall back to a resolver for inputs)

eg:

Unable to bind RecursiveInputSlice.self to github.com/vektah/gqlgen/codegen/testdata.RecursiveInputSlice
  no method named self
  field has wrong type: []github.com/vektah/gqlgen/codegen/testdata.RecursiveInputSlice is not compatible with *[]*github.com/vektah/gqlgen/codegen/testdata.RecursiveInputSlice
exec plan failed

These error messages can be shown for object types too, but they aren't errors because resolvers will be generated. If you run with gqlgen -v you will see why resolvers are being generated
eg:

example/scalars$ gqlgen -v
Unable to bind User.primitiveResolver to github.com/vektah/gqlgen/example/scalars/model.User
  no method named primitiveResolver
  no field named primitiveResolver
  Adding resolver method
Unable to bind User.customResolver to github.com/vektah/gqlgen/example/scalars/model.User
  no method named customResolver
  no field named customResolver
  Adding resolver method
example/scalars$ echo $?
0

Without the -v there will be no output.

fixes #162

@vektah vektah merged commit eb44925 into master Jul 14, 2018
@vektah vektah deleted the validate-method-returns branch July 14, 2018 06:46
cgxxv pushed a commit to cgxxv/gqlgen that referenced this pull request Mar 25, 2022
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 this pull request may close these issues.

BUG: Generate doesn't produce resolver when matched method name doesn't match return type
1 participant