Im updating a project from graphql-yoga to apollo-server. I load a primsa schema into my graphql schema (schema.graphql) using this line # import * from './generated/prisma.graphql'
, under graphql-yoga this then imported the prisma types into the schema.
However as it is yoga doing this, when upgrading from yoga, this simply does not happen. I managed to get this to work using graphql-import (assume it imports the schema), however as its deprecated I am unable to use this as a solution.
Does anyone know how I can achieve this using graphql-tools please? Below is how I create my apollo-server instance.
const sources = loadTypedefsSync(__dirname + '/schema.graphql', { loaders: [new GraphQLFileLoader()] })
const typeDefs = sources.map(source => source.document)
const schema = makeExecutableSchema({ typeDefs, ...resolvers })
const schemaWithMiddleware = applyMiddleware(schema, permissions)
const server = new ApolloServer({
schema: schemaWithMiddleware,
context: ({ req }) => ({
...req,
db
}),
})
Thanks in advance
It is recommend by the maintainers of GraphQL Import to migrate to GraphQL Tools. There is a straight forward migration from GraphQL Import example provided by GraphQL Tools in the docs.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.