Git Product home page Git Product logo

Comments (3)

vonphlpp avatar vonphlpp commented on May 18, 2024

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?

from prisma-tools.

vonphlpp avatar vonphlpp commented on May 18, 2024

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;

from prisma-tools.

AhmedElywa avatar AhmedElywa commented on May 18, 2024

This issue not in our generator please ask your question at https://stackoverflow.com/

from prisma-tools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.