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

Support for custom scalars #9

Closed
ahanoff opened this issue Oct 26, 2022 · 8 comments · Fixed by #10
Closed

Support for custom scalars #9

ahanoff opened this issue Oct 26, 2022 · 8 comments · Fixed by #10

Comments

@ahanoff
Copy link

ahanoff commented Oct 26, 2022

GraphQL.g.cs(6110, 36): [CS0246] The type or namespace name 'ObjectId' could not be found (are you missing a using directive or an assembly reference?)

in schema it looks like:

scalar ObjectId

Does it support custom scalars? I've generated client from schema that uses Mongo ObjectId, and got this error

@byme8
Copy link
Owner

byme8 commented Oct 27, 2022

At the moment, there is not support for custom scalar types. I will have a look at it.

@ahanoff
Copy link
Author

ahanoff commented Oct 28, 2022

https://chillicream.com/docs/strawberryshake/scalars/#custom-scalars
By default, all custom scalars are treated like the String scalar. This means, that the client expects a string value and will deserialize it to a System.String.

thanks @byme8, btw this is how Strawberry Shake client treats custom scalars. Maybe it gives you some ideas

@byme8
Copy link
Owner

byme8 commented Oct 29, 2022

@ahanoff Checkout v2.1.0

@DaveRMaltby
Copy link
Contributor

Should a schema that contains a TimeSpan start failing after upgrading to v2.1.0? I am going to try to follow your readme and make a custom scalar for System.TimeSpan If this works, I would like to create an issue for it and suggest that it be natively supported by ZeroQL.

@byme8
Copy link
Owner

byme8 commented Oct 30, 2022

At the moment, it will fail. It is not bootstrapped correctly in the library. It is possible to define it as a custom scalar, but it would be much better to handle it as a system type.

I already started working on it and noticed that HotChocolate and System.Text.Json serialize System.TimeSpan in different formats. So, I plan to add a more robust way to tinker with JSON serialization in the library.

@DaveRMaltby
Copy link
Contributor

You rock! Thanks.

@byme8 byme8 closed this as completed Nov 1, 2022
@byme8
Copy link
Owner

byme8 commented Jan 8, 2023

@DaveRMaltby Starting from v3.3.0-preview.2 the System.TimeSpan is properly bootstrapped.

@DaveRMaltby
Copy link
Contributor

@byme8, great! Thank you sir. I'll take advantage of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants