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";
export type EditorContent = Record<keyof typeof longKeysToShortKeys, string>;
type ShorterEditorContent = Record<
typeof longKeysToShortKeys[keyof typeof longKeysToShortKeys],
(typeof longKeysToShortKeys)[keyof typeof longKeysToShortKeys],
string
>;
@ -46,13 +47,12 @@ interface PlaygroundOpenHandlerInput {
variables: string;
}
export const playgroundOpenHandler = ({
query,
headers,
operationName,
variables,
}: PlaygroundOpenHandlerInput) => () => {
const playgroundURL = new URL(process.env.API_URI);
const thisURL = new URL(getApiUrl(), window.location.origin).href;
export const playgroundOpenHandler =
({ query, headers, operationName, variables }: PlaygroundOpenHandlerInput) =>
() => {
const playgroundURL = new URL(thisURL);
playgroundURL.hash = encodeGraphQLStatement({
query,
headers,
@ -60,4 +60,4 @@ export const playgroundOpenHandler = ({
variables,
});
window.open(playgroundURL, "_blank").focus();
};
};