Describe the bug
Subscriptions provide null instead of values and generate an error in the prisma.io playground as well as typescript client. I have using nestjs framerwork so resolver is created according to nestjs and I assume one user is added with "[email protected]"
To Reproduce
Steps to reproduce the behavior:
```graphql
type User {
id: ID! @unique
firstName: String
lastName: String
email: String! @unique
createdAt: DateTime!
updatedAt: DateTime!
archivedAt: DateTime @default(value: null)
}
2. add prisma.yml as follows
```yml
endpoint: ${env:PRISMA_URL}
secret: ${env:PRISMA_SECRET}
datamodel:
- ./src/core/user/user.prisma
generate:
- generator: typescript-client
output: ./src/prisma
@Mutation()
async updateUser(@Args() args): Promise<User> {
return prisma.updateUser(args);
}
@Subscription('user')
onUserMutation() {
return {
subscribe: async (parent, args, context) => {
return prisma.$subscribe.user(args);
},
resolve: (payload) => {
console.log('payload', payload);
return payload;
},
};
}
deploy schema using prisma deploy
Go to playground hosted prisma.io by https://eu1.prisma.sh/XYZ and do subscribe using
subscription {
user {
node{
id
firstName
lastName
email
createdAt
updatedAt
archivedAt
}
mutation
updatedFields
previousValues {
id
firstName
lastName
email
createdAt
updatedAt
archivedAt
}
}
}
mutation {
updateUser(data: { lastName: "TestLastName" }, where: { email: "[email protected]" }) {
id
firstName
lastName
email
createdAt
updatedAt
archivedAt
}
}
Expected behavior
When userUpdate mutation is run on local or graphql playground output should be
"data": {
"user": {
"node": {
"updatedAt": "2018-11-27T08:45:40.865Z",
"email": "[email protected]",
"archivedAt": null,
"lastName": "TestLastName",
"firstName": "TestFirstName",
"id": "cjoz9klnnab7709619ruq8mrs",
"createdAt": "2018-11-27T04:51:27.779Z"
},
"mutation": "UPDATED",
"updatedFields": [
"lastName",
"updatedAt"
],
"previousValues": {
"updatedAt": "2018-11-27T08:40:40.865Z",
"email": "[email protected]",
"archivedAt": null,
"lastName": "TestLastPreviousName",
"firstName": "TestFirstName",
"id": "cjoz9klnnab7709619ruq8mrs",
"createdAt": "2018-11-27T04:51:27.779Z"
}
}
}
However, the output is
{
"data": {
"user": {
"node": {
"updatedAt": "2018-11-27T07:46:31.066Z",
"email": "[email protected]",
"archivedAt": null,
"lastName": "TestLastName",
"firstName": "TestFirstName",
"id": "cjoz9klnnab7709619ruq8mrs",
"createdAt": "2018-11-27T04:51:27.779Z"
},
"mutation": "UPDATED",
"updatedFields": [
"lastName",
"updatedAt"
],
"previousValues": null
}
},
"errors": [
{
"message": "Cannot return null for non-nullable type (line 18, column 7):\n email\n ^",
"path": [
"user",
"previousValues",
"email"
],
"locations": [
{
"line": 18,
"column": 7
}
]
},
{
"message": "Cannot return null for non-nullable type (line 19, column 7):\n createdAt\n ^",
"path": [
"user",
"previousValues",
"createdAt"
],
"locations": [
{
"line": 19,
"column": 7
}
]
},
{
"message": "Whoops. Looks like an internal server error. Search your server logs for request ID: subscription:cjozfpkcwcxo40961ivojk78u:1",
"path": [
"user",
"previousValues",
"updatedAt"
],
"requestId": "subscription:cjozfpkcwcxo40961ivojk78u:1"
}
]
}
and on local playground the output is
{
"data": {
"user": {
"node": null,
"mutation": "UPDATED",
"updatedFields": [
"lastName",
"updatedAt"
],
"previousValues": null
}
}
}
as we console log in resolver the outout on console is
payload { mutation: 'UPDATED', updatedFields: [ 'lastName', 'updatedAt' ] }
Versions (please complete the following information):
prisma CLI: prisma/1.21.1 (linux-x64) node-v10.13.0Additional context
This issue is already put up at https://www.prisma.io/forum/t/prisma-client-1-19-and-subscription-big-problem/4775
I think this is an issue with subscription response from prisma.io hosted service which did not return previousValues column as well as Prisma client (typescript) which failed to return node as well as previousValues received from prisma service.
I was able to reproduce the issue:
here is the server log for the faulty request
{
"key":"error/unhandled",
"requestId":"subscription:cjp2nep0h000e0770bz75v6v4:1",
"clientId":"test$test",
"payload":{
"exception":"java.lang.ClassCastException: java.lang.String cannot be cast to org.joda.time.DateTime",
"query":"subscription {\n user {\n node {\n id\n firstName\n lastName\n email\n createdAt\n updatedAt\n archivedAt\n }\n mutation\n updatedFields\n previousValues {\n id\n firstName\n lastName\n email\n createdAt\n updatedAt\n archivedAt\n }\n }\n}",
"variables":"{}",
"code":"0",
"stack_trace":"sangria.execution.Resolver.resolveValue(Resolver.scala:858)\\n sangria.execution.Resolver.$anonfun$resolveActionsPar$4(Resolver.scala:518)\\n scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:234)\\n scala.collection.Iterator.foreach(Iterator.scala:929)\\n scala.collection.Iterator.foreach$(Iterator.scala:929)\\n scala.collection.AbstractIterator.foreach(Iterator.scala:1417)\\n scala.collection.IterableLike.foreach(IterableLike.scala:71)\\n scala.collection.IterableLike.foreach$(IterableLike.scala:70)\\n scala.collection.AbstractIterable.foreach(Iterable.scala:54)\\n scala.collection.TraversableLike.map(TraversableLike.scala:234)\\n scala.collection.TraversableLike.map$(TraversableLike.scala:227)\\n scala.collection.AbstractTraversable.map(Traversable.scala:104)\\n sangria.execution.Resolver.resolveActionsPar(Resolver.scala:512)\\n sangria.execution.Resolver.resolveValue(Resolver.scala:901)\\n sangria.execution.Resolver.resolveValue(Resolver.scala:807)\\n sangria.execution.Resolver.$anonfun$resolveActionsPar$4(Resolver.scala:518)\\n scala.collection.TraversableLike.$anonfun$map$1(TraversableLike.scala:234)\\n scala.collection.Iterator.foreach(Iterator.scala:929)\\n scala.collection.Iterator.foreach$(Iterator.scala:929)\\n scala.collection.AbstractIterator.foreach(Iterator.scala:1417)\\n scala.collection.IterableLike.foreach(IterableLike.scala:71)\\n scala.collection.IterableLike.foreach$(IterableLike.scala:70)\\n scala.collection.AbstractIterable.foreach(Iterable.scala:54)\\n scala.collection.TraversableLike.map(TraversableLike.scala:234)\\n scala.collection.TraversableLike.map$(TraversableLike.scala:227)\\n scala.collection.AbstractTraversable.map(Traversable.scala:104)\\n sangria.execution.Resolver.resolveActionsPar(Resolver.scala:512)\\n sangria.execution.Resolver.resolveValue(Resolver.scala:901)\\n sangria.execution.Resolver.resolveValue(Resolver.scala:807)\\n sangria.execution.Resolver.$anonfun$resolveActionsPar$15(Resolver.scala:620)\\n scala.util.Success.$anonfun$map$1(Try.scala:251)\\n scala.util.Success.map(Try.scala:209)\\n scala.concurrent.Future.$anonfun$map$1(Future.scala:287)\\n scala.concurrent.impl.Promise.liftedTree1$1(Promise.scala:29)\\n scala.concurrent.impl.Promise.$anonfun$transform$1(Promise.scala:29)\\n scala.concurrent.impl.CallbackRunnable.run(Promise.scala:60)\\n akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)\\n akka.dispatch.BatchingExecutor$BlockableBatch.$anonfun$run$1(BatchingExecutor.scala:91)\\n scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:12)\\n scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:81)\\n akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:91)\\n akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40)\\n akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutorConfigurator.scala:43)\\n akka.dispatch.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)\\n akka.dispatch.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)\\n akka.dispatch.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)\\n akka.dispatch.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)",
"message":"java.lang.String cannot be cast to org.joda.time.DateTime"
}
}
here is playground output

and here is the reproduction repository: https://github.com/pantharshit00/prisma-3603
@divyenduz Any progress with this?
https://github.com/prisma/prisma/issues/3634 seems to be the same issue.
@JeetChaudhari : These are two separate issues, the other one talks about client and sub-query selection, and the solution to that is outlined here: https://github.com/prisma/prisma/issues/3629
This one is a bug in Prisma core, we have identified it with this reproduction, you can track this issue for its resolution.
I am also experiencing null previousValues with prisma client 1.27.1.
I have made a reproduction using the primsa-examples/typescript/graphql-subscriptions repository.
https://github.com/david-on-github/primsa-client-deleted-subscriptions
Most helpful comment
I was able to reproduce the issue:
here is the server log for the faulty request
here is playground output

and here is the reproduction repository: https://github.com/pantharshit00/prisma-3603