is there a good approach for using useSession (next-auth/react
) and useQuery (@apollo/client
) together? problem with the code below is that session
could possibly undefined here which could cause a 400 error in Graphql, I would only want the query to happen if session is defined
const myComponent = () => {
const { data: session } = useSession();
const { loading: user, data: userData } = useQuery<data, dataVar>(
GET_USER_INFO,
{
variables: { userID: session?.user.id as string },
}
);
}