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 #8

Open
CodesInChaos opened this issue Aug 28, 2024 · 1 comment
Open

Support for custom scalars #8

CodesInChaos opened this issue Aug 28, 2024 · 1 comment

Comments

@CodesInChaos
Copy link

I'm interested in proper support for custom scalar types. This has some overlap with the enum support mentioned in the readme, in particular this applies to them as well:

However end users probably don't want multiple enums for each generated query module as this would break sharing. To get around this, there should be a macro for generating the shared types used by all other.

There is one additional challenge however: Custom scalars usually have constraints, so the new function needs to contain validation and return a custom Result type. Auto generating that isn't trivial for standard constraints, and practically impossible for expression constraints. So there needs to be a design that allows mixing auto-generated code with custom written code.

@ifiokjr
Copy link
Owner

ifiokjr commented Aug 28, 2024

I think I'll leave the custom scalar types until the edgedb-protocol library is upgraded to protocol version 2.0. This provides names for the scalar types which can be added to the shared types.

Regarding constraints, I was thinking there might be a way to provide the https://github.com/Keats/validator as an option. But I can't think of a good API for this.

It's not a high priority for my current project, but if you can think of a compelling way to integrate this, I'm happy to accept contributions.

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

No branches or pull requests

3 participants
@CodesInChaos @ifiokjr and others