hasura / graphql-engine

Blazing fast, instant realtime GraphQL APIs on your DB with fine grained access control, also trigger webhooks on database events.
https://hasura.io
Apache License 2.0
31.12k stars 2.77k forks source link

Insert mutation problem: No such type exists in the schema #288

Closed andreystarkov closed 6 years ago

andreystarkov commented 6 years ago

Table name is lottery_tickets. Here is code:

  export const MUTATION_ADD = gql`
    mutation insertLotteryTicketsMutation ($objects: [lottery_tickets_input]){
      insert_lottery_tickets(objects: $objects) {
        affected_rows
        returning {
          id
        }
      }
    }
  `
  client.mutate({
    mutation: MUTATION_ADD,
    variables: {
      objects: [
        {
          ticketId: 3,
          timestamp: '1533810845',
          numbers: '11,12,13,14,15'
        }
      ]
     }
   })

I get this error: 400: No such type exists in the schema lottery_tickets_input. Am i doing something wrong? Everything seems like it was described at your docs. Hasura version v1.0.0-alpha12

andreystarkov commented 6 years ago

Solved. Seems like error at your docs.

[tablename]_input -> [tablename]_insert_input

coco98 commented 6 years ago

@andreystarkov We'll update our docs asap! Keeping this issue open till that happens. @rikinsk please take note!

rikinsk-zz commented 6 years ago

@andreystarkov Could you share the docs page you noticed the bug on. I am having some trouble locating the exact source.

andreystarkov commented 6 years ago

@rikinsk https://github.com/hasura/platform-docs/blob/master/platform/manual/guides/graphql-react.rst

At least this one, i saw same description at some other place, but cant find where at the moment.

rikinsk-zz commented 6 years ago

Right. Those are actually docs for the Hasura Kubernetes platform which currently uses a very old version of GraphQL engine. Hence the discrepancy in its docs I believe.

coco98 commented 6 years ago

Ok. So once we add docs on query variables here: https://docs.hasura.io/1.0/graphql/manual/mutations/insert.html we can close this.

andreystarkov commented 6 years ago

Thank you guys!

ajhool commented 4 years ago

I had this same error and realized that I was not adding the appropriate header (my admin secret) when making the call. Thus, it was not able to find the schema and therefore didn't recognize the uuid type. Adding the correct auth resolved the problem.