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(graphql): override nodetype tostrings for display #856

Merged
merged 4 commits into from
Mar 11, 2022

Conversation

andrewazores
Copy link
Member

@andrewazores andrewazores commented Mar 11, 2022

Fixes #853

I found this simple workaround for the way that GraphQL treats enum values. Rather than creating some duplication within our internal GraphQL module that re-encodes all of the NodeType enums to their Kind strings, I simply add an override on the toString() method for all of the NodeType implementations that simply returns the Kind. GraphQL uses toString() to serialize the nodeType enum field, which displays the enum member's name by default, so this override is simple and effective and doesn't duplicate definitions.

To test:
Query http :8181/api/beta/graphql query=@graphql/root-node-query.graphql
Query http :8181/api/v2.1/discovery

Compare the results of the kind/nodeType fields of nodes, before and after this patch. Before you should see ex. REALM/Realm, whereas after they will both agree on Realm.

Copy link
Contributor

@hareetd hareetd left a comment

Choose a reason for hiding this comment

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

Looks good!

@andrewazores andrewazores merged commit 0a609ac into cryostatio:main Mar 11, 2022
@andrewazores andrewazores deleted the discovery-node-kind branch March 11, 2022 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GraphQL and Discovery API disagree on nodes' names
2 participants