Skip to content

Commit

Permalink
Implement Faust’s multiple queries
Browse files Browse the repository at this point in the history
Signed-off-by: Joe Fusco <[email protected]>
  • Loading branch information
josephfusco committed Jan 8, 2024
1 parent 89eda6d commit 79b713a
Showing 1 changed file with 51 additions and 31 deletions.
82 changes: 51 additions & 31 deletions wp-templates/archive-field_type.js
Original file line number Diff line number Diff line change
@@ -1,39 +1,19 @@
import { gql } from '@apollo/client'
import Head from 'next/head'
import { useFaustQuery } from '@faustwp/core';

import { FieldTypesList } from '@/components/FieldTypesList'
import { LayoutArchive } from '@/components/LayoutArchive'

export const ArchiveFieldType = (props) => {
const { data } = props

const { node } = data

if (!node) {
return null
export const GET_LAYOUT_QUERY = gql`
query GetLayout {
...LayoutArchiveFragment
}
${LayoutArchive.fragment}
`;

let toc = []

return (
<>
<Head>
<title>{`${data?.node?.label} - WPGraphQL for ACF`}</title>
</Head>
<LayoutArchive
title={data?.node?.label ? data.node.label : 'WPGraphQL for ACF'}
data={data}
navigation={data?.navigation?.nodes}
toc={toc}
>
<FieldTypesList data={data} />
</LayoutArchive>
</>
)
}

ArchiveFieldType.query = gql`
query GetArchiveFieldType($uri: String!) {
export const GET_POST_QUERY = gql`
query GetPost($uri: String!) {
node: nodeByUri(uri: $uri) {
__typename
uri
Expand Down Expand Up @@ -62,9 +42,49 @@ ArchiveFieldType.query = gql`
}
}
}
...LayoutArchiveFragment
}
${LayoutArchive.fragment}
`
`;

export const ArchiveFieldType = (props) => {
const { data } = props
console.log({data});
const { node } = useFaustQuery(GET_POST_QUERY);
const { primaryMenuItems, footerMenuItems, docsSidebarMenuItems } = useFaustQuery(GET_LAYOUT_QUERY);

if (!node) {
return null
}

let toc = []

console.log({primaryMenuItems, footerMenuItems, docsSidebarMenuItems});


return (
<>
<Head>
<title>{`${data?.node?.label} - WPGraphQL for ACF`}</title>
</Head>
<LayoutArchive
title={data?.node?.label ? data.node.label : 'WPGraphQL for ACF'}
data={data}
navigation={data?.navigation?.nodes}
toc={toc}
>
<FieldTypesList data={data} />
</LayoutArchive>
</>
)
}

ArchiveFieldType.queries = [
{
query: GET_LAYOUT_QUERY,
},
{
query: GET_POST_QUERY,
variables: ({ uri }) => ({ uri }),
}
];

ArchiveFieldType.variables = ({ uri }) => ({ uri })

0 comments on commit 79b713a

Please sign in to comment.