Fix the API URL construction (#3142)

This commit is contained in:
Jakub Neander 2023-02-09 10:33:02 -05:00 committed by GitHub
parent 696aeb7010
commit 6cdf378532
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,9 +1,10 @@
import { getApiUrl } from "@dashboard/config";
import LzString from "lz-string"; import LzString from "lz-string";
export type EditorContent = Record<keyof typeof longKeysToShortKeys, string>; export type EditorContent = Record<keyof typeof longKeysToShortKeys, string>;
type ShorterEditorContent = Record< type ShorterEditorContent = Record<
typeof longKeysToShortKeys[keyof typeof longKeysToShortKeys], (typeof longKeysToShortKeys)[keyof typeof longKeysToShortKeys],
string string
>; >;
@ -46,18 +47,17 @@ interface PlaygroundOpenHandlerInput {
variables: string; variables: string;
} }
export const playgroundOpenHandler = ({ const thisURL = new URL(getApiUrl(), window.location.origin).href;
query,
headers, export const playgroundOpenHandler =
operationName, ({ query, headers, operationName, variables }: PlaygroundOpenHandlerInput) =>
variables, () => {
}: PlaygroundOpenHandlerInput) => () => { const playgroundURL = new URL(thisURL);
const playgroundURL = new URL(process.env.API_URI); playgroundURL.hash = encodeGraphQLStatement({
playgroundURL.hash = encodeGraphQLStatement({ query,
query, headers,
headers, operationName,
operationName, variables,
variables, });
}); window.open(playgroundURL, "_blank").focus();
window.open(playgroundURL, "_blank").focus(); };
};