Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

232
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda