Hi, does anyone have experience using Prisma with ...
# orm-help
b
Hi, does anyone have experience using Prisma with React Query? I'm calling
const { data, error, isLoading } = useQuery(['links'], resolvers.Query.links)
Where
resolvers.Query.links
is
links: async () => prisma.link.findMany()
I'm getting the error
Copy code
Invalid environment variables:
 DATABASE_URL: Required
 NODE_ENV: Required
But DATABASE_URL is specified in the root .env file. Previously I was using Apollo Client and didn't encounter this issue.
👀 1
p
You need a server to talk to prisma no?
b
I'm using the Next.js backend with a separately hosted PostgreSQL Database (Supabase)
r
Hi Bryan 👋 Can you please share a minimal reproduction of this issue so i can try reproducing and come up with a solution?
b
@Raphael Etim Hi Raphael, thanks for following up. The reproduction can be found here: https://replit.com/@bryanzcp502/PrismaReactQueryIssueRepro The project is in the prisma-react-query-issue folder and running "npm run dev" starts the homepage that shows the issue. If you click "Open in a new tab" and check the console you will see the error message as described above
@Raphael Etim Hi Raphael, just following up on this issue. Please let me know if you can access the repro.
r
I just got to it now. The repl seems to take a long time to wake up
b
Thanks, to run the repl you need to
cd prisma-react-query-issue/
and run
npm run dev
to start the server, the Webview should then reload to show the error in the screenshot
a
Hey Bryan, Just to reiterate, you cannot use Prisma queries on the frontend of your website where React Query is generally used. That will definitely result in some errors.
b
Hi Austin, thanks for your response. I might be misunderstanding how React Query/Prisma should be used in this case, previously I have been using Apollo client and have not had issues with Prisma. How would you recommend using and resolving queries using React Query and Prisma or would it be better to stick with Apollo Client?
p
You would have to connect prisma with a graphql connector thingy
Read through
b
Got it, will read through and try useQuery again after making changes. Thanks.
👍 1