Fix the API URL construction (#3142)
This commit is contained in:
parent
696aeb7010
commit
6cdf378532
1 changed files with 16 additions and 16 deletions
|
@ -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();
|
};
|
||||||
};
|
|
||||||
|
|
Loading…
Reference in a new issue