0
import { ApolloServer, makeExecutableSchema } from 'apollo-server-express';
const { constraintDirective, constraintDirectiveTypeDefs } = require('graphql-constraint-directive');

schema: mergeSchemas({
  schemas: [
    makeExecutableSchema({
      resolvers: resolver,
      typeDefs: [constraintDirectiveTypeDefs, typeDefs],
      schemaTransforms: [constraintDirective()]
    }),
  ],
}) 

I am referring this pacakge: https://www.npmjs.com/package/graphql-constraint-directive.

I am getting this error in loading types on my console after implementing it:

Error: Directive "constraint" may not be used on ARGUMENT_DEFINITION.

How to apply validation at schema level?

Brian Destura
  • 11,487
  • 3
  • 18
  • 34
Hemendra
  • 23
  • 3

1 Answers1

0

Your problem is that you are trying to use makeExecutableSchema from apollo-server-express.

As stated in the docs, makeExecutableSchema from graphql-tools should be used.

Solution:

const { ApolloServer } = require('apollo-server-express')
const { makeExecutableSchema } = require('graphql-tools')
Wedyarit
  • 31
  • 3