Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

How to trigger resolver generation on parameterized field #1466

Closed
AlexandreBossard opened this issue Feb 15, 2021 · 3 comments
Closed

How to trigger resolver generation on parameterized field #1466

AlexandreBossard opened this issue Feb 15, 2021 · 3 comments

Comments

@AlexandreBossard
Copy link

What happened?

the following schema:

type TimeScope {
    ID: ID!
    name: String
}
type App{
    ID: ID!
    name: String
    time_range(start: String!, stop: String!): [TimeScope!]!
}
type Query{
    App(appId: ID): App!
}
schema{
    query: Query
}

does not generate a resolver for time_range by default. How am i supposed to access the start and stop parameters ?
I like my model to be generated, even if I know i can force the resolver generation through a graphql directive or the qglgen.yml it is quite cumbersome when you have a few of them.

What did you expect?

The resolver to be generated by default on each parameterized graphql field. Or one line of configuration to do that.

BTW: the yaml configuration is not documented anymore on the website, seems to have been moved away with the FAQ

versions

  • gqlgen version 0.13.0
  • go version 1.15.7
@AlexandreBossard AlexandreBossard changed the title How to get generator on paremeter filed How to trigger generator generation on parameterized field Feb 15, 2021
@AlexandreBossard AlexandreBossard changed the title How to trigger generator generation on parameterized field How to trigger resolver generation on parameterized field Feb 15, 2021
@hsblhsn
Copy link
Contributor

hsblhsn commented Aug 13, 2021

Hey, did you solve it somehow?

@edigaryev
Copy link
Contributor

Perhaps you could try the just merged #1725 if it helps with your case.

Otherwise it's not quite clear what your environment is, e.g. there's no gqlgen.yml. A minimal example hosted as a GitHub repository would be helpful in reproducing this.

@peteole
Copy link

peteole commented Nov 23, 2021

Actually I found a fix to this: You can edit the generated App go struct (by moving it into a separate file) and remove the "time_range" field. When you run the generate command again, a getter method will be generated for the tim_range field which gets passed the correct arguments.
Anyways this behavior is somewhat unexpected since parameterized fields can never be represented by a field of a struct, but must have a getter method. Maybe it makes sense to leave out all parameterized fields from the structs by default and generate getter methods instead?
Or is this what #1725 does?

@frederikhors frederikhors converted this issue into discussion #1934 Feb 4, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants