GithubHelp home page GithubHelp logo

Comments (17)

ghjm avatar ghjm commented on June 3, 2024 4

If my PR #2878 is merged (and is included in a release, etc), you will be able to specify a new configuration option omit_root_models: true that will fix this.

from gqlgen.

Yamashou avatar Yamashou commented on June 3, 2024 3

A new version has been released to allow Query and Mutation to not be generated

generate:
  clientV2: true
  clientInterfaceName: "GithubGraphQLClient"
  query: false
  mutation: false

https://github.com/Yamashou/gqlgenc/releases/tag/v0.18.0

Please let me know if this release does not solve the problem.

from gqlgen.

ghjm avatar ghjm commented on June 3, 2024 1

You must be generating different packages for the client and the server. I was trying to avoid this, because I also use the generated structs for internal data handling, and I didn't want to have two different type systems for client-side and server-side representations of identical objects. So for me it is a problem that gqlgen started generating the empty Query and Mutation structs, because they conflict with the same-named structs generated by gqlgenc.

Whatever you're trying to do, it's not the same as what I was trying to do. This PR does solve my problem and I'm now able to upgrade to latest-version gqlgen without problems, as long as I set the configuration flag.

from gqlgen.

ghjm avatar ghjm commented on June 3, 2024 1

@matoszz I followed these instructions from @Yamashou: Yamashou/gqlgenc#111. I don't use the gqlgenc CLI, and therefore, I don't use a gqlgenc.conf - instead I use Go code to run a pass of gqlgen that adds gqlgenc as a plugin. You can see an example of this here: https://github.com/ghjm/connectopus/tree/main/pkg/cpctl.

from gqlgen.

ghjm avatar ghjm commented on June 3, 2024

This issue is affecting me as well.

from gqlgen.

udhaykumarB avatar udhaykumarB commented on June 3, 2024

same issue here

from gqlgen.

skid-rock avatar skid-rock commented on June 3, 2024

Same problem. Need to do something

from gqlgen.

matoszz avatar matoszz commented on June 3, 2024

@ghjm I'm testing gqlgen @ v0.17.43 (with #2878) + omit_root_models: true and gqlgenc @ v0.18.0 and it doesn't seem as though this flag (regardless of it's settings) is getting picked up. I attempted both true/false and noticed that there was no change output when running gqlgen directly (good) but when running gqlgenc it still outputs the base models regardless of the settings I have within gqlgen.yml - any advice? you see this working in-practice yet?

from gqlgen.

ghjm avatar ghjm commented on June 3, 2024

The client generator has always generated these base models. If you want gqlgenc not to output them, that would require a change in https://github.com/Yamashou/gqlgenc, not here. This PR just (optionally) prevents gqlgen from generating them, so that it doesn't conflict with gqlgenc.

from gqlgen.

ghjm avatar ghjm commented on June 3, 2024

Also, now that the PR has been merged, this issue can be closed. Cc @StevenACoffman

from gqlgen.

matoszz avatar matoszz commented on June 3, 2024

@ghjm shouldn't the change of the bool option in the gqlgen.yml actually produce a change in the output when generating? I guess I would have expected when uncommenting out that option in the configuration and running the generate commands that i'd see a diff in output with the option on / off but there's no file changes when doing so.

I originally reported this issue when the version of gqlgen I was trying to pull in started behaving in this way, but it seems as though it's always been erroneously generated by gqlgenc all along (I can bump gqlgenc version and not change gqlgen, generates fine; if i bump the gqlgen version + gqlgenc i get the empty structs)

from gqlgen.

ghjm avatar ghjm commented on June 3, 2024

And maybe this issue shouldn't be closed since it is apparently not solved for @matoszz, who opened the issue.

from gqlgen.

matoszz avatar matoszz commented on June 3, 2024

@ghjm interesting, appreciate the response / feedback - I may be inadvertently generating different packages for the client and server as your description seems like what i'm trying to accomplish as I also use the generated structs for internal data handling. Would you mind sharing your gqlgen + gqlgenc configuration(s)? It'd be helpful for me to see how you're managing these as a single package in practice.

In my gqlgen.yml I have:

schema:
  - schema/*.graphql

exec:
  filename: internal/graphapi/gen_server.go
  package: graphapi

model:
  filename: internal/graphapi/gen_models.go
  package: graphapi

resolver:
  layout: follow-schema
  dir: internal/graphapi
  package: graphapi
  filename_template: "{name}.resolvers.go"

omit_gqlgen_version_in_file_notice: true

autobind:
 - "github.com/datumforge/datum/internal/graphapi"
 - "github.com/datumforge/datum/internal/ent/generated"

and gqlgenc.yml:

schema: ["schema.graphql" ]
query: ["query/*.graphql"]
model:
  package: datumclient
  filename: ./internal/datumclient/models.go
client:
  package: datumclient
  filename: ./internal/datumclient/graphclient.go
generate:
  clientV2: true
  clientInterfaceName: "DatumClient"

is it as simple as making the package names the same and aligning the model file names?

from gqlgen.

matoszz avatar matoszz commented on June 3, 2024

@Yamashou we updated gqlgenc to v.18.0 and tested both of those configuration parameters under generate (with gqlgen v0.17.43), and I believe this is what we needed - ref #495.

Really appreciate the assistance and responsiveness - thank you @ghjm @Yamashou 🙇 ❤️

from gqlgen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.