Skip to content

@apollographql/graphql-playground-html generates incorrect links if you pass a falsey version #4937

@silenaker

Description

@silenaker

1.6.26 has a problem, that is
if you don't want a fixed version number and set version option to "", you will get a wrong url

const apolloServer = new ApolloServer({
  schema,
  context: fastify,
  playground: {
    version: "",
    cdnUrl: "",
    settings: {
      "editor.theme": "light",
    },
  },
});

fastify.register(fastifyStatic, {
  root: path.join(__dirname, "../node_modules/@apollographql/graphql-playground-react/"),
  prefix: "/@apollographql/graphql-playground-react/"
});

will contribute to

<link rel="stylesheet" href="/@apollographql/graphql-playground-reactbuild/static/css/index.css">

I found a workaround for the moment,you must set the version option and set route correctly

const apolloServer = new ApolloServer({
  schema,
  context: fastify,
  playground: {
    version: "1.6.26", // must set version
    cdnUrl: "",
    settings: {
      "editor.theme": "light",
    },
  },
});

fastify.register(fastifyStatic, {
  root: path.join(__dirname, "../node_modules/@apollographql/graphql-playground-react/"),
  prefix: "/@apollographql/[email protected]/", // must use corresponding version
});

1.6.29 has fixed this bug

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions