Prisma1: Subscriptions with updatedFields_contains filter are not triggered

Created on 3 May 2018  路  11Comments  路  Source: prisma/prisma1

Bug Report

Current behavior

Server-side subscription throws on mutation execution

Reproduction

I've setup a subscription on user type to send confirmation email after user creation, which looks as follows (running on Prisma sandbox 1.7.4):

subscription {
  user(where: {
    OR: [{
      mutation_in: [CREATED]
    }, {
      mutation_in: [UPDATED]
      updatedFields_contains: "confirmToken"
      node: {
        confirmToken_not: "null"
      }
    }]
  }) {
    node {
      email
      confirmToken
      firstName
      lastName
    }
  }
}

When I try to create a new user I am getting following error:

...

Error: Argument 'where' expected type 'UserSubscriptionWhereInput' but got:

{
  OR: [{
    boolean: true
  }, {
    boolean: false,
    updatedFields_contains: "confirmToken",
    node: {
      confirmToken_not: "null"
    }
  }]
}

Reason: 'OR[1].updatedFields_contains' Field 'updatedFields_contains'
is not defined in the input type 'UserSubscriptionWhereInput'. (line 2, column 15):

...

Notice how mutation_in: [CREATED] and mutation_in: [UPDATED] from my
subscription query above are replaced with boolean: true and boolean: false.

Expected behavior?
I would expect that appropriate condition from the filtering logic provided in subscription is being matched and payload posted to the specified webhook.

aresubscriptions bu2-confirmed

Most helpful comment

Thanks for reporting this! 馃檹
I implemented a fix that we will ship today with 1.17.2.

All 11 comments

@taikn, thanks for your report! That looks like problem with updatedFields_contains.
Can you provide a minimal repo to reproduce this issue? 馃檪

I've narrowed down the issue i think it has something to do with mutation type UPDATED, you can clone the the repo from here: https://github.com/taikn/prisma-sss-error

npm install
npm run dev

then in playground try running this mutation:

mutation {
  updateUser(
    where: {id: "cjgrv5uqa4vir0b59xhoflz35"},
    data: {confirmToken: "prettyCoolToken"}) {
      id
  }
}

I am getting:

[GraphQL error]: Message: There can be only one input field named 'boolean'., Location: [object Object], Path: updateUser
[Network error]: Error: There can be only one input field named 'boolean'.
Error: There can be only one input field named 'boolean'.
    at BatchedGraphQLClient.<anonymous> (/Users/eduard/Sites/prisma-sss-error/node_modules/http-link-dataloader/dist/src/BatchedGraphQLClient.js:77:35)
    at step (/Users/eduard/Sites/prisma-sss-error/node_modules/http-link-dataloader/dist/src/BatchedGraphQLClient.js:40:23)
    at Object.next (/Users/eduard/Sites/prisma-sss-error/node_modules/http-link-dataloader/dist/src/BatchedGraphQLClient.js:21:53)
    at fulfilled (/Users/eduard/Sites/prisma-sss-error/node_modules/http-link-dataloader/dist/src/BatchedGraphQLClient.js:12:58)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

Thanks @taikn, I can confirm this error.

Additionally, this mutation (to the Prisma API)

mutation b {
  createUser(data: {
    email: "Nilan"
    firstName: "Nilan"
    lastName: "Nilan"
    confirmToken: ""
  }) {
    id
  }
}

results in

{
  "data": null,
  "errors": [
    {
      "message": "Argument 'where' expected type 'UserSubscriptionWhereInput' but got: {OR: [{boolean: true}, {boolean: false, updatedFields_contains: \"confirmToken\", node: {confirmToken_not: \"null\"}}]}. Reason: 'OR[1].updatedFields_contains' Field 'updatedFields_contains' is not defined in the input type 'UserSubscriptionWhereInput'. (line 2, column 15):\n  user(where: {\n              ^\n (line 3, column 5):\n    OR: [{\n    ^\n (line 3, column 9):\n    OR: [{\n        ^\n (line 7, column 7):\n      updatedFields_contains: \"confirmToken\"\n      ^",
      "path": [
        "createUser"
      ],
      "locations": [
        {
          "line": 8,
          "column": 3
        },
        {
          "line": 2,
          "column": 15
        },
        {
          "line": 3,
          "column": 5
        },
        {
          "line": 3,
          "column": 9
        },
        {
          "line": 7,
          "column": 7
        }
      ]
    }
  ]
}

as you mentioned in your first post.

:wave: Any updates on this one?

@marktani What could be a workaround until this is fixed? Moving webhook requests directly into the resolvers?

I also received this error
mutation:

mutation {
  updateOrder(
    where: {
      id: "xxxx"
    }
    data: {
      status: DONE
    }
  ) {
    id
    status
  }
}

result:

{
  "data": {
    "updateOrder": null
  },
  "errors": [
    {
      "locations": [],
      "message": "There can be only one input field named 'boolean'.",
      "path": [
        "updateOrder"
      ]
    }
  ]
}

Also getting this error. Client only just reported it but I can imagine it's been happening for a while. A fix would be awesome as moving this into resolvers is quite costly.

Hitting this issue as well

Surprised this is not given more priority as it renders the power of Prisma subscriptions (almost) useless.

I don't think is renders subscriptions almost useless 馃檪
But I'll see if we can give this some attention soon!

Thanks for reporting this! 馃檹
I implemented a fix that we will ship today with 1.17.2.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sapkra picture sapkra  路  40Comments

sorenbs picture sorenbs  路  48Comments

marktani picture marktani  路  34Comments

sorenbs picture sorenbs  路  52Comments

marktani picture marktani  路  48Comments