Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[B] Inline pageTree query instead of using fragment #428

Merged
merged 1 commit into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading