Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

231
Views
Null value in bulk insert Hasura GraphQL

I am trying to do a multiple insert using a REST API exposed by Hasura (written in GraphQL). This is my mutation:

mutation insertMultipleMeasurements2($payload: [measurements_insert_input!]!) {
  insert_measurements(objects: $payload) {
    returning {
      time
    } 
  }
}

and this is the definition of measurements_insert_input in the Actions tab:

input measurements_insert_input {
  device: String!
  value: numeric!
  variable: String!
}

(which btw is the only way I found to insert an object of numeric type in a bulk insert).

When I try to insert something like:

[
    {
        "device": "TEST",
        "value": 5630,
        "variable": "Length"
    },
        {
        "device": "TEST",
        "value": 5631,
        "variable": "Length"
    }
]

I get:

{
    "path": "$",
    "error": "expecting a value for non-nullable variable: \"payload\"",
    "code": "validation-failed"
}

I tried many different ways to rewrite my mutation but looks like none worked. Thanks in advance

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You've most likely forgotten to wrap your objects with variables, like so :

yourMutation({
      variables: { objects, on_conflict }
})

It's not straightforward if you rely on TS IntelliSense, better check the doc :)

about 4 years ago · Juan Pablo Isaza Report

0

Based on the error message

"expecting a value for non-nullable variable: "payload""

you should be passing the array via an object

{
  payload: [
    {
    "device": "TEST",
    "value": 5630,
    "variable": "Length"
    },
    {
    "device": "TEST",
    "value": 5631,
    "variable": "Length"
    }
  ]
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!