-
Notifications
You must be signed in to change notification settings - Fork 726
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
ID as a custom scalar #3379
ID as a custom scalar #3379
Comments
Hey @TizianoCoroneo! I thought I was going to have to say no to this request (because ID is reserved as a specific type in the GraphQL Spec), but after reviewing the spec, it just says that ID must be serialized to a @calvincestari @BobaFetters do you see any reason why we shouldn't allow this? If you want to make a PR for this, I think we can accept it! |
We can't allow complete customization of the type since it will still need to be bound by the serializable-to-string requirement in the GraphQL spec. I don't know exactly how this would work yet but it'd need to conform to Happy to work with you in figuring this out though @TizianoCoroneo. |
I'm not sure how much that matters? Client devs are going to implement their custom scalars to consume the scalar specified by their schema. If your schema is trying to use the
I'm not sure if any of these are relevant. Maybe I'm missing something, but if so, I think we need to be more clear on what specifically would go wrong with this. I can't actually come up with a situation in which this would be problematic. @TizianoCoroneo, we aren't going to allocate time to implement this ourselves in the near future, but if it's something you want, please go ahead and try it out. If you get it working in your project and that doesn't reveal any problems that we had missed, we'll do a little more thinking and investigation, but I'm hoping it should be mergeable. |
Implemented in #363. Should be included in next release! |
Hey 👋 |
Do you have any feedback for the maintainers? Please tell us by taking a one-minute survey. Your responses will help us understand Apollo iOS usage and allow us to serve you better. |
Use case
I'd like to be able to customize the backing type of the
ID
of the codegen-generated models.In our API we have IDs that are encoded representations of other things (can't go in too much details), so I would like to have my own custom
String
-wrapper type with additional functionality, instead of the mandatedString
as the type behind theID
typealias. Today I have to extendString
, polluting the namespace instead.Example: the
SchemaMetadata.graphl.swift
contains this code:Describe the solution you'd like
It would be nice to have it as another custom scalar instead:
The text was updated successfully, but these errors were encountered: