From ef6e8b18b27b1f93502f7a78b32d4f48fc513a34 Mon Sep 17 00:00:00 2001 From: Grace Date: Fri, 1 Dec 2023 11:48:41 +0000 Subject: [PATCH 1/5] Add perspective param to query url --- src/common/sanity.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/common/sanity.ts b/src/common/sanity.ts index 99f7b3330..9e9e18569 100644 --- a/src/common/sanity.ts +++ b/src/common/sanity.ts @@ -88,10 +88,11 @@ export const sanityLanguageId = (locale: string): string => { }; export const project = "ajwvhvgo"; -export const dataset = flags.cmsPreview ? "apps-preview" : "apps"; +export const dataset = "apps-preview"; +const perspective = flags.cmsPreview ? "previewDrafts" : "published"; const queryUrl = (query: string): string => { - return `https://${project}.apicdn.sanity.io/v1/data/query/${dataset}?query=${encodeURIComponent( + return `https://${project}.api.sanity.io/v2023-08-01/data/query/${dataset}?perspective=${perspective}&query=${encodeURIComponent( query )}`; }; From 6b7b0b4649cb0ff38cfefd2619cd25b81f1c83c1 Mon Sep 17 00:00:00 2001 From: Grace Date: Fri, 1 Dec 2023 11:49:13 +0000 Subject: [PATCH 2/5] Remove draft filter in query --- src/documentation/ideas/content.ts | 2 +- src/documentation/mapping/content.ts | 2 +- src/documentation/reference/content.ts | 2 +- src/workbench/WelcomeDialog.tsx | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/documentation/ideas/content.ts b/src/documentation/ideas/content.ts index 6721735c1..3b2537bff 100644 --- a/src/documentation/ideas/content.ts +++ b/src/documentation/ideas/content.ts @@ -11,7 +11,7 @@ export const fetchIdeas = async (languageId: string): Promise => const ideasQuery = (languageId: string): string => { return ` - *[_type == "pythonIdeasConfig" && language == "${languageId}" && !(_id in path("drafts.**"))][0]{ + *[_type == "pythonIdeasConfig" && language == "${languageId}"][0]{ pythonIdeasOrder[]->{ _id, name, language, compatibility, image, slug, content[] { diff --git a/src/documentation/mapping/content.ts b/src/documentation/mapping/content.ts index 914250bbe..7fe43ab45 100644 --- a/src/documentation/mapping/content.ts +++ b/src/documentation/mapping/content.ts @@ -11,7 +11,7 @@ export const fetchMappingData = async (): Promise => const mappingQuery = (): string => { return ` - *[_type == "pythonModule" && !(_id in path("drafts.**"))]{ + *[_type == "pythonModule"]{ pythonModuleName, pythonModuleItem[] { pythonAlternativeContentLink, diff --git a/src/documentation/reference/content.ts b/src/documentation/reference/content.ts index 015b77e92..20780d089 100644 --- a/src/documentation/reference/content.ts +++ b/src/documentation/reference/content.ts @@ -33,7 +33,7 @@ export const getTopicAndEntry = ( // This is necessary for the client-side search index. const toolkitQuery = (languageId: string): string => { return ` - *[_type == "toolkit" && language == "${languageId}" && (slug.current == "explore" || slug.current == "reference") && !(_id in path("drafts.**"))]{ + *[_type == "toolkit" && language == "${languageId}" && (slug.current == "explore" || slug.current == "reference")]{ id, name, description, language, contents[]->{ name, slug, compatibility, subtitle, image, diff --git a/src/workbench/WelcomeDialog.tsx b/src/workbench/WelcomeDialog.tsx index 4de16c5ea..b03b0771c 100644 --- a/src/workbench/WelcomeDialog.tsx +++ b/src/workbench/WelcomeDialog.tsx @@ -42,7 +42,7 @@ const WelcomeDialog = ({ isOpen, onClose }: WelcomeDialogProps) => { }; const query = (): string => { return ` - *[_id == "pythonEditorConfig" && !(_id in path("drafts.**"))]{ + *[_id == "pythonEditorConfig"]{ welcomeVideo }`; }; From ed53959a4e6e7b3c6136b329ce62abea260508c2 Mon Sep 17 00:00:00 2001 From: Grace Date: Fri, 1 Dec 2023 12:11:55 +0000 Subject: [PATCH 3/5] Revert dataset logic --- src/common/sanity.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/sanity.ts b/src/common/sanity.ts index 9e9e18569..52dff7d20 100644 --- a/src/common/sanity.ts +++ b/src/common/sanity.ts @@ -88,7 +88,7 @@ export const sanityLanguageId = (locale: string): string => { }; export const project = "ajwvhvgo"; -export const dataset = "apps-preview"; +export const dataset = flags.cmsPreview ? "apps-preview" : "apps"; const perspective = flags.cmsPreview ? "previewDrafts" : "published"; const queryUrl = (query: string): string => { From 3a7816071be87697a3738fd8ba62b39a5ca889e9 Mon Sep 17 00:00:00 2001 From: Grace Date: Fri, 1 Dec 2023 13:37:44 +0000 Subject: [PATCH 4/5] Parameterise api vs apicdn in sanity query url --- src/common/sanity.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/common/sanity.ts b/src/common/sanity.ts index 52dff7d20..8bea07f5e 100644 --- a/src/common/sanity.ts +++ b/src/common/sanity.ts @@ -92,7 +92,9 @@ export const dataset = flags.cmsPreview ? "apps-preview" : "apps"; const perspective = flags.cmsPreview ? "previewDrafts" : "published"; const queryUrl = (query: string): string => { - return `https://${project}.api.sanity.io/v2023-08-01/data/query/${dataset}?perspective=${perspective}&query=${encodeURIComponent( + return `https://${project}.${ + flags.cmsPreview ? "api" : "apicdn" + }.sanity.io/v2023-08-01/data/query/${dataset}?perspective=${perspective}&query=${encodeURIComponent( query )}`; }; From 74b8999b736944302fd67ebb2a6ae606bd6c0a5e Mon Sep 17 00:00:00 2001 From: Grace Date: Fri, 1 Dec 2023 14:06:25 +0000 Subject: [PATCH 5/5] Fix mapping query for v2021-03-25 --- src/common/sanity.ts | 2 +- src/documentation/mapping/content.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/common/sanity.ts b/src/common/sanity.ts index 8bea07f5e..9c36fda45 100644 --- a/src/common/sanity.ts +++ b/src/common/sanity.ts @@ -94,7 +94,7 @@ const perspective = flags.cmsPreview ? "previewDrafts" : "published"; const queryUrl = (query: string): string => { return `https://${project}.${ flags.cmsPreview ? "api" : "apicdn" - }.sanity.io/v2023-08-01/data/query/${dataset}?perspective=${perspective}&query=${encodeURIComponent( + }.sanity.io/v2021-03-25/data/query/${dataset}?perspective=${perspective}&query=${encodeURIComponent( query )}`; }; diff --git a/src/documentation/mapping/content.ts b/src/documentation/mapping/content.ts index 7fe43ab45..77566380c 100644 --- a/src/documentation/mapping/content.ts +++ b/src/documentation/mapping/content.ts @@ -17,7 +17,7 @@ const mappingQuery = (): string => { pythonAlternativeContentLink, pythonApiEntry, referenceLink { - _type == "reference" =>^-> { + _type == "reference" =>@-> { slug } }