Solved

GraphQL: How to clear a connection field value

  • 28 August 2023
  • 5 replies
  • 110 views

Userlevel 4

Hi there!

 

Im trying to get a card and clear the value of a field using GraphQL. The field is not string or number, it is a pipe connector. I’m not trying to delete the relation field, just clearing it out.

 

I’m trying the following:

mutation { updateFieldsValues(input: {nodeId: "{cardId}", values: {fieldId: "{name}", value: [] }}) { clientMutationId } }

 

I have tryed usin “” or [“”] in the value but I got always an error sayin is an invalid input.

Have anyone did this before?

icon

Best answer by Lais Laudari 28 August 2023, 16:36

View original

5 replies

Userlevel 7

Hi @ramongb!
Did you try to fill out it as null? 
value: [null]

Userlevel 4

Hi @Lais Laudari 

Thanks for your answer, but it does’t work either:

 

Query:

mutation {   updateFieldsValues(     input: {nodeId: "782947385", values: {fieldId: "booking", value: [ null ]}}   ) {   clientMutationId   } }

 

Result:

mutation {

  updateFieldsValues(

    input: {nodeId: "782947385", values: {fieldId: "booking", value: NULL}}

  ) {

    clientMutationId

  }

}

 

I also triyed NULL and [NULL] but I got:

{

  "errors": [

    {

      "message": "Argument 'value' on InputObject 'NodeFieldValueInput' has an invalid value (NULL). Expected type '[UndefinedInput]'.",

      "locations": [

        {

          "line": 3,

          "column": 42

        }

      ],

      "path": [

        "mutation",

        "updateFieldsValues",

        "input",

        "values",

        0,

        "value"

      ],

      "extensions": {

        "code": "argumentLiteralsIncompatible",

        "typeName": "InputObject",

        "argumentName": "value"

      }

    }

  ]

}

 

What else can I try?

 

 

 

Userlevel 7

I got it!
Can you try this one:
 

mutation {updateCardField( input: {card_id: xxxxx, field_id: "xxxx", new_value: null }) {  clientMutationId  success}}


 

Userlevel 4

I works!!!!

 

Ok I hadn't considered updateCardField

 

Thanks a lot @Lais Laudari 

Userlevel 7
Badge +13

It’s so good to see this community working and sharing knowledge.

Reply