Sumchans
Sumchans

Reputation: 3774

graphql query throws expected argument name exception in flutter

What could be wrong in the below query, I get an Expected argument name error when I execute the query inside of Flutter. I tried another query which does not take any arguments which worked but not this one. Here is the post that I created in github regarding the same issue - https://github.com/zino-hofmann/graphql-flutter/discussions/1326

const String findContacts = r''' {
  query GetContacts($contacts:[String]){
    findContacts(contacts:$contacts) {
      status
      error
      users {
          id
          userPhoneNumber
          userDisplayName
      }
    }
  }
}
''';

Here is my schema -

type_defs = gql("""
    type Query {
        findContacts(contacts: [String]): Result!
    }


    type User {
        id: ID!
        partitionKey: String 
        userPhoneNumber: ID      
        userDisplayName: String
        avatarUrl: String
        createdAt: String 
        updatedAt: String
        userStatus: String
        userCustomMessage: String
    } 

    type Result {
        status: Int
        error: String
        user: User
        users: [User]
    }
""")

Upvotes: 0

Views: 291

Answers (1)

Sumchans
Sumchans

Reputation: 3774

This worked for me by setting setting the findContacts like below -

const String findContacts = """
  query(\$contacts:[String]) {
    findContactsOnBol(contacts:\$contacts) {
      status
      error
      users {
          id
          userPhoneNumber
          userDisplayName
      }
    }
  }
""";

Upvotes: 0

Related Questions