Spring boot graphql - How to use an input array? [Fixed]

Viewed 17

[FIXED, the answer is below] I'm new to spring boot and graphql so this question might be dump but I didn't found the answer to my question on internet so I'm asking it here. How are we supposed to use input arrays for graphql mutations ? Here is how I tried :

// schema.graphqls
type Mutation{
    test(input:TestInput):String
}

input TestInput{
    temp:[Int]
}


// @Controller TestInputController.java
@MutationMapping
public String test(@Argument TestInput input){
    System.out.println("hello");
    System.out.println(input);
    return "test";
}

record TestInput(Integer[] temp){}


// mutation in graphiql
mutation{
  test(input:{
    temp:[5]
    })   
}

// result
Error : java.lang.IllegalStateException: Cannot access properties on null bean instance 'input'

Do you have an idea of how I can fix that ? Or any resource that can explain me my problem ?

Thanks in advance


For fixing the problem, we should use List as input instead of Integer[]

0 Answers
Related