My query for a single post shows
Cannot return null for non-nullable field Post.author
error message when I include the author field, both from React as well as the Playground. It's working fine for the posts
query which queries for multiple posts and is able to retrieve the specific author, but not when I perform a single post
query.
Client-side schema:
posts(query: String, first: Int, skip: Int, after: String, orderBy: UserOrderByInput): [Post!]!
post(id: ID): Post!
Query from React:
(gql is the same for post
and posts
except for the sorting arguments)
const { data, error, loading } = useQuery(GET_POST, {
variables: {
id: props.match.params.id
}
})
export const GET_POST = gql`
query Post($id: ID!) {
post(
id: $id
){
id
title
body
location
author{
id
firstName
lastName
}
}
}
`
Server-side query:
post(parent, args, { prisma }, info) {
if(!args.id) {
throw new Error("No search query input")
}
return prisma.query.post({
where: {
id: args.id
}, info})
},