-
Notifications
You must be signed in to change notification settings - Fork 427
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
Native scalar support for json (w/ feature = "json") #280
Comments
Did you see 2e5df9f on master? |
@LegNeato --- that doesn't work for actually allowing a There are no Presumably an alternative to providing Side Note: AFAIK the problem can't be fully solved by implementing |
Related discussion on this issue: graphql/graphql-spec#101 |
Is there a workaround for this or could someone point me in the right direction in the codebase so I could submit a PR? The only place I can see is that ScalarValue trait... |
I'm not sure we want to do this? I don't see a massive benefit over just creating custom scalars and de/serializing I am sure I am missing something though... |
In any case, I put up a PR for the current-style integration. It still serializes and unserializes to a GraphQL |
I guess it doesn't conform to the spec, but in another Node.js (Apollo) server I have worked with, I used something like https://github.com/taion/graphql-type-json so that you could specify JSON a lot more ergonomically via dev tools like graphiql. It is not a huge deal though, I went ahead and made my own scalar that wraps a Being able to directly use |
@LegNeato - yes, for me the benefit would be if serialization did not serialize to string; while having a standard serialized-to-string Json is useful in terms of "batteries included" for library users, I think the benefit is to minimize complexity of deserialization/serialization in clients by having it be "full" JSON (instead of serialized json within json). |
Any update on this? |
I would like to be able to use a
serde_json::Value
as an Input or Output value in the graph.This can work fine for output values, but doesn't work for Input values.
Simple-ish work arounds include newtype-ing
json::Value
and having it serialize as some sort of string or blob--- but that causes easily avoidable and unnecessary pain for both a Javascript Client and for the server itself (which might, for example use the same struct with bothdiesel
andjuniper
).This doesn't work (I think) because using an arbitrary JSON value as an input (or output) would require unusual handling during validation that is not described by the GraphQL spec. We could, as an extension have special handling for a
serde_json::Value
that does not attempt to further validate the input after identifying that the input variable / input-object field is expecting arbitrary JSON.I believe an extension like this must be implemented within
juniper
itself (although if I'm wrong, I'd love to know). This should be fairly low risk to add to core, asserde_json
is an incredibly widely used and well supported rust crate. Presumably it would be a off-by-default feature flag since it is an extension to the GraphQL spec.The text was updated successfully, but these errors were encountered: