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

there are no resolvers generated for input #1948

Closed
FanFani4 opened this issue Feb 5, 2022 · 12 comments · Fixed by #1950
Closed

there are no resolvers generated for input #1948

FanFani4 opened this issue Feb 5, 2022 · 12 comments · Fixed by #1950

Comments

@FanFani4
Copy link
Contributor

FanFani4 commented Feb 5, 2022

What happened?

not generating resolvers for input types ( even with force resolver from gqlgen.yml or @GoModel directive )

What did you expect?

same behavior as for types

Minimal graphql.schema and models to reproduce

https://github.com/FanFani4/gqlgen-input-bug

versions

  • gqlgen version?
  • v0.14.0-dev
  • go version?
  • go version go1.17.6 linux/amd64
  • dep or go modules?
  • modules

related issues and discussions

#1307
#1823

@FanFani4
Copy link
Contributor Author

FanFani4 commented Feb 6, 2022

created a PR for this issue , can you accept it pls?

#1950

@Omkarz7
Copy link

Omkarz7 commented Feb 7, 2022

Hey @FanFani4, I am facing the same issue as you. This has led to the following issue in my project
cannot use resolver (variable of type *graph.Resolver) as generated.ResolverRoot value in struct literal: missing method TestInput
This has forced me to use Int as id datatype. I am sure not everyone can use this hack.
I hoping your fix will resolve this issue once merged.

@frederikhors
Copy link
Collaborator

This is very strange. @FanFani4 I can suppose the problem is:

autobind:
  - "github.com/FanFani4/gqlgen-input-bug/domain"

Can you please try to generate without these lines?

@FanFani4
Copy link
Contributor Author

FanFani4 commented Feb 8, 2022

hi @frederikhors , without binding models it is generating everything fine in graph/model/model_gen.go -
my point is that if i bind a type - gqlgen is generating a resolver for it in {name}.resolvers.go if it is different from schema but for input it is not.

this can be reproduced with autobind and manual binding

@FanFani4
Copy link
Contributor Author

FanFani4 commented Feb 8, 2022

@Omkarz7 thx, but it is not only about enums , i changed github.com/FanFani4/gqlgen-input-bug TestInput.role in schema to string and in model to float and the behavior is exactly the same

@FanFani4
Copy link
Contributor Author

FanFani4 commented Feb 8, 2022

plugin/resolvergen/resolver.go

resolvergen is iterating only through objects only , i added inputs to be iterated as well and resolvers for inputs was generated fine

@Omkarz7
Copy link

Omkarz7 commented Feb 8, 2022

@FanFani4 I am not talking about enums, I am talking about TestInput.id, change it to Int and check if that works

input TestInput { id: Int! # change from string to int role: String! }

I got around the issue by accepting id as different parameter in the mutation like this:
type Mutation { foo(id: ID!, in: TestInput!): TestType! }

And now I am wondering that we might be talking about two different issues.

@FanFani4
Copy link
Contributor Author

FanFani4 commented Feb 8, 2022

talking about two different issues

yes, i am talking about the case when fields of an input have different types in schema and binded model

@FanFani4
Copy link
Contributor Author

hi @frederikhors, any news on this issue ?

@frederikhors
Copy link
Collaborator

Please don't ask for ETA.

@mojtabacazi
Copy link

@FanFani4 is this related to #1868 ?

@FanFani4
Copy link
Contributor Author

hi @mojtabacazi , yes it is. you can try to add this line in your go.mod and try to regenerate the code. just don't forget to remove it when its fixed

replace github.com/99designs/gqlgen => github.com/FanFani4/gqlgen v0.16.1-0.20220206105048-15f5c9278130

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.

4 participants