My setup isn’t working correctly:
In my app.tsx
I want to use useQuery
to get some results from Apollo:
// app.tsx
import {useQuery} from '@apollo/client';
import resolvers from './resolvers';
const App = () => {
const {loading, error, data} = useQuery(resolvers.resolvers.Query.movies);
My movies query looks like this:
// ./resolver.js
const Query = {
movies: () => {
return prisma.movie.findMany();
},
};
This shows the error:
Argument of type ‘() => PrismaPromise<Movie>’ is not assignable to parameter of type ‘DocumentNode | TypedDocumentNode<any, OperationVariables>’.
Type ‘() => PrismaPromise<Movie>’ is missing the following properties from type ‘TypedDocumentNode<any, OperationVariables>’: kind, definitionsts(2345)
I believe the issue is that the return type of the resolver is PrismaPromise<Movie[]>
but useQuery
requires a type of DocumentNode
. So I’m guessing I have to refactor my resolvers to make it work with TypeScript but I can’t find any good source on that.