-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[Post!]!
becomes []*Post
not []Post
in 0.9.0
#715
Comments
This was intentional, see #710 It makes gqlgen more consistent with other codegen tools like prisma and protobuffer and generally reduces boilerplate. See also #375 (comment) |
Ahh, I didn't see #375. Alright. This requires a huge refactor for us, but I'll live. Thanks. |
I've discussed this in the Gitter and plan to make a PR about making this specific instance of pointer-slices being used instead of struct-value-slices a configuration choice. |
Seems this would add considerable complexity, without much upside. What's the rationale? |
I've used gqlgen since 0.5, and while the refactor for 0.8 was mostly done by search-replace and about 1 block of boilerplate per model, refactoring only the resolvers for this one would mean a lot of loops to convert between. I can understand the rationale for pointers to single structs due to compilation errors, but struct-of-slice-pointers seems to be a choice mentioned in a single comment and then accepted. I'll post the PR and let you review it. If the added complexity isn't worth it, feel free to reject it. |
Yeah me too, seems kind of complicated to solve this. |
this break the spec of graphql, which define the syntax of "!", what the plan or what this tool will be. |
This is an intentional change in 0.9 and brings slices in line with regular struct resolvers. Further discussion in #719
I'm not sure what you mean here. This issue is about the return type from a resolver, and has no bearing on the GraphQL spec. |
@vektah I am using Prisma and the methods always return a slice of structs, not pointers, so I have to retype it every time, or am I doing something wrong? My issue: (#738) |
What happened?
Generate is turning the following schema:
into:
What did you expect?
I expected the following generated types, which has been the case with previous versions:
That is, I expected
[Post!]!
to become[]Post
not[]*Post
. I cannot tell whether this is intentional, based on #710 and #711, or not.Minimal graphql.schema and models to reproduce
See above.
versions
gqlgen version
? 0.9.0go version
? 1.12.0The text was updated successfully, but these errors were encountered: