【发布时间】:2019-12-29 05:13:05
【问题描述】:
我正在使用 apollo 模块,并且我有多个模块: 用户个人资料, 学校, 项目
我有以下类型定义:
UserProfile 的 typeDef:
export const typeDefs = gql`
extend type Query {
getUserProfile(uuid: String!): UserProfile
}
type UserProfile {
id: ID!
email: String,
uuid: String,
firstName: String,
lastName: String,
school: String
}
extend type Project {
userInfo: UserProfile
}
`;
为项目键入 def:
export const typeDefs = gql`
extend type Query {
getProject(uuid: String!): Project
}
type Project {
_id: ID!
user: String,
name: String,
uuid: String
}
extend type UserProfile {
userProjects: [Project]
}
`;
这里是学校类型定义:
export const typeDefs = gql`
extend type Query {
getSchool(uuid: String!): School
}
type School {
_id: ID!
uuid: String,
name: String,
}
extend type UserProfile {
schoolInfo: School
}
`;
现在如果我执行以下查询:
query {
getProject(uuid: "a9e2f2ea") {
name
uuid
ownerInfo {
email
gender
}
userInfo {
lastName
school
schoolInfo
}
}
}
它抱怨它不能:
“无法查询类型 \"UserProfile\" 上的字段 \"schoolInfo\"。
此架构中缺少什么?
【问题讨论】:
标签: graphql apollo graphql-js apollo-server