Search code examples
graphqlgraphql-java

how to send array of strings as argument in graphql query


I'm trying to send array of strings as a query to my springboot based server,but the following query does not work ExecutionResult execute = graphQLService.getGraphQL().execute("{my_func{my_var:[\"abc\"]}{my_var2}}"); here is my schema file

schema {
   query: Query
   mutation: Mutation
 }

type Query {
   my_func(
     my_var: [String]
        ) : [object]
 }

type object{
    my_var: String,
    my_var2: String,
 }

this is the error

Query failed to parse : '{my_func{my_var:["abc"}]}{my_var2}}' 

Solution

  • The syntax of your query is not correct . It should be :

    {
      my_func (my_var:["abc"]) {
        my_var2
      }
    }
    

    You should use round brackets () instead of curly brackets {} for specifying the field argument in the query.