I am trying to use Apollo Client in my React Native project. I tried to generate types from the graphql API based on the official tutorial: https://www.apollographql.com/docs/react/development-testing/static-typing/
The problem is that I am using the gql
function which returns unknown
. And these make problems in the useQuery
and useMutation
hooks.
A defined mutation (this is working in Apollo playground):
export const registerMutation = gql(`
mutation Register($email: String!, $password: String!, $companyName: String) {
register(data:{email: $email, password: $password, companyName: $companyName}){
name
email
profileImage
}
}
`);
Usage of the mutation:
const [register] = useMutation(registerMutation);
The error I am getting from useMutation hook: Argument of type 'unknown' is not assignable to parameter of type 'DocumentNode | TypedDocumentNode<any, OperationVariables>'.