WPGraphiQL IDE displays correct data like this:
but when I make the same query with Apollo Client on the Front-End the children of menu returns null.
Getting data with query
import { useApollo } from "../lib/apolloClient";
import { initializeApollo } from "../lib/apolloClient";
import { gql } from "@apollo/client";
function CustomApp({ pageProps, Component, props }) {
const apolloClient = useApollo(pageProps.initialApolloState);
return (
<>
{console.log(props)}
</>
);
}
CustomApp.getInitialProps = async () => {
const apolloClient = initializeApollo();
await apolloClient.query({
query: gql`
{
menu(id: 2, idType: DATABASE_ID) {
id
databaseId
name
slug
menuItems {
nodes {
databaseId
}
}
}
}
`,
});
return {
props: {
initialApolloState: apolloClient.cache.extract(),
},
};
};
Console:
https://i.stack.imgur.com/UdMVY.png
All other nodes return children without any problem.