-
Notifications
You must be signed in to change notification settings - Fork 1.4k
node and nodes scalar type configuration #5381
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
base: master
Are you sure you want to change the base?
Conversation
@rmosolgo I wanted to throw this proof of concept together quickly to get your thoughts 🙏 I'm open to any changes you suggest, or whatever you feel makes sense! |
Hmm after looking closer at this, maybe the configuration of the |
I'm open to accepting a customization here, but I don't want a global configuration object. Lots of applications run multiple schemas and I want to make sure that they can be configured separately. Here are a few other APIs I could imagine:
I'm definitely game to support something like this -- is there one of of those alternatives (or another non-global one) that you'd like to explore? |
I like Approach
will work so it won't be a breaking change. I'd still need to inject it here into the
Do you have suggestions for that too? 🙏 |
PR Description
This PR makes it possible to configure the
node
andnodes
scalar type through theConfiguration
class.For example, you could do this in a Rails initializer:
And the arguments to
node
andnodes
would beid: SomeScalar!
andids: [SomeScalar!]!
respectively. The returnedid
field would beid: SomeScalar!
.Why is this needed?
We don't use the GraphQL Ruby
ID
scalar and instead use our own scalar for ID fields. Maybe we should consider going back to theID
scalar, but that's a different discussion/concern for if we ever want to go back in that direction 😄 This PR makes it possible to use our own scalar for the rootnode
andnodes
field.GraphQL Ruby doesn't support this type of configuration?
I ultimately need to be able to set the scalar type at Ruby load time. Here for example:
And setting this in a configuration class was the easiest way for me to do this through a simple Rails initializer. I realize this isn't a pattern that GraphQL Ruby takes for configuration (unless I missed it!) and I'm open to any other approaches!
Other approaches we considered
I realize I could also completely override the modules, but it felt much better to be able to configure/inject the type and save us from awkward monkey patching.