Query works in playground but not work in nextjs client

hi, have this problem and i don`t find the solution, this is my problem:

i have this query and it works well in the playground(graphql community forum it does not let me put an image):

query{
getAllLoans{
books{
id
title
author{
fullName
}
bookLoan{
createdAt
returned_date
}
}
}
}

then i want to use this query in nextjs i have this error:
GRAPHQL-COMUNITY-ERROR

if you see the data is ok but the when i try to map i get this error, and i don`t know why,
my client code:

if someone could help me and tell me what i’m doing wrong, i would appreciate it

this is the query:

this is my client code:

use-Query-Client

@gfxargentina the issue is shown in your first screenshot where you logged the results of getAllLoans:

Image 2021-12-04 at 3.49.29 PM

Item 31 has no books which means the libro.books.title call in your component is failing because it can’t look title up on a null value. You should edit your component to be a little more defensive with regards to handling cases where libro.books can be null.

1 Like

hi hwillson, thanks for your response, you are right, the problem was the null in item 31, i delete that field from the database and all works ok, thanks

admin can close this thread hwillson respond is the solution, thanks

Solved.