Ad
Error: Directive Constraint In Graphql Yoga When Using Constraints
I am using Graphql server with Prisma. but when i try to run the code i get this error I am using
const { GraphQLServer } = require('graphql-yoga')
const { prisma } = require('./generated/prisma-client')
This is the error
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)
I tried to remove the constraint from the datamodel but the error persists
@constraint(
maxLength:650,
minLength:20
)
has anyone got the same or similar error ? Thanks
Ad
Answer
I found the solution for this problem Finally it was a typing problem, the directive was not declared and so not recognized by graphql-yoga so I added the declaration of the directive in the schema.graphql file which contains the declaration of all Entities and it worked
directive @constraint(
maxLength:Int!
) on FIELD_DEFINITION
So here the graphql-yoga can find the Directive. Hope that will help you I don't know exactly how it works from inside but it solved my problem
Ad
source: stackoverflow.com
Related Questions
- → Maximum call stack exceeded when instantiating class inside of a module
- → Browserify api: how to pass advanced option to script
- → Node.js Passing object from server.js to external modules?
- → gulp-rename makes copies, but does not replace
- → requiring RX.js in node.js
- → Remove an ObjectId from an array of objectId
- → Can not connect to Redis
- → React: How to publish page on server using React-starter-kit
- → Express - better pattern for passing data between middleware functions
- → Can't get plotly + node.js to stream data coming through POST requests
- → IsGenerator implementation
- → Async/Await not waiting
- → (Socket.io on nodejs) Updating div with mysql data stops without showing error
Ad