-
Notifications
You must be signed in to change notification settings - Fork 114
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
[normalize feature req] validation and safety utils #102
Comments
I think this would be a great addition. Would If a |
Just throwing an exception is sufficient for now – eventually surfacing mismatched paths could be a goal but we can add that to the exception details later as well |
After thinking about this further, without having access to the schema, we'd really only be able to validate whether the data should be a Map (i.e. the node has a SelectionSet) or a scalar (i.e. the node doesn't have a SelectionSet), and I'm not sure how useful this would be. So we could either:
How do you envision this being used? Would it be called directly by the user? Or are you incorporating validation into the |
@smkhalsa we can tell from the This came up because for whatever reason a user's |
@micimize ah, ok. The way that the denormalize functions work is that if a Map doesn't contain a key for a given FieldNode in the document (e.g. "bar" in your example above), the By default
It sounds like in the case you describe above, if they want to receive partial data, they should be able to just set |
closed by #104 |
I'm looking at adding some handlers in
graphql/client.dart
to check for / distinguish between malformed response data and cache misconfigurations, and I'm wondering if there's a better way than what I'm currently thinking.Current thinking:
denormalizeOperation
already validates all subtree structure right? So we can create a thin wrappervalidateResponseStructure
that ignores denormalization, or extract the traversal logic into its own helperwriteQuery
/readQuery
. If it returnsnull
, we then:MismatchedDataStructureException
ifvalidateResponseStructure
isnull
CacheRoundTripException
otherwise (could be broken down further later).The main idea is to
validateResponseStructure
independent of the cache. Might be a util better suited forgql
.The text was updated successfully, but these errors were encountered: