I'm newbie in graphql and have following problem:
I'm querying all customers with their photo but graphql server response give me null on photo object.
If I try the RAW SQL statement from Sequelize logging and execute in my sql client it give me right result.
I think the problem is somewhere in graphql on client but I dont know where.
I didnt add till now custom scalar type for field filetype in CustomerPhoto schema but I dont think that this is a issue.
// Customer schema
import CustomerPhoto from "./customerPhoto";
const Customer = `
type Customer {
customerID: ID!
firstname: String
lastname: String
phone: String
email: String
photo: CustomerPhoto
}
type Query {
customers: [Customer]
}
`;
export default [Customer, CustomerPhoto];
// CustomerPhoto schema
const CustomerPhoto = `
type CustomerPhoto {
customerPhotoID: ID!
filename: String
filetype: BLOB
}
`;
export default CustomerPhoto;
Here is my query in grahpiQL:
{
customers {
firstname
phone
photo {
customerPhotoID
}
}
}
Here is the result from query:
{
"data": {
"customers": [
{
"firstname": "Jade",
"phone": "993.588.1173 x0426",
"photo": null
},
{
"firstname": "Oleta",
"phone": "288-162-3631",
"photo": null
},
{
"firstname": "Geoffrey",
"phone": "742.195.2920 x40571",
"photo": null
},
{
"firstname": "Daphne",
"phone": "010.713.4911 x39353",
"photo": null
}
......
]
}
}
here is my resolver:
const CustomerResolvers = {
Query: {
customers: (_, args) => {
return models.Customer.findAll({
include: {
model: models.CustomerPhoto,
attributes: ["customerPhotoID","filename"],
},
attributes: ["customerID","firstname", "lastname", "phone", "email"],
});
}
}
};