Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Prisma client and errors #3292

Closed
divyenduz opened this issue Oct 10, 2018 · 1 comment
Closed

Prisma client and errors #3292

divyenduz opened this issue Oct 10, 2018 · 1 comment

Comments

@divyenduz
Copy link
Contributor

divyenduz commented Oct 10, 2018

Description
Under this issue, we try to explore the behavior of client in error conditions. There is also a broad proposal prisma/prisma#2199 that also applies to Prisma client

We will explore network errors and GraphQL errors separately. Note that GraphQL errors can also be partial i.e. both data and errors can be filled by the server.

Network error
Assuming that the service is down. Running an operation on Client throws, which IMO is the correct behavior.

try {
  const users = await prisma.users();
  console.log(users);
} catch (e) {
  console.error(e);
}

This code throws in case an exception with the following trace:-

{ Error: Project not found: 'client-errors@dev'
    at BatchedGraphQLClient.<anonymous> (/Users/divyendusingh/Documents/projects/graphcool/triage/client-errors/node_modules/http-link-dataloader/src/BatchedGraphQLClient.ts:59:13)
    at step (/Users/divyendusingh/Documents/projects/graphcool/triage/client-errors/node_modules/http-link-dataloader/dist/src/BatchedGraphQLClient.js:40:23)
    at Object.next (/Users/divyendusingh/Documents/projects/graphcool/triage/client-errors/node_modules/http-link-dataloader/dist/src/BatchedGraphQLClient.js:21:53)
    at fulfilled (/Users/divyendusingh/Documents/projects/graphcool/triage/client-errors/node_modules/http-link-dataloader/dist/src/BatchedGraphQLClient.js:12:58)
    at process._tickCallback (internal/process/next_tick.js:68:7) result: { errors: [ [Object] ], status: 200 } }

GraphQL Errors

On running a Client operation that is sure to produce invalid GraphQL i.e. yielding filled errors key in response from server.

try {
  const users = await prisma.users().$fragment(`fragment userData on User { nonExistingField }`)
  console.log(users);
} catch (e) {
  console.error(e);
}

This also throws, which might not be the correct behavior because GraphQL errors can also be partial i.e. both data and errors can be filled by the server. Even if this is a preferred client behavior, it should be documented here: prisma/prisma#3185

Versions (please complete the following information):

  • prisma CLI: prisma/1.19.0-beta.2 (darwin-x64) node-v10.4.0
@stale
Copy link

stale bot commented Nov 24, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status/stale Marked as state by the GitHub stalebot label Nov 24, 2018
@divyenduz divyenduz removed the status/stale Marked as state by the GitHub stalebot label Nov 27, 2018
@janpio janpio closed this as completed Sep 1, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants