graphiql icon indicating copy to clipboard operation
graphiql copied to clipboard

[graphiql] Playground doesn't work

Open Trsa993 opened this issue 5 months ago • 13 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

Current Behavior

Hello,

With the latest commit, playground doesn't work anymore with spring-boot-starter-graphql-3.4.x

Image

Image

Expected Behavior

No response

Steps To Reproduce

No response

Environment

  • GraphiQL Version:
  • OS:
  • Browser:
  • Bundler:
  • react Version:
  • graphql Version:

Anything else?

No response

Trsa993 avatar Jun 24 '25 08:06 Trsa993

The new GraphiQL just released, you should either pin to v4 or update to ne esm based cdn https://github.com/graphql/graphiql/blob/main/docs/migration/graphiql-5.0.0.md

dimaMachina avatar Jun 24 '25 09:06 dimaMachina

The new GraphiQL just released, you should either pin to v4 or update to ne esm based cdn https://github.com/graphql/graphiql/blob/main/docs/migration/graphiql-5.0.0.md

Actually I can't choose any version. I am using the file inside spring-boot-starter-graphql-3.4.5. I think I will wait for these.

thedemircan avatar Jun 24 '25 09:06 thedemircan

experiencing similar issue

haroldsphinx avatar Jun 24 '25 12:06 haroldsphinx

Feel free to ping your repository maintainers to update graphiql UMD link, to point to v4

-https://unpkg.com/graphiql/dist/index.umd.js
+https://unpkg.com/[email protected]/dist/index.umd.js

Alternatively you can suggest them to use ESM based CDN with new GraphiQL 5, see official example

dimaMachina avatar Jun 24 '25 12:06 dimaMachina

Feel free to ping your repository maintainers to update graphiql UMD link, to point to v4

-https://unpkg.com/graphiql/dist/index.umd.js +https://unpkg.com/[email protected]/dist/index.umd.js Alternatively you can suggest them to use ESM based CDN with new GraphiQL 5, see official example

We are repointing to https://unpkg.com/[email protected]/dist/index.umd.js since we are not yet ready to ugrade to v5. Will that [email protected] UMD continue to be available in the foreseeable future?

maronavenue avatar Jun 24 '25 16:06 maronavenue

You can find the solution to this. #https://github.com/graphql/graphiql/issues/4033#issuecomment-3001804909

thedemircan avatar Jun 24 '25 20:06 thedemircan

is getting a 404 from https://unpkg.com/graphiql/graphiql.min.js the same problem

SimonCropp avatar Jun 24 '25 23:06 SimonCropp

What I did was a workaround to fix this issue (until spring-boot-starter-graphql updates their side) I manually provided a local version of the Graphiql by serving it as a static file:

1 - Create the folder structure src/main/resources/static/graphiql 2 - Create an index.html file with this content :

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>GraphiQL</title>
    <link rel="stylesheet" href="https://unpkg.com/[email protected]/graphiql.min.css" />

</head>
<body style="margin: 0;">
<div id="graphiql" style="height: 100vh;"></div>
<script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
<script crossorigin src="https://unpkg.com/[email protected]/graphiql.min.js"></script>
<script>
    const graphQLFetcher = (graphQLParams, options) => {
        const headers = options?.headers || {};
        return fetch('/graphql', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                ...headers
            },
            body: JSON.stringify(graphQLParams),
        }).then(response => response.json());
    };

    ReactDOM.render(
        React.createElement(GraphiQL, {
            fetcher: graphQLFetcher,
            headersEditorEnabled: true
        }),
        document.getElementById('graphiql'),
    );
</script>
</body>
</html>

You can change the version of [email protected] as needed.

3- Call it on: http://localhost:8080/graphiql/index.html

mvgmenezes avatar Jun 25 '25 16:06 mvgmenezes

I upgraded spring boot to 3.5.3 and it is working, but be careful if you do that, some dependancies might be broken, especially if you use spring cloud, I spent some time resolving it.

Trsa993 avatar Jun 25 '25 16:06 Trsa993

Note: the unpkg issue also affects graphiql's own live demo page. Image

MrOrz avatar Jun 28 '25 05:06 MrOrz

The Live demo at https://graphql.github.io/swapi-graphql/ , e.g. as linked from https://github.com/graphql/graphiql/blob/main/README.md#graphiql and https://github.com/graphql/graphiql/blob/main/packages/graphiql/README.md#graphiql , fails with errors such as:

Image

gjvoosten avatar Jul 10 '25 11:07 gjvoosten

We have the same issue. This is breaking production env, please find a solution for this to work or revert!

Natanhel avatar Jul 15 '25 12:07 Natanhel

We have the same issue. This is breaking production env, please find a solution for this to work or revert!

pin your UMD CDN graphiql version to v4, or use ESM based CDN https://github.com/graphql/graphiql/tree/main/examples/graphiql-cdn for graphiql v5

dimaMachina avatar Jul 15 '25 12:07 dimaMachina