Comments (17)
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.
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.
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.
@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.
This issue is affecting me as well.
from gqlgen.
same issue here
from gqlgen.
Same problem. Need to do something
from gqlgen.
@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.
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.
Also, now that the PR has been merged, this issue can be closed. Cc @StevenACoffman
from gqlgen.
@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.
And maybe this issue shouldn't be closed since it is apparently not solved for @matoszz, who opened the issue.
from gqlgen.
@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.
@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)
- Option to use json.Number when unmarshalling dynamically typed scalars
- generate cannot resolve custom slice type HOT 1
- Is it possible to disable/redirect gqlgen's log output (e.g. while running unit tests)?
- Allow infrastructural input validation
- How do I pass values from Directive to Resolver through context? HOT 3
- ResolverImplementer has a break change that the implementor can't know a field status. HOT 3
- [Proposal] Resolve the schema location from where the config file live instead of the current working dir
- [Proposal] Add defer for field resolvers HOT 1
- Unrecognized import path for sourcegraph/appdash-data HOT 7
- What is the best way to pass variables between query and response object field resolver ?
- unrecognized import path "sourcegraph.com/sourcegraph/appdash-data": reading https://sourcegraph.com/sourcegraph/appdash-data?go-get=***: 404 Not Found HOT 9
- Mutation resolver code generation
- Code generation broken for federated multi-key, multi-entity types HOT 1
- [Bug] Altair introspect query error
- Use go.work and workspaces
- Pass error code in Websocket InitFunc
- @policy directive is not recognized while loading the schema to generate code HOT 2
- Resource exhaustion when handling of crafted queries
- [Proposal] Support embeding via extraFields attribute
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gqlgen.