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

Add support for interfaces, part 3: automatically add __typename #56

Merged
merged 1 commit into from
Aug 25, 2021

Conversation

benjaminjkraft
Copy link
Collaborator

@benjaminjkraft benjaminjkraft commented Aug 23, 2021

Summary:

In #52, I added support for interface types, but with the simplifying
restriction (among others) that the user must request the field
__typename. In this commit, I remove this restriction.

The basic idea is simple: we preprocess the query to add __typename.
The implementation isn't much more complicated! Although it required
some new wiring in a few places.

Issue: #8

Test plan:

make check

@benjaminjkraft benjaminjkraft self-assigned this Aug 23, 2021
@benjaminjkraft benjaminjkraft changed the title Automatically add __typename to fields of interface type Add support for interfaces, part 3: automatically add __typename Aug 23, 2021
Copy link
Contributor

@dnerdy dnerdy left a comment

Choose a reason for hiding this comment

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

This looks great! It's nice to have the genqlient automatically request __typename.

One very minor issue I can foresee is if an object already has a field named typename. Then the names would conflict. Perhaps this means the __typename field will need to be made configurable at some point.

@benjaminjkraft
Copy link
Collaborator Author

benjaminjkraft commented Aug 24, 2021

Ah, good point. I'll just make a separate issue for that (edit: #60); there are some other potential conflicts.

@benjaminjkraft benjaminjkraft changed the base branch from benkraft.interfaces-2 to main August 25, 2021 18:57
In #52, I added support for interface types, but with the simplifying
restriction (among others) that the user must request the field
`__typename`.  In this commit, I remove this restriction.

The basic idea is simple: we preprocess the query to add `__typename`.
The implementation isn't much more complicated!  Although it required
some new wiring in a few places.

Issue: #8

Test plan: make tesc

Reviewers: marksandstrom, adam, miguel
@benjaminjkraft benjaminjkraft merged commit 65f9e90 into main Aug 25, 2021
@benjaminjkraft benjaminjkraft deleted the benkraft.interfaces-3 branch August 25, 2021 19:12
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.

2 participants