【发布时间】:2019-07-25 15:57:37
【问题描述】:
由于某种原因,我不得不构建一个仅客户端的 GraphQL 服务器,我的架构构建如下:
private buildSchema(): GraphQLSchema {
const allTypes: string = ...// my types
const allResolvers: IResolvers[] = ...// my resolvers
return makeExecutableSchema({
typeDefs: allTypes,
resolvers: allResolvers
});
}
客户端如下:
this.client = new ApolloClient({
link: new SchemaLink({schema: this.buildSchema()}),
cache: new InMemoryCache({
addTypename: false
})
});
除了我的查询不是defered 之外,一切正常。例如,如果我运行:
const gqlQuery: string = `
{
user {
name
slowResolver @defer {
text
}
}
}
`
const $result = this.apollo.getClient().watchQuery({
query: gql(gqlQuery)
});
$result 将仅在整个查询将被解析时发出(而不是预期的user 然后slowResolver)。
知道我在工作流程中遗漏了什么吗?
【问题讨论】:
标签: graphql apollo apollo-client apollo-server