Uh oh!
There was an error while loading. Please reload this page.
Decoders - #351
Conversation
xperiandri
left a comment
There was a problem hiding this comment.
Looks interesting.
But I have not noticed a practical usage sample in tests.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Co-authored-by: Andrii Chebukin <xperiandri@live.ru>
Co-authored-by: Andrii Chebukin <xperiandri@live.ru>
Co-authored-by: Andrii Chebukin <xperiandri@live.ru>
njlr
commented
Oct 6, 2021
Good point - I can update one of the samples perhaps |
* Updates star-wars to new API * Updates star-wars to new API * Updates star-wars to new API * Updates star-wars to new API * Updates star-wars to new API * Updates star-wars to new API * Updates star-wars to new API
| match error.Reason with | ||
| | DecodeErrorReason.TypeMismatch (expected, actual) -> | ||
| sprintf "expected value of type %s but got %s" expected actual |
There was a problem hiding this comment.
| sprintf "expected value of type %s but got %s" expected actual | |
| sprintf "expected value of type '%s' but got '%s'" expected actual |
| match varDef.TypeDef with | ||
| | Nullable _ -> Ok NullValue | ||
| |_ -> | ||
| let message = sprintf "Variable '$%s': expected value of type %s, but no value was found" vname (varDef.TypeDef.ToString()) |
There was a problem hiding this comment.
| letmessage= sprintf "Variable '$%s': expected value of type %s, but no value was found" vname (varDef.TypeDef.ToString()) | |
| letmessage= sprintf "Variable '$%s': expected value of type '%s', but no value was found" vname (varDef.TypeDef.ToString()) |
c8b3525 to
0810527Compare14aa27a to
3ba4016Compare1737829 to
246d6c0Compare0dd4372 to
81bc85eCompared90f0e9 to
434b4beComparef3a1bf8 to
9d4b950Compare6dc591e to
85a9d8cCompare
This PR introduces "decoders" to input types in the schema.
A decoder is like a
coerceInputfunction, but it returns a structuredErrorrather than anoption:A helper library of decoders is provided for common types like
string,int, etc. There is also a utility for automatic decoder generation using reflection.All input types (not just scalars) now have a decoder attached to them.
The user can provide a decoder (recommended) or they can allow a default one to be generated automatically. This allows the user to interpret the GraphQL AST with the context of the type being decoded.
There are currently some scrappy comments etc. If we like the idea I can clean it up before merging.