Skip to content

Commit d53f1bf

Browse files
authored
Merge branch 'main' into bjoern/cosmo-signup-optimizations
2 parents 608fe29 + 2c44697 commit d53f1bf

1 file changed

Lines changed: 26 additions & 12 deletions

File tree

  • studio/src/pages/[organizationSlug]/[namespace]/graph/[slug]

studio/src/pages/[organizationSlug]/[namespace]/graph/[slug]/playground.tsx

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ import { useToast } from "@/components/ui/use-toast";
5656
import { SubmitHandler, useZodForm } from "@/hooks/use-form";
5757
import { useHydratePlaygroundStateFromUrl } from "@/hooks/use-hydrate-playground-state-from-url";
5858
import { useLocalStorage } from "@/hooks/use-local-storage";
59-
import { PLAYGROUND_DEFAULT_HEADERS_TEMPLATE, PLAYGROUND_DEFAULT_QUERY_TEMPLATE } from "@/lib/constants";
59+
import {
60+
PLAYGROUND_DEFAULT_HEADERS_TEMPLATE,
61+
PLAYGROUND_DEFAULT_QUERY_TEMPLATE,
62+
} from "@/lib/constants";
6063
import { NextPageWithLayout } from "@/lib/page";
6164
import { parseSchema } from "@/lib/schema-helpers";
6265
import { cn } from "@/lib/utils";
@@ -84,13 +87,10 @@ import {
8487
import { sentenceCase } from "change-case";
8588
import crypto from "crypto";
8689
import { GraphiQL } from "graphiql";
87-
import {
88-
GraphQLSchema,
89-
parse,
90-
validate,
91-
} from "graphql";
90+
import { GraphQLSchema, parse, validate } from "graphql";
9291
import { useTheme } from "next-themes";
9392
import { useRouter } from "next/router";
93+
import posthog from "posthog-js";
9494
import { ReactNode, useContext, useEffect, useMemo, useState } from "react";
9595
import { createPortal } from "react-dom";
9696
import { FaNetworkWired } from "react-icons/fa";
@@ -305,6 +305,10 @@ const graphiQLFetch = async (
305305

306306
await executePostScripts(graphId, requestBody, responseData);
307307

308+
posthog.capture("cosmo_studio_query_executed", {
309+
query_success: response.ok && !responseData.errors,
310+
});
311+
308312
onFetch(
309313
await response.clone().json(),
310314
response.status,
@@ -712,8 +716,8 @@ const ConfigSelect = () => {
712716
{type === "featureFlag"
713717
? "Feature flag"
714718
: type === "subgraph"
715-
? "Subgraph"
716-
: "Graph"}{" "}
719+
? "Subgraph"
720+
: "Graph"}{" "}
717721
:
718722
</span>
719723
<Select
@@ -925,7 +929,14 @@ const PlaygroundPage: NextPageWithLayout = () => {
925929
});
926930

927931
const [isHydrated, setIsHydrated] = useState(false);
928-
useHydratePlaygroundStateFromUrl(tabsState, setQuery, setUpdatedVariables, setHeaders, setTabsState, isGraphiqlRendered);
932+
useHydratePlaygroundStateFromUrl(
933+
tabsState,
934+
setQuery,
935+
setUpdatedVariables,
936+
setHeaders,
937+
setTabsState,
938+
isGraphiqlRendered,
939+
);
929940

930941
// eslint-disable-next-line react-hooks/exhaustive-deps
931942
useEffect(() => {
@@ -1253,7 +1264,6 @@ const PlaygroundPage: NextPageWithLayout = () => {
12531264
};
12541265
}, [theme]);
12551266

1256-
12571267
if (!graphContext?.graph) return null;
12581268

12591269
return (
@@ -1289,7 +1299,11 @@ const PlaygroundPage: NextPageWithLayout = () => {
12891299
query={query}
12901300
variables={updatedVariables}
12911301
onEditQuery={setQuery}
1292-
headers={headers === PLAYGROUND_DEFAULT_HEADERS_TEMPLATE ? undefined : headers}
1302+
headers={
1303+
headers === PLAYGROUND_DEFAULT_HEADERS_TEMPLATE
1304+
? undefined
1305+
: headers
1306+
}
12931307
defaultHeaders={PLAYGROUND_DEFAULT_HEADERS_TEMPLATE}
12941308
onEditHeaders={setHeaders}
12951309
plugins={[
@@ -1298,7 +1312,7 @@ const PlaygroundPage: NextPageWithLayout = () => {
12981312
}),
12991313
]}
13001314
// null stops introspection and undefined forces introspection if schema is null
1301-
schema={isLoading ? null : schema ?? undefined}
1315+
schema={isLoading ? null : (schema ?? undefined)}
13021316
onTabChange={setTabsState}
13031317
/>
13041318
{isMounted && <PlaygroundPortal />}

0 commit comments

Comments
 (0)