question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid query generated for object as GraphQL function parameter

See original GitHub issue

Description

I am using Hasura and am trying to run the following query:

query {
  test_table(where: { id: { _eq: 1 } }) {
    id
    some_name
  }
}

According to Hasura logs, the actual query that is sent to the server has id and _eq wrapped in escaped quotes, which fails validation:

query {
  test_table(where: { \"id\": { \"_eq\": 1 } }) {
    id
    some_name
    __typename
  }
  __typename
}

NOTE: The query works perfectly without parameters, or if sending a multiple “simple” parameters (rather than a nested object), such as: test_table(limit: 1, offset: 1)

Repro steps

Following the readme, I create the provider, operation and run try to run the query:

type MyProvider = GraphQLProvider<"http://localhost:8080/v1/graphql">

let operation =
    MyProvider.Operation<"""query q {
      test_table(where: { id: { _eq: 1 } }) {
        id
        some_name
      }
    }""">()

let runtimeContext =
  { ServerUrl = "http://localhost:8080/v1/graphql"
    HttpHeaders = [] }

let result = Commands.operation.Run(runtimeContext)

Expected behavior

The query sent to the server should not contain \" wrapped around id and eq.

Actual behavior

The query sent to the server has \" wrapped around id and eq, which results in an invalid query and an error.

Known workarounds

I was searching for workarounds and found this page in the docs that has an example using GraphQL query DSL, but it seems that .Queries does not exist on GraphQLProvider. Has this been deprecated? Are the docs outdated?

Related information

Mac OS X v1.0.2 Both in a .NET Core 3.1 console app, as well as Xamarin with Fabulous

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
johnberzy-bazingacommented, Mar 22, 2020

@Yakimych Sorry for the delay. Can you open another issue with some additional information.

Thanks

1reaction
johnberzy-bazingacommented, Mar 3, 2020

@Yakimych This should be fixed with the latest release. Please let me know if you have any issues.

Thanks

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - graphQl - Argument has invalid value Expected ...
The error suggests that the query parameter you have to pass in is not supposed to be a simple scalar string type. –...
Read more >
Error handling - Apollo GraphQL Docs
The GraphQL operation includes an invalid value for a field argument. PERSISTED_QUERY_NOT_FOUND. A client sent the hash of a query string to execute...
Read more >
Passing Arguments
A query language for your API — GraphQL provides a complete description of the data in your API, gives clients the power to...
Read more >
Errors | urql Documentation
Invalid Object type: The type ??? is not an object in the defined schema, but the GraphQL document is traversing it. When you're...
Read more >
GraphQL error handling to the max with Typescript, codegen ...
Then, we define the query result as a Union type of the expected ... will use this type resolver to generate the proper...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found