teamwalnut / graphql-ppx

GraphQL language primitives for ReScript/ReasonML written in ReasonML
https://graphql-ppx.com
MIT License
258 stars 53 forks source link

Error when using JsonScalar as argument #93

Closed ryyppy closed 4 years ago

ryyppy commented 4 years ago

Hey! I am having troubles using a JsonScalar value with a filter_query parameter inside the graphql statement.

Not sure why this is. Here is the example graphql statement:

module CardsQuery = [%graphql
  {|
  query {
    EventItems(
      filter_query: {featured: { in: true } }) {
      items {
        slug
        content {
          date
          title
          cover_photo
        }
      }
    }
  }
|}
];

Here you can find the graphql_schema.json: https://gist.github.com/ryyppy/34c01942b4bdc8aa9f7a42d171645aae

The error it yields:

Fatal error: exception Graphql_ppx_base__Schema.Invalid_type("Type JsonScalar doesn't have any input fields")

Not sure if this is intentional, or a bug?

jfrolich commented 4 years ago

Hi, which field is the custom scalar? If filter_query is a custom scalar it cannot have subfields right? Perhaps if it's a field containing json data it need to be quoted?

ryyppy commented 4 years ago

filter_query is the custom scalar. In GraphiQL the query works fine, when I try to quote it as a string, the query compiles, but the server does not accept the request because it seems to consume the value in some different way

ryyppy commented 4 years ago

My temporary solution was to parametrize the filter_query as $filter and pass the JSON as a variable. This works for now, but I would rather inline the constant in the query itself

jfrolich commented 4 years ago

Hmm I don't know about this part of the GraphQL spec, so not sure if we differ from the spec atm, but good to look into!

jfrolich commented 4 years ago

This is definitely an issue and it used to work with GraphQL_ppx in earlier versions.

jfrolich commented 4 years ago

Hi @ryyppy, can you check with the latest 1.0 version if it works now? (it should)

ryyppy commented 4 years ago

awesome! thanks for working on this! it will take me some time to test this since i am currently busy, i will report back if there are any further issues when i am back at this particular project