diff --git a/src/app/api/graphql/route.ts b/src/app/api/graphql/route.ts index c6afd97..8a5795b 100644 --- a/src/app/api/graphql/route.ts +++ b/src/app/api/graphql/route.ts @@ -1,6 +1,6 @@ /* eslint-disable react-hooks/rules-of-hooks */ import { createYoga, Plugin, createSchema } from "graphql-yoga"; -import { EnvelopArmor } from "@escape.tech/graphql-armor"; +import { EnvelopArmorPlugin } from "@escape.tech/graphql-armor"; import resolvers from "@/graphql/resolvers"; import typeDefs from "@/graphql/types"; @@ -48,9 +48,6 @@ function useApiKey(): Plugin { }; } -const armor = new EnvelopArmor(); -const protection = armor.protect(); - const { handleRequest } = createYoga({ schema: createSchema({ typeDefs: typeDefs, @@ -58,15 +55,12 @@ const { handleRequest } = createYoga({ }), // While using Next.js file convention for routing, we need to configure Yoga to use the correct endpoint - graphqlEndpoint: - process.env.NEXT_PUBLIC_GRAPHQL_URL || - process.env.GRAPHQL_UR || - "/api/graphql", + graphqlEndpoint: "/api/graphql", // Yoga needs to know how to create a valid Next response fetchAPI: { Response }, - plugins: [...protection.plugins, useApiKey()], + plugins: [useApiKey(), EnvelopArmorPlugin()], graphiql: environment !== "production" ? true : false });