Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make_graphiql_handler doesn't support named queries #22

Open
jmurrayufo opened this issue Oct 6, 2021 · 0 comments
Open

make_graphiql_handler doesn't support named queries #22

jmurrayufo opened this issue Oct 6, 2021 · 0 comments

Comments

@jmurrayufo
Copy link

jmurrayufo commented Oct 6, 2021

Recently switched over to running Starlette to get working subscriptions, but I've run into a very strange bug.

Versions:

  • starlette==0.14.2
  • starlette-graphene3==0.5.1
  • graphene==3.0b8
  • graphql-core==3.1.6
  • graphql-relay==3.1.0

Running our app as follows

app = Starlette()
schema = graphene.Schema(
    query=Query,
    mutation=Mutation,
    subscription=Subscription,
    auto_camelcase=False,
)

app.mount("/", GraphQLApp(schema, on_get=make_graphiql_handler()))

if __name__ == "__main__":

    uvicorn.run(app, host="0.0.0.0", port=8000)

Expected behavior:

Running the following in GraphiQL works:

{
  star {
    id
  }
}

This works as well:

query {
  star {
    id
  }
}

This fails:

query name1 {
  star {
    id
  }
}


query name2 {
  star {
    id
  }
}

With the following error:

Syntax Error GraphQL (1:1) Unexpected <EOF>

1: 
   ^

I can also see similar errors given this input:

query {
  star {
    id
  }
}


query name2 {
  star {
    id
  }
}

Which results in

{
  "data": null,
  "errors": [
    {
      "message": "This anonymous operation must be the only defined operation.",
      "locations": [
        {
          "line": 1,
          "column": 1
        }
      ],
      "path": null
    }
  ]
}

I do note a few odd behaviors here.

  • Refreshing the page should preserve the queries, it doesn't and gives me a fresh welcome screen or an incorrectly edited version of the query.
  • Naming queries at all seems unsupported, but other instances of GraphiQL seem to support this without issue.
  • The GraphiQL playground handler supports named queries without issue.
  • No change to code base, this is all working correctly with starlette's provided GUI client. But release notes indicate that this support is deprecated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant