Closed vonphlpp closed 3 years ago
Ok I have to use getStaticProps like:
const prisma = new PrismaClient();
export async function getStaticProps() {
const data = await prisma.page.findMany();
return {
props: {
data,
},
revalidate: 1,
};
}
But now I dont have the query in my client cache. Somebody know I can save the query in the cache?
Still have the Error. Please help me
import * as React from 'react';
import { Card, CardBody } from '@paljs/ui/Card';
import { Button } from '@paljs/ui/Button';
import { useRouter } from 'next/router';
import { initializeApollo } from '../Api/client';
import { gql, useQuery } from '@apollo/client';
const POSTS = gql`
query findManyPost {
findManyPost {
id
}
}
`;
const Index = () => {
const { data } = useQuery(POSTS);
// query is working on the client
console.log(data);
...
};
//If I use getStaticProps I get the error
export async function getStaticProps() {
const apolloClient = initializeApollo();
await apolloClient.query({
query: POSTS,
});
return {
props: {
initialApolloState: apolloClient.cache.extract(),
},
};
}
export default Index;
This issue not in our generator please ask your question at https://stackoverflow.com/
Hi I created with the
pal c
the full-stack-nextjs project. I have to say this is really nice, didn't expect that, thx for this.But I get the error:
This is happening when I use getStaticProps like:
to solve this problem I made this change in src/Api/client:
But now I don't use anymore the SchemaLink from "@apollo/client/link/schema"
I guess I'm doing something wrong in the getStaticProps()