Closed duncan-bayne closed 5 years ago
I wonder whether this is related to https://github.com/luminus-framework/luminus-template/issues/214? I don't think so, though, because it happens on a fresh run of lein run
, and on a fresh production deployment.
Hmm, have you tried using the built in test page http://localhost:3000/graphiql
. I tried the following query from there:
query {
hero {name}
}
and I see the following result as expected:
{
"data": {
"hero": {
"name": "Luke"
}
}
}
As a note, there's an older version 0.28.0
of Lacinia packaged with the template, I've just bumped up to the latest `0.32.0.
Ah! Got it. Working back from your example, the cause was a missing header:
$ curl 'http://localhost:3000/api/graphql' -X POST --data '{"query":"{ hero(id: \"1000\") }","variables":{},"operationName":null}'
{"type":"exception","class":"java.io.IOException"}%
$ curl 'http://localhost:3000/api/graphql' -X POST --data '{"query":"{ hero(id: \"1000\") }","variables":{},"operationName":null}' -H 'Content-Type: application/graphql'
{"errors":[{"message":"Failed to parse GraphQL query.","extensions":{"errors":[{"locations":[{"line":1,"column":null}],"message":"mismatched input '\"query\"' expecting {'query', 'mutation', 'subscription', '...', NameId}"},{"locations":[{"line":1,"column":null}],"message":"mismatched input '}' expecting {'query', 'mutation', 'subscription', '...', NameId}"},{"locations":[{"line":1,"column":null}],"message":"extraneous input '\"operationName\"' expecting {<EOF>, 'query', 'mutation', 'subscription', '{', 'fragment'}"}]}}]}%
If you don't specify -H 'Content-Type: application/graphql'
, you get the java.IO.IOException
instead of a sensible error message.
Maybe another mention in the documentation somewhere? Or perhaps this is an upstream bug in lacinia?
Yeah, that sounds like an upstream issue for lacinia, since it's ultimately handling the content type.
I'll raise an issue on lacinia, then, & close this one.
Thanks for all the help, and also, thanks for Luminus! :)
I've created a Luminus 3.25 app with the following invocation:
The app compiles, runs locally, and deploys to Heroku (with a tweak; see #231). However, the GraphQL API seems broken both locally, and in production.
If I POST a valid GraphQL query, the server returns a 500, while internally raising
ERROR todo-list.middleware.exception - UT000034: Stream is closed
. However, if I POST an invalid GraphQL query, it responds as expected.For example:
Relevant excerpt from the log:
It's possible I'm doing something wrong and supplying an invalid or unexpected GraphQL query; this is my first time using GraphQL. Even so, I'd expect some sort of error to that effect (as is provided when no query at all is POSTed).