-
-
Notifications
You must be signed in to change notification settings - Fork 74
Example doesn't work #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I've just found that this is because of a breaking change in graphql 14 mentioned here: ardatan/graphql-tools#957 Now we have to manually define custom directives in our schema... |
I dont know if your problem is exactly like mine, but when working in custom directives for example
With the graphql-tools update , the definition of the directive is needed within the schema, something like this
Also i removed the direct dependency of graphql-tools because of the issue you referenced. Hope this helps. |
I've got the same problem |
const ConstraintDirective = require('graphql-constraint-directive')
const express = require('express')
const bodyParser = require('body-parser')
const { graphqlExpress } = require('apollo-server-express')
const { makeExecutableSchema } = require('graphql-tools')
const typeDefs = `
directive @constraint(
# String constraints
minLength: Int
maxLength: Int
startsWith: String
endsWith: String
notContains: String
pattern: String
format: String
# Number constraints
min: Int
max: Int
exclusiveMin: Int
exclusiveMax: Int
multipleOf: Int
) on INPUT_FIELD_DEFINITION
type Query {
books: [Book]
}
type Book {
title: String
}
type Mutation {
createBook(input: BookInput): Book
}
input BookInput {
title: String! @constraint(minLength: 5, format: "email")
}
scalar ConstraintString
scalar ConstraintNumber
`
const schema = makeExecutableSchema({
typeDefs, schemaDirectives: { constraint: ConstraintDirective }
})
const app = express()
app.use('/graphql', bodyParser.json(), graphqlExpress({ schema })) |
Some problem. |
The example in the README doesn't work with the error: Error: Unknown directive "constraint".
As far as I can tell the directive returns its own definition, it shouldn't need to be defined in the graphql schema, right?
I've created a file containing only the js from the readme with the various imports installed, still get this error.
The text was updated successfully, but these errors were encountered: