Sequelize.js graphQL查询在响应中为我提供空对象

Sequelize.js graphQL查询在响应中为我提供空对象,sequelize.js,graphql,apollo,apollo-server,Sequelize.js,Graphql,Apollo,Apollo Server,我是graphql的新手,有以下问题: 我正在查询所有客户的照片,但graphql服务器响应在照片对象上为空。 如果我尝试Sequelize日志中的原始SQL语句并在我的SQL客户机中执行,它会给出正确的结果 我想问题出在客户端的graphql中,但我不知道在哪里 到目前为止,我还没有在CustomerPhoto模式中为fieldfiletype添加自定义标量类型,但我认为这不是一个问题 //客户模式 import CustomerPhoto from "./customerPhoto";

我是graphql的新手,有以下问题:

我正在查询所有客户的照片,但graphql服务器响应在照片对象上为空。

如果我尝试Sequelize日志中的原始SQL语句并在我的SQL客户机中执行,它会给出正确的结果

我想问题出在客户端的graphql中,但我不知道在哪里

到目前为止,我还没有在CustomerPhoto模式中为fieldfiletype添加自定义标量类型,但我认为这不是一个问题

//客户模式

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;
以下是我在grahpiQL中的查询:

{
  customers {
    firstname
    phone
    photo {
     customerPhotoID
    }
  }
}
以下是查询的结果:

  {
      "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
          }
    ......
        ]
      }
    }
这是我的解析器:

const CustomerResolvers = {
  Query: {
    customers: (_, args) => {
      return models.Customer.findAll({
        include: {
          model: models.CustomerPhoto,
          attributes: ["customerPhotoID","filename"],
        },
        attributes: ["customerID","firstname", "lastname", "phone", "email"],
      });

    }
  }
};

我的客户模式不好

解决方案如下:

我不得不使用CustomerPhoto来代替照片

const Customer = `
     type Customer {
      customerID: ID!
      firstname: String
      lastname: String
      phone: String
      email: String
      CustomerPhoto: CustomerPhoto
     } 
     type Query {
      customers: [Customer]
      }
    `;