Giter Site home page Giter Site logo

Comments (7)

hlship avatar hlship commented on June 3, 2024

In our grammar, query is a reserved word. I'll check the spec to see if there's anything similar. If not, we'll have to figure out how to convince the parser to accept the value there.

By "not working" do you mean that you get an exception or a parse error, or what?

from lacinia.

hlship avatar hlship commented on June 3, 2024
clojure.lang.ExceptionInfo: Failed to parse GraphQL query.
                            clojure.core/eval    core.clj: 3105
                                          ...                  
                                user/eval6250   REPL Input     
   com.walmartlabs.lacinia.parser/parse-query  parser.clj: 1221
   com.walmartlabs.lacinia.parser/parse-query  parser.clj: 1227
com.walmartlabs.lacinia.parser/parse-query/fn  parser.clj: 1231
                         clojure.core/ex-info    core.clj: 4617
clojure.lang.ExceptionInfo: Failed to parse GraphQL query.
    errors: ({:location {:line 1, :column nil},
              :parse-error "mismatched input 'query' expecting Name"}
             {:location {:line 1, :column nil},
              :parse-error "mismatched input ':' expecting {'(', '{', '@', Name}"}
             {:location {:line 1, :column nil},
              :parse-error
              "extraneous input '}' expecting {<EOF>, 'query', 'mutation', 'subscription', '{', 'fragment'}"})

from lacinia.

stijnopheide avatar stijnopheide commented on June 3, 2024

yes, that's exactly the exception we see.

Also, the workaround is easy, just use another name for the argument. Maybe a mention in the documentation about reserved words can avoid confusion for other users for now?

from lacinia.

hlship avatar hlship commented on June 3, 2024

True, I'd like to test this against the reference implementation to see if it can accept it.

from lacinia.

stijnopheide avatar stijnopheide commented on June 3, 2024

There is another use case in which you will get this exception and this when the query sent by the client will use the word 'query' anywhere in the input objects.

e.g.
query DoQuery($query: String) {someQuery(q: $query) {result}}
and the input to that query
{"query": "lalala"}

This is I think more problematic because it has nothing to do with the schema and from the clients' perspective the error message is very confusing.

from lacinia.

hlship avatar hlship commented on June 3, 2024

Just checked against the RI:

var { graphql, buildSchema } = require('graphql');

var schema = buildSchema(`
  type Query {
    query: String
  }
`);

var root = { query: () => 'Hello world!' };

graphql(schema, '{ query }', root).then((response) => {
  console.log(response);
});

... and this works as expected. So query is only a "reserved word" when it appears in that location. I'll have to do some work to figure out how to make this work correctly in Antlr.

from lacinia.

hlship avatar hlship commented on June 3, 2024

This one is turning out to be a disproportionate amount of work vs. reward.

from lacinia.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.