Created
November 3, 2018 20:56
-
-
Save donedgardo/ed2d36f6e650991543e5a55c77cddc0d to your computer and use it in GitHub Desktop.
Apollo-server 2.0 setup graphqlshield
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ApolloServer } from "apollo-server-express"; | |
import { importSchema } from "graphql-import"; | |
import { makeExecutableSchema } from "graphql-tools"; | |
import { applyMiddleware } from "graphql-middleware"; | |
import * as path from "path"; | |
import { Prisma } from "./generated/prisma"; | |
import resolvers from "./resolvers"; | |
import permisions from "./resolvers/permisions"; | |
export const db: Prisma = new Prisma({ | |
endpoint: process.env.PRISMA_ENDPOINT, // the endpoint of the Prisma API (value set in `.env`) | |
debug: process.env.NODE_ENV === "DEBUG", // log all GraphQL queries & mutations sent to the Prisma API | |
secret: process.env.PRISMA_MANAGEMENT_API_SECRET // only needed if specified in `database/prisma.yml` (value set in `.env`) | |
}); | |
const typeDefs: any = importSchema(path.resolve("src/schema.graphql")); | |
const schema = applyMiddleware( | |
makeExecutableSchema({ | |
typeDefs, | |
resolvers | |
}), | |
permisions | |
); | |
export const server = new ApolloServer({ | |
// Removed from Graphql Yoga but might include after PR: https://github.com/apollographql/apollo-server/pull/1799 | |
// middlewares: [permisions], | |
// resolverValidationOptions: { | |
// requireResolversForResolveType: false | |
// }, | |
typeDefs, | |
resolvers, | |
schema, | |
engine: { | |
apiKey: process.env.YOUR_APOLLO_ENGINE_KEY | |
}, | |
context: req => ({ | |
...req, | |
db | |
}) | |
}); |
I'm getting the same error
If you're getting an error with the introspection query resolving asynchronously, you can fix that by downgrading the version of apollo-server
until this issue is fixed: apollographql/apollo-server#1935 (related to: apollographql/apollo-server#1934)
Getting the same error, except only when deploying to on my docker container... Locally, no issues 😕
Edit: @Gomah which version did you downgrade apollo-server to?
@constmontague 2.0.5
any fix for this?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm getting
Error: The introspection query is resolving asynchronously; execution of an introspection query is not expected toreturn a
Promise.
when adding the permissions-middleware. Have you run into the same error?