Im a beginner trying to set up a graphql API with apollo-express and prisma
All was going well, but than I decided to use this library to add input validation: graphql-constraint-directive
It requires me to use makeExecutableSchema to build my schema so I can use the schemaDirectives param
My code to start the server was like this:
const server = new ApolloServer({
typeDefs,
resolvers,
context: ({req}) => {
const userId = getUserID(req);
return {
userId,
prisma
}
}
});
And all was working perfectly
But to use that lib I had it refactored it like this:
const schema = makeExecutableSchema({
typeDefs,
resolvers,
schemaDirectives: {constraint: ConstraintDirective}
});
const server = new ApolloServer({
schema,
context: ({req}) => {
const userId = getUserID(req);
return {
userId,
prisma
}
}
});
And it works too, all my queries and mutations are working, and the validation too.
But it broke the graphql-playground: its no longer able to load my schema and docs, both tabs are empty. And it displays the following error: Server cannot be reached
It still works: Im able to send my querys and mutations and all, but I no longer have code completion and the auto docs, since it doenst knows my schema, and so is no longer as useful
If I replace the executable schema for the pure typeDefs ans resolvers, than it works alright again, playground loads everything again
Am I supposed to do something different when using makeExecutableSchema, for playgroun to work?