From 012438c7f6de790c03d56973044b249e2f02284d Mon Sep 17 00:00:00 2001 From: Blake Mason Date: Mon, 22 Apr 2024 10:08:02 -0700 Subject: [PATCH] [B] Inline pageTree query instead of using fragment --- lib/api/fragments/global.js | 18 ----------- lib/api/global.js | 59 ++++++++++++++++++++++++++++++++----- 2 files changed, 52 insertions(+), 25 deletions(-) diff --git a/lib/api/fragments/global.js b/lib/api/fragments/global.js index efd995e9..eff9010b 100644 --- a/lib/api/fragments/global.js +++ b/lib/api/fragments/global.js @@ -1,23 +1,5 @@ import { getImageFields } from "@/lib/api/fragments/image"; -export const pageTreeFragment = ` -fragment pageTreeFragment on EntryInterface { - id - title - uri - children(isVisible: true) { - id - title - uri - children(isVisible: true) { - id - title - uri - } - } -} -`; - export const siteInfoFragment = ` fragment siteInfoFragment on siteInfo_GlobalSet { language diff --git a/lib/api/global.js b/lib/api/global.js index e430d348..b2e73713 100644 --- a/lib/api/global.js +++ b/lib/api/global.js @@ -3,7 +3,6 @@ import { gql } from "graphql-request"; import { queryAPI } from "@/lib/fetch"; import { linkFragment } from "@/lib/api/fragments/link"; import { - pageTreeFragment, siteInfoFragment, footerFragment, rootPageInfoFragment, @@ -14,7 +13,6 @@ import { userProfileFragment } from "@/lib/api/fragments/page"; export async function getGlobalData() { const query = gql` ${linkFragment} - ${pageTreeFragment} ${siteInfoFragment} ${footerFragment} ${rootPageInfoFragment} @@ -28,7 +26,19 @@ export async function getGlobalData() { level: 1 isVisible: true ) { - ...pageTreeFragment + id + title + uri + children(isVisible: true) { + id + title + uri + children(isVisible: true) { + id + title + uri + } + } } globals: globalSets(site: "default") { ...rootPageInfoFragment @@ -48,7 +58,19 @@ export async function getGlobalData() { level: 1 isVisible: true ) { - ...pageTreeFragment + id + title + uri + children(isVisible: true) { + id + title + uri + children(isVisible: true) { + id + title + uri + } + } } globals_es: globalSets(site: "es") { ...rootPageInfoFragment @@ -71,7 +93,6 @@ export async function getGlobalData() { export function useGlobalData() { const { data, error } = useSWR( gql` - ${pageTreeFragment} ${linkFragment} ${siteInfoFragment} ${footerFragment} @@ -83,7 +104,19 @@ export function useGlobalData() { level: 1 isVisible: true ) { - ...pageTreeFragment + id + title + uri + children(isVisible: true) { + id + title + uri + children(isVisible: true) { + id + title + uri + } + } } globals: globalSets(site: "default") { ...siteInfoFragment @@ -98,7 +131,19 @@ export function useGlobalData() { level: 1 isVisible: true ) { - ...pageTreeFragment + id + title + uri + children(isVisible: true) { + id + title + uri + children(isVisible: true) { + id + title + uri + } + } } globals_es: globalSets(site: "es") { ...siteInfoFragment