graphql-mesh icon indicating copy to clipboard operation
graphql-mesh copied to clipboard

GraphiQL doesn't load documents (example queries) anymore (cli v0.64.0)

Open JustusNBB opened this issue 2 years ago • 6 comments

Describe the bug

When pressing "Play" in the GraphiQL Playground after mesh:start, it throws/shows

{  "errors": "Syntax Error: Unexpected <EOF>.\n\nGraphQL request:1:1\n1 |\n  | ^"}

To Reproduce Steps to reproduce the behavior: Any sandbox with example queries should do: e.g. JavaScript Wiki Example Sandbox

Expected behavior

It should run the default query (or select an example query) when pressing "Play"

Environment:

  • OS: irrelevant Sandbox
  • @graphql-mesh/cli: 0.63.0/0.64.0
  • NodeJS: 14/16

Additional context

It seems to be a new GraphiQL version, probably its config changed a bit(?).

JustusNBB avatar Mar 22 '22 14:03 JustusNBB

@JustusNBB I'm not able to reproduce this in the sandbox you linked to, perhaps this issue was addressed in the guild's fork of graphiql? would like to know how to address it in graphiql as well

acao avatar May 12 '22 07:05 acao

@JustusNBB I'm not able to reproduce this in the sandbox you linked to, perhaps this issue was addressed in the guild's fork of graphiql? would like to know how to address it in graphiql as well

Can you please be more specific? When I open the sandbox I still get the error (mesh-cli is version 0.70.2 now). I don't think https://github.com/graphql/graphiql/issues/2399 is really related either, because it has a query and this is just about the preconfigured example queries having dissappeard.

image

documents:
  - example-queries/*.graphql

Documents are not loaded. It should allow two run the two queries in that folder. E.g. here <untitled> should be viewsInPastMonth or views-in-past-month.graphql, and there should be a second tab in GraphiQL for the second query (wikipedia-metrics).

JustusNBB avatar May 13 '22 09:05 JustusNBB

@TuvalSimha @dotansimha Is it intended to start without the example queries in new playground tabs?

Querying does still work when using a query from the explorer (e.g.viewsInPastMonth), so this is not about querying somehow being broken.

the guild's fork of graphiql

Is there such a thing? That would explain why I don't recognise GraphiQL anymore. The tabs (which are empty instead of containing the example queries) look like they are from the Apollo Playground instead(?!).

At the beginning when I started, I could not decide between the playgrounds, that's why I have both GraphiQL as well as Apollo. The latter still works as expected, it is configured like this:

const { schema, meshContext } = await getBuiltMesh();

  const apolloServer = new ApolloServer({
    schema,
    context: meshContext,
    plugins: [
      ApolloServerPluginLandingPageGraphQLPlayground({
        tabs: [
          {
            endpoint: '/graphql',
            query: readFileSync(join(__dirname, './src/queries/productprice.example.graphql'), 'utf-8'),
          },
        ],
      })
    ]
  });

Please explain further plans for GraphiQL within GraphQL Mesh!

JustusNBB avatar May 13 '22 10:05 JustusNBB

Bump, please give me a hint how I can help here?

JustusNBB avatar Jul 11 '22 13:07 JustusNBB

This is not an issue with GraphiQL. We stopped showing concatenated version of all defined operations in GraphiQL because it causes performance issues if you have too many operations.

ardatan avatar Jul 11 '22 15:07 ardatan

This is not an issue with GraphiQL. We stopped showing concatenated version of all defined operations in GraphiQL because it causes performance issues if you have too many operations.

Ok makes sense, the preconfigured default query/queries should not be hundreds of lines... But how do I preconfigure any query for the graphiql playground now? https://www.graphql-config.com/docs/user/user-documents I can't find my (example) queries in the explorer or schema either.

Can you give a reference to the referred code change please @ardatan, I'd like to have a look, maybe I have an idea to just impose arbitrary limits for query tabs (graphiql has new tabs right?), so existing document definitions will be shown again if not too long...

JustusNBB avatar Jul 12 '22 10:07 JustusNBB

Seems this has been implemented/fixed again, as I now have a Tab with my Example Query within GraphiQL? (cli v77)

JustusNBB avatar Sep 05 '22 11:09 JustusNBB

Sorry for the misleading report, but that could also be the reason why it was/is difficult to reproduce - GraphiQL caches queries, so when you reopen with a query in the browser cache, it will be shown when reopening GraphiQL the next time.

The original issue persists, when I open the GraphiQL playground mesh dev (v0.77) inside an anonymous tab, there is no example query preconfigured. Please reopen.

JustusNBB avatar Sep 09 '22 11:09 JustusNBB

The original issue persists, when I open the GraphiQL playground inside an anonymous tab, there is no example query preconfigured.

This is not an issue. It's been removed because it causes issues when a project has too many documents defined.

ardatan avatar Sep 09 '22 11:09 ardatan

This is not an issue. It's been removed because it causes issues when a project has too many documents defined.

Then should I request a new feature instead, so I can define those Examples again under a different mesh config instead of considering this a regression (but it is still one for me :()?

What about the idea above to impose arbitrary limits instead?

JustusNBB avatar Sep 09 '22 11:09 JustusNBB

Maybe you can try contributing with a PR?

ardatan avatar Sep 09 '22 11:09 ardatan

Yes that was what I was considering. But since I have redundancy with the Apollo Playground (updated my setup from the current examples), I'll rather be watching how you continue to develop GraphiQL instead of continueing this discussion (and finding arbitray limits that fit everyone, need code and other references...).

JustusNBB avatar Sep 09 '22 11:09 JustusNBB

Another workaround: Append the example query to the graphiql playground url, then it will show that query in the editor - so now example queries can be stored in URLs.

JustusNBB avatar Sep 09 '22 11:09 JustusNBB