I would like to use same basic fragments in my query.
But as soon as I use my fragment variable: ${NEXT_SEO_FRAGMENT}
I got following Error: ApolloError: Response not successful: Received status code 500
my query:
import { getApolloClient } from "../apollo-client";
import gql from 'graphql-tag'
import { Locale } from "../types";
const NEXT_SEO_FRAGMENT = gql`
fragment NextSeoFields on NextSeoType {
seoDescription
seoTitle
}
`;
export async function getHomeEntrys(locale: Locale) {
const apolloClient = getApolloClient();
const language = locale;
const { data } = await apolloClient.query({
query: gql`
query pages($language: LanguageCodeFilterEnum!) {
pages(where: { language: $language }) {
edges {
node {
title
content
slug
language {
code
locale
}
id
isFrontPage
nextSeo {
...NextSeoFields
}
}
}
}
}
${NEXT_SEO_FRAGMENT}
`,
variables: {
language,
},
});
return data?.pages.edges
}
working code without the fragment:
import { getApolloClient } from "../apollo-client";
import gql from 'graphql-tag'
import { Locale } from "../types";
export async function getHomeEntrys(locale: Locale) {
const apolloClient = getApolloClient();
const language = locale;
const { data } = await apolloClient.query({
query: gql`
query pages($language: LanguageCodeFilterEnum!) {
pages(where: { language: $language }) {
edges {
node {
title
content
slug
language {
code
locale
}
id
isFrontPage
nextSeo {
seoDescription
seoTitle
}
}
}
}
}
`,
variables: {
language,
},
});
return data?.pages.edges
}
thanks for any help, best