Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass json object as string #10

Open
draak-krijger opened this issue Apr 9, 2020 · 2 comments
Open

pass json object as string #10

draak-krijger opened this issue Apr 9, 2020 · 2 comments

Comments

@draak-krijger
Copy link

I tried to pass a JSON object as a string through mutation. I'm getting the following error and couldn't manage to fix it,
error: Body: {"errors":[{"message":"Syntax error","locations":[{"line":2,"column":159}],"extensions":{"name":"GraphQLError","time_thrown":"2020-04-09T19:51:20.587Z"}}]}

my code is,

mutation = GQLi::DSL.mutation {
        callConnector(input: {
          connector: "outreach",
          version: "2.8",
          operation: "list_mailboxes",
          authId: "auth_id",
          input: "{\"per_page\":100,\"page\":1,\"sort\":{\"direction\":\"asc\"}}"
        }) {
          output
        }
      }
response = client.execute!(mutation)
response.query.to_gql

It throws error because of stringify JSON value of input field.

I would love some advice about how to properly pass in a JSON string as a query argument.
Thanks!

@dlitvakb
Copy link
Contributor

Hey @draak-krijger,

Looks like you may need to wrap your JSON in an extra set of "" as is most likely hitting the API as a nested GraphQL query, rather than a stringified JSON.

Cheers

@draak-krijger
Copy link
Author

Hey @dlitvakb,

Thanks for your reply! I'm not sure about the format you mentioned. An example would be helpful.

I tried something by changing the input field value in the following way but didn't work.

input: """{"per_page":100,"page":1,"sort":{"direction":"asc"}}"""

btw, API endpoint expects the field value as JSON.

Thanks In Advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants