0
mutation MyMutation($title: String!, $date: date!,$stime: timetz!  , $etime: timetz!
 ) {
  insert_schedules(objects: {title: $title , date: $date, start_time: $stime, end_time:$etime}) {
    affected_rows
  }
}`

Error

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

Here I am using timetz but it doesnt work.Even using time doesnt work.What to use.

Nitish
  • 35
  • 1
  • 1
  • 6

1 Answers1

1

That's because the type of start_time and/or end_time columns are not timetz.

There are two solutions:

  1. changing the type of those columns to timetz; can be achieved by running this sql as a migration
alter table schedules alter column start_time type timetz;
alter table schedules alter column end_time type timetz;

  1. or if your column is of type timestamp with timezone, you can simply do:
mutation MyMutation($title: String!, $date: date!, $stime: timestamptz!, $etime: timestamptz!) {
  insert_schedules(objects: {title: $title, date: $date, start_time: $stime, end_time: $etime}) {
    affected_rows
  }
}

Although both timetz and timestamptz are supported by hasura, timestamptz stores both date and time, with time zone, and is the more recommended one. Check this page out to know more about their differences. https://www.postgresql.org/docs/current/datatype-datetime.html