【发布时间】:2019-07-31 07:15:07
【问题描述】:
我正在使用"graphql-import": "^0.7.1"
我尝试将 @cacheControl 指令添加到我的 graphql 架构中
type Post @cacheControl(maxAge: 240) {
id: Int!
title: String
author: Author
votes: Int @cacheControl(maxAge: 30)
readByCurrentUser: Boolean! @cacheControl(scope: PRIVATE)
}
然后它给出了这个错误 -
Error: Directive cacheControl: Couldn't find type cacheControl in any of the schemas.
所以在从链接中获取提示之后 -
https://github.com/prisma/graphql-import/issues/153
我在下面添加了代码
directive @cacheControl(
maxAge: Int,
scope: CacheControlScope
) on OBJECT | FIELD_DEFINITION
enum CacheControlScope {
PUBLIC
PRIVATE
}
但在那之后我开始收到这个错误 -
Error: There can be only one type named "CacheControlScope".
Enum value "CacheControlScope.PUBLIC" can only be defined once.
Enum value "CacheControlScope.PRIVATE" can only be defined once.
我不知道如何解决这个问题。
【问题讨论】:
-
你能不能尝试把cacheDirective放在一个directives.graphql上然后导入它(#import cacheControl from 'directives.graphql')看看它是否有效?
-
@jgoday 我也试过了,但还是不行
标签: graphql graphql-js apollo-server express-graphql