-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Feature: Allow overriding built-in scalar types #917
Comments
Had also similar requirements in quite a few places (but most importantly with IDs, which we represent internally as UUIDs). Though I implemented it with scalar aliases. Just replacing a built-in scalar can be quite limiting since the schema can have different types of IDs |
This is pretty interesting. I think providing custom scalar types with the same name as the built-in types might break some core assumptions in the codebase that check for these built-ins. If taking that approach, look out for this. Allowing custom serialization behavior for these types could be pretty sweet. I would love to see a PR which added this in a nice way. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I have another use-case that would greatly benefit from this. I want to override the serialization/deserialization of the String type to convert all Windows-style line endings to Unix-style for incoming/outgoing data. Some of my clients use Windows machines and some use Unix, and my database also has both style of line endings. Overriding the String serialization/deserialization is a single point of change instead of all the different places I would need to add code to strip carriage returns. Is there any plan to add this feature to an upcoming release? |
The problem here is that introspection depends on built-in scalars. |
any workaround? casting and validation for ID? |
Specifically, sometimes we want to replace
ID
with something like this that can handle Mongo ObjectIDs: https://github.com/tmeasday/create-graphql-server/blob/79abbd67f4aef3b44fb8605e41eb2ba7978810a6/skel/resolvers/index.js#L8I think it could be as simple as just allowing the schema to take a type called
ID
and just using that instead of the built-in.The text was updated successfully, but these errors were encountered: