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

Fix Having Pointers to Union Types #633

Merged
merged 2 commits into from
Mar 18, 2019
Merged

Fix Having Pointers to Union Types #633

merged 2 commits into from
Mar 18, 2019

Conversation

mathewbyrne
Copy link
Contributor

Fixes #594

Adds unions to the list of things that aren't turned into pointers based on the schema. I also rewrote CopyModifiersFromAst to make it a bit simpler to use.

}

if !t.NonNull && usePtr {
def := b.schema.Types[t.Name()]
usePtr := def.Kind != ast.Interface && def.Kind != ast.Union
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vektah this potentially changes the logic a little bit here, since usePtr is recalculated at each recursion, but I think it's maybe more technically correct? Nothing unexpected seemed to shift after codegen.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 I think its effectively the same thing.

Mathew Byrne added 2 commits March 18, 2019 14:48
This is probably a more correct way to check whether we should wrap the
type in a pointer or not, rather than looking at the GrapQL definition.
There may be use-cases where a GraphQL interface/union might be mapped
to a Go stuct.
@mathewbyrne mathewbyrne merged commit fc05501 into master Mar 18, 2019
@vektah vektah deleted the fix-union-pointers branch March 18, 2019 06:10
cgxxv pushed a commit to cgxxv/gqlgen that referenced this pull request Mar 25, 2022
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 this pull request may close these issues.

None yet

2 participants