Skip to content

Deserialize struct from query that isn't present in schema #911

Closed Answered by obmarg
djkato asked this question in Q&A
Discussion options

You must be logged in to vote

So I'm guessing in the GraphQL schema this is defined as JSON, which is a scalar that represents arbitrary some arbitrary JSON object?

You've got a few options for handling this:

  1. Define ChosenPaymentMethodData as you've done above, and then put cynic::impl_scalar!(ChosenPaymentMethodData, schema::JSON) afterwards, and it should work. You can do cynic::impl_scalar on any type that implements Serialize & Deserialize, and it'll become acceptable in positions expecting the given scalar. It's often better than deriving Scalar for that reason. Although it's worth noting that this will let you use ChosenPaymentMethodData on any JSON field, not just this one. So be careful with that.
  2. You can use s…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by djkato
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants