Skip to content

Commit

Permalink
[B] Inline pageTree query instead of using fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
Blake Mason authored and blnkt committed Apr 22, 2024
1 parent 7cac517 commit 8aacc50
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 25 deletions.
18 changes: 0 additions & 18 deletions lib/api/fragments/global.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down
59 changes: 52 additions & 7 deletions lib/api/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -14,7 +13,6 @@ import { userProfileFragment } from "@/lib/api/fragments/page";
export async function getGlobalData() {
const query = gql`
${linkFragment}
${pageTreeFragment}
${siteInfoFragment}
${footerFragment}
${rootPageInfoFragment}
Expand All @@ -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
Expand All @@ -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
Expand All @@ -71,7 +93,6 @@ export async function getGlobalData() {
export function useGlobalData() {
const { data, error } = useSWR(
gql`
${pageTreeFragment}
${linkFragment}
${siteInfoFragment}
${footerFragment}
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 8aacc50

Please sign in to comment.