What is the recommended way to manage and structure queries that returns a list with the error plugin #1248
-
The error plugin explains on how to manage and structure queries that are capable of returning errors using GraphQL interfaces and unions. Say I have the following schema with a interface Error {
message: String!
}
type NotFoundError implements Error {
message: String!
}
type Query {
user(id: ID!): UserResult!
}
type User {
firstname: String!
id: ID!
lastname: String!
}
union UserResult = NotFoundError | User What is the recommended way to manage and structure queries that returns a list with the error plugin? Let's say I want to add a Would the users(ids: [ID!]!): [User!]! or this? which would return existing requested users data as well as users:(ids: [ID!]!): [UserResult!]! or some completely different structure? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
It depends on how and what you want to do with it. here is my opinions:
Of course, Disclaimer; I've never set error options for query fields. If I'm wrong, please let me know. |
Beta Was this translation helpful? Give feedback.
-
You can see an example of how list fields work here: https://stackblitz.com/edit/typescript-2ptbbh?file=index.ts The |
Beta Was this translation helpful? Give feedback.
You can see an example of how list fields work here: https://stackblitz.com/edit/typescript-2ptbbh?file=index.ts
The
directResult
option doesn't work on list fields, so a Result type with a data field containing the list will be created instead.