-
Notifications
You must be signed in to change notification settings - Fork 19
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
Custom Input Scalars #35
Comments
Somewhat accidentally, there is already a function that lets you define custom scalar variables for your query, but it's intended for enum types: You can use this for custom scalars just as well, providing the name of the custom scalar type from your schema as the first argument. The only limitation is that the value extraction function you provide must always return a I agree that this library should have a dedicated function for custom scalar variables, so I will probably simply add an alias to I think the functions in |
Yes, I found the enum but as you mention it puts limitations on what types the custom scalar can represent.. both in elm and server side. If the specification does't enforce this limitation, it kinda doesn't make sense to enforce them here? Another solution would be implement the custom scalars for each basic type, prehaps a little bloaty: customInt : String -> VariableSpec NonNull Int
customInt name =
VariableSpec NonNull (TypeRef.namedType name) AST.IntValue ect. or adding it to the AST directly type Value variableConstraint a
= VariableValue variableConstraint String
| IntValue Int
| FloatValue Float
| StringValue String
| BooleanValue Bool
| AnyValue (a -> Encode.Value) a
... But it kinda makes some function definition look weird. type alias ConstantValue a =
Value Never a
type alias ArgumentValue =
Value () Never or
Any thought on that? Meh, should have realized that the arg module can be used to the same end. |
The spec for GraphQL allow for custom input scalars. This lib should allow custom input scalar.
This would allow the server implementation of graphql to catch a input scalar like ProductId(unsigned) as a custom scalar and validate it in the graphql layer, insteed of just passing a int to backend.
The text was updated successfully, but these errors were encountered: