question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

jsonb mutation variable fails with "no such type exists in the schema: 'jsonb'"

See original GitHub issue

Connected to Hasura through a WebSocket, I’m trying to use a jsonb column, inserting an array. But even without any data being sent for that variable (which should then result in it becoming NULL since it’s nullable), I still get an error stating no such type exists in the schema: 'jsonb'. I’ve seen jsonb being used in the Hasura docs (as an example: https://hasura.io/docs/1.0/graphql/core/mutations/insert.html#insert-an-object-with-a-jsonb-field) so I’m not sure what I’m doing wrong.

Here’s the mutation (note that I’m not sending the $files variable through for testing purposes):

mutation submitPost($body: String!, $files: jsonb) {
  insert_newsfeed_one(object: { body: $body }) {
    id
  }
}

Here’s the full WS message being sent:

{
  "id": "5",
  "type": "start",
  "payload": {
    "variables": { "body": "Testing", "files": [] },
    "extensions": {},
    "operationName": "submitPost",
    "query":"mutation submitPost($body: String!, $files: jsonb) {
      insert_newsfeed_one(object: {body: $body}) {
        id
        __typename
      }
    }
    "
  }
}

And the error response:

{
  "type": "error",
  "id": "5",
  "payload": {
    "errors": [
      {
        "extensions": {
          "path": "$.variableValues",
          "code": "validation-failed"
        },
        "message": "no such type exists in the schema: 'jsonb'"
      }
    ]
  }
}

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

7reactions
tirumaraiselvancommented, Nov 10, 2020

Hi @trymbill

Are you using any role (x-hasura-role)? If you are using a role, then does the table with a jsonb column have permission on that column to insert or select? I guess it does not by looking at the error message: no such type exists in the schema: 'jsonb'

This is just a GraphQL spec thing where if a type is not used in any field, it is simply omitted from schema. You do not see this with GraphiQL as it is running as admin role.

2reactions
trymbillcommented, Nov 10, 2020

Ahh! Good catch! Yeah, it’s definitely a new column so the permissions weren’t updated yet. Thank you for your help!

Just as a sidenote; might be worth updating that error message. Checking the permissions will from now on be something I check, but for new users, it’s definitely not 100% obvious. Thanks again for a killer product!

Read more comments on GitHub >

github_iconTop Results From Across the Web

"no such type exists in the schema: 'timetz'" in hasura
There are two solutions: changing the type of those columns to timetz; can be achieved by running this sql as a migration. alter...
Read more >
Postgres: Update mutation | Hasura GraphQL Docs
The output type is the nullable table object. The mutation returns the updated row object or null if the row does not exist....
Read more >
GraphQL schema basics
Your GraphQL server uses a schema to describe the shape of your available data. This schema defines a hierarchy of types with fields...
Read more >
How to Use TypeScript with GraphQL using TypeGraphQL
GraphQL also comes with type definitions, which exist in schema objects. ... In package.json , update the scripts object to this:
Read more >
GraphQL Queries & Mutations - elide.io
Contains the actual graphQL query. operationName - Used if multiple operations are present in the same query. variables - Contains a json object...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found