Comments (7)
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.
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.
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.
True, I'd like to test this against the reference implementation to see if it can accept it.
from lacinia.
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.
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.
This one is turning out to be a disproportionate amount of work vs. reward.
from lacinia.
Related Issues (20)
- icu4j vulnerability HOT 1
- Swallowed unhandled exceptions because of misusage of clojure.core/future HOT 10
- Scalar type which returns vector HOT 4
- ::lacinia/null returned in unions instead of null HOT 1
- Apollo Federation Compatibility HOT 1
- Includes variable-definitions in parsed query HOT 4
- Question: Is there a way to return JSON without a corresponding EDN definition? HOT 3
- Use of executor/selection in streamer functions HOT 1
- Document example of a raw JSON scalar
- cryptic errors when input is the wrong type
- Passing in variables wrapped in an array comes in as a double array HOT 5
- Support @defer and @stream directives
- Convert the keys of arguments and variables to kebab-case HOT 1
- Subscriptions may fail to stream data to the client
- Unbalanced braces in queries not causing parse-query to fail
- Tracing "validation" fields are always null
- Question: Query complexity and depth HOT 2
- Replace antlr4 deps with antlr4-runtime HOT 2
- Issue with merging fragments with list
- Adding support for deprecation on input fields
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lacinia.