Skip to content

Accessing restricted model property returns both data and errors #813

Answered by MichalLytek
yss14 asked this question in Q&A
Discussion options

You must be logged in to vote

Yes, that's how GraphQL works.

If something bad happens, like TypeError or undefined is not a function inside the resolver, the errors bubbles up in the types and fields chain (nested properties) until it find a nullable field.

Then it continues resolving other fields, because the response is still matching the defined types.

So you can have "partial" response and the errors array containing the detailed info.

Just ignore the errors array on the frontend side if data is still there?

That's up to you - I think frontend should never make a query that violates validation or authentication rules.
Most implementations like Apollo will throw an error if there's some data in errors.

If for som…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@yss14
Comment options

@chinanderm
Comment options

@MichalLytek
Comment options

Answer selected by yss14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants