Prisma1: Getting TypeError: Cannot read property 'selectionSet' of undefined

Created on 14 Nov 2018  路  17Comments  路  Source: prisma/prisma1

All my resolver started throwing this error after upgrading to [email protected]

Works fine on [email protected]

Expected behavior
This error shouldn't happen.

Screenshots
screen shot 2018-11-14 at 11 44 19 am

According to the error there's something wrong with prisma-client-lib for this version 1.20.3

Versions (please complete the following information):

  • OS: MacOS latest
  • prisma CLI: prisma/1.20.3 (darwin-x64) node 8 lts]
  • graphql-cli, prisma-client, graphql-yoga
bu2-confirmed areclient

Most helpful comment

We're sorry for the inconveniences. We just released a fix for this https://github.com/prisma/prisma/releases/tag/1.20.7

When using [email protected] this problem should not occur anymore.

In case you're still facing this issue - please let us know and we reopen this issue.

All 17 comments

@chanlito : If possible, can you also please share a minimal reproduction github project?

I can confirm the same problem with the:

The repo for reproducing the bug can be found here - https://github.com/tadejstanic/prisma-nestjs

It's a NestJS project which uses prisma client. So NestJS is just a wrapper around the prisma client therefore I'm sure NestJS has nothing to do with the bug.

The error bubbles up when you execute a query with a related model (courses). For instance:

query getAllUsers {
  getAllUsers{
    id name courses {
        title
    }
  }
}

On the other hand, this query works just fine:

query getAllUsers {
  getAllUsers{
    id name 
  }
}

With [email protected] this bug was not presented.

Also having this issue after updating to 1.20.5.

Error stack:
TypeError: Cannot read property 'selectionSet' of undefined at C:\dev\cba-prisma-yoga\node_modules\prisma-client-lib\src\Client.ts:316:14 at Array.reduceRight (<anonymous>) at Client.generateSelections (C:\dev\cba-prisma-yoga\node_modules\prisma-client-lib\src\Client.ts:231:30) at Client.<anonymous> (C:\dev\cba-prisma-yoga\node_modules\prisma-client-lib\src\Client.ts:138:32) at step (C:\dev\cba-prisma-yoga\node_modules\prisma-client-lib\dist\Client.js:47:23) at Object.next (C:\dev\cba-prisma-yoga\node_modules\prisma-client-lib\dist\Client.js:28:53) at C:\dev\cba-prisma-yoga\node_modules\prisma-client-lib\dist\Client.js:22:71 at new Promise (<anonymous>) at __awaiter (C:\dev\cba-prisma-yoga\node_modules\prisma-client-lib\dist\Client.js:18:12) at Client.processInstructions (C:\dev\cba-prisma-yoga\node_modules\prisma-client-lib\src\Client.ts:134:42)

So i updated my application, everything to 1.20.5 (prisma-cli, prisma-client, prisma-server) and here are the result:


  1. screen shot 2018-11-14 at 9 28 05 pm
    I get Cannot read property 'selectionSet' of undefined

2.
screen shot 2018-11-14 at 9 30 04 pm
I get Invalid AST Node: {}

3.
screen shot 2018-11-14 at 9 31 36 pm
The 3rd seems okay.

Finally I ran those queries on version 1.20.1 again, they all ran fine without errors.

Stack for invalid AST Node:

Query: Error: Invalid AST Node: {} at visit (C:\dev\cba-prisma-yoga\node_modules\graphql\language\visitor.js:245:15) at Object.print (C:\dev\cba-prisma-yoga\node_modules\graphql\language\printer.js:22:29) at Client.<anonymous> (C:\dev\cba-prisma-yoga\node_modules\prisma-client-lib\src\Client.ts:145:21) at step (C:\dev\cba-prisma-yoga\node_modules\prisma-client-lib\dist\Client.js:47:23) at Object.next (C:\dev\cba-prisma-yoga\node_modules\prisma-client-lib\dist\Client.js:28:53) at C:\dev\cba-prisma-yoga\node_modules\prisma-client-lib\dist\Client.js:22:71 at new Promise (<anonymous>) at __awaiter (C:\dev\cba-prisma-yoga\node_modules\prisma-client-lib\dist\Client.js:18:12) at Client.processInstructions (C:\dev\cba-prisma-yoga\node_modules\prisma-client-lib\src\Client.ts:134:42) at Client.processInstructionsOnce (C:\dev\cba-prisma-yoga\node_modules\prisma-client-lib\src\Client.ts:128:33)

Hello,
Unfortunately I am having the same problem, even I am just trying to learn Prisma by using the tutorial of the official documentation. (https://www.prisma.io/docs/1.20/get-started/02-change-data-model-JAVASCRIPT-c001/)
I got the error while I am trying the Step 6 (Query relational data)
There isn't any problem while querying the users' info as following:
const postsByUser = await prisma .user({ email: "[email protected]" })
However, if I add the remaining part,

const postsByUser = await prisma .user({ email: "[email protected]" }) .posts()
Now I am getting the mentioned error

Thanks in advance.

Getting this issue too

Same problem here with nested queries, works fine with Prisma 1.20.1.

Also seeing this error with relations

Also seeing this problem unfortunately on 1.20.6

Getting same error with v1.20.6, which wasn't present in v1.20.0.

Same problem.

Same here at the step const postsByUser = await prisma.user({ email: "[email protected]" }).posts() of the tutorial https://www.prisma.io/docs/get-started/02-change-data-model-TYPESCRIPT-t101/

Seems like node here is undefined https://github.com/prisma/prisma/blob/4658f385eb67dcbdde7176d0ccb7a6f31095362c/client/src/Client.ts#L308

We're sorry for the inconveniences. We just released a fix for this https://github.com/prisma/prisma/releases/tag/1.20.7

When using [email protected] this problem should not occur anymore.

In case you're still facing this issue - please let us know and we reopen this issue.

Thanks @timsuchanek ! Working now for me.

@timsuchanek Thank you for the quick fix! Works for me too.

@timsuchanek how shall I go about updating? I have this issue #3508 which made me downgrade to 1.20.5. I tested the 1.21.0 and the issue wasn't resolved there. Now I'm not sure whether updating fixes both issues for me.

Edit: Just updated the client-lib and prisma to 1.21.1 and it seems to run!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

akoenig picture akoenig  路  3Comments

dohomi picture dohomi  路  3Comments

notrab picture notrab  路  3Comments

hoodsy picture hoodsy  路  3Comments

Fi1osof picture Fi1osof  路  3Comments