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 graphql reflect tag #596

Merged
merged 4 commits into from
Feb 28, 2023
Merged

Add graphql reflect tag #596

merged 4 commits into from
Feb 28, 2023

Conversation

pavelnikolov
Copy link
Member

@pavelnikolov pavelnikolov commented Feb 27, 2023

This PR allows fields to have a graphql reflect tag in order to override the name of the field they resolve. This in turn would allow for field resolvers which are case-sensitive. Currently the library matches fields using case-insensitive matching and the _ char is insignificant. This violates the official GraphQL spec which states that names should be case-sensitive and the _ is significant.

With this change, similar to the json reflect tag, users can set a graphql tag in order to override the name. For example:

type resolver struct {
    Hello string `graphql:"hello"`
}

or

type resolver struct {
    Greeting string `graphql:"hello"`
}

The above would allow the users to override the name and use a case-sensitive matching. Both of the above resolvers would resolve a schema like this:

type Query {
    hello: String!
}

fixes: #593

@pavelnikolov pavelnikolov added this to the v1.6.0 milestone Feb 27, 2023
@pavelnikolov pavelnikolov self-assigned this Feb 27, 2023
@pavelnikolov pavelnikolov merged commit f05ace9 into master Feb 28, 2023
@pavelnikolov pavelnikolov deleted the add-graphql-reflect-tag branch February 28, 2023 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow field names starting with a leading _
1 participant