我正在使用带有Prisma的Graphql服务器。但是当我尝试运行代码时出现此错误 我正在使用
SELECT
fullVisitorId,
visitNumber,
(SELECT max(case when customdimension.index = 16 then customdimension.value else '' end) as cd_16,
(SELECT max(case when customdimension.index = NN then customdimension.value else '' end) as cd_NN
FROM ga_sessions
这是错误
const { GraphQLServer } = require('graphql-yoga')
const { prisma } = require('./generated/prisma-client')
我试图从数据模型中删除约束,但错误仍然存在
Error: Directive constraint: Couldn't find type constraint in any of the schemas.
at collectDirective (D:\project\Starter\server\node_modules\graphql-import\dist\definition.js:113:23)
at Array.forEach (<anonymous>)
at collectNode (D:\project\Starter\server\node_modules\graphql-import\dist\definition.js:105:25)
at D:\project\Starter\server\node_modules\graphql-import\dist\definition.js:87:13
at Array.forEach (<anonymous>)
at collectNewTypeDefinitions (D:\project\Starter\server\node_modules\graphql-import\dist\definition.js:86:30)
at Object.completeDefinitionPool (D:\project\Starter\server\node_modules\graphql-import\dist\definition.js:23:41)
at Object.importSchema (D:\project\Starter\server\node_modules\graphql-import\dist\index.js:99:67)
at mergeTypeDefs (D:\project\Starter\server\node_modules\graphql-yoga\dist\index.js:420:37)
at new GraphQLServer (D:\project\Starter\server\node_modules\graphql-yoga\dist\index.js:95:34)
有人有相同或相似的错误吗? 谢谢
答案 0 :(得分:0)
我找到了解决此问题的方法 最后,这是一个打字问题,该指令未声明,因此graphql-yoga无法识别该指令,因此我在包含所有实体声明的schema.graphql文件中添加了该指令的声明
directive @constraint(
maxLength:Int!
) on FIELD_DEFINITION
所以在这里graphql-yoga可以找到该指令。 希望对您有帮助 我不知道它是如何从内部工作的,但是它解决了我的问题