Skip to content

Commit

Permalink
fix: patch GraphQL Playground's tooltips issue (#4272)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrians5j authored Sep 23, 2024
1 parent 342d430 commit 07582e3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/app-graphql-playground/src/plugins/Playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { config as appConfig } from "@webiny/app/config";
import ApolloClient from "apollo-client";
import { GraphQLPlaygroundTabPlugin } from "~/types";
import { SecurityIdentity } from "@webiny/app-security/types";
import { ORIGINAL_GQL_PLAYGROUND_URL, PATCHED_GQL_PLAYGROUND_URL } from "./constants";

const withHeaders = (link: ApolloLink, headers: Record<string, string>): ApolloLink => {
return ApolloLink.from([
Expand All @@ -39,16 +40,20 @@ const initScripts = () => {
return resolve();
}

return loadScript(
"https://cdn.jsdelivr.net/npm/@apollographql/[email protected]/build/static/js/middleware.js",
resolve
);
loadScript(PATCHED_GQL_PLAYGROUND_URL, (err: Error) => {
if (err) {
return loadScript(ORIGINAL_GQL_PLAYGROUND_URL, resolve);
}

resolve();
});
});
};

interface CreateApolloClientParams {
uri: string;
}

interface PlaygroundProps {
createApolloClient: (params: CreateApolloClientParams) => ApolloClient<any>;
}
Expand All @@ -57,9 +62,11 @@ interface CreateApolloLinkCallableParams {
endpoint: string;
headers: Record<string, string>;
}

interface CreateApolloLinkCallableResult {
link: ApolloLink;
}

interface CreateApolloLinkCallable {
(params: CreateApolloLinkCallableParams): CreateApolloLinkCallableResult;
}
Expand Down
5 changes: 5 additions & 0 deletions packages/app-graphql-playground/src/plugins/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export const ORIGINAL_GQL_PLAYGROUND_URL =
"https://cdn.jsdelivr.net/npm/@apollographql/[email protected]/build/static/js/middleware.js";

export const PATCHED_GQL_PLAYGROUND_URL =
"https://webiny-public.s3.us-east-2.amazonaws.com/project-scripts/gql-playground-mw-1.7.42-patched.js";

0 comments on commit 07582e3

Please sign in to comment.