also removed any references to Anify
This commit is contained in:
41
src/graphql.ts
Normal file
41
src/graphql.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import { createSchema, createYoga } from "graphql-yoga";
|
||||
import { Hono } from "hono";
|
||||
|
||||
import { createGraphQLContext } from "./context";
|
||||
import { resolvers } from "./resolvers";
|
||||
import { typeDefs } from "./schema";
|
||||
|
||||
const schema = createSchema({
|
||||
typeDefs,
|
||||
resolvers,
|
||||
});
|
||||
|
||||
const yoga = createYoga({
|
||||
schema,
|
||||
graphqlEndpoint: "/graphql",
|
||||
landingPage: false, // Disable landing page for production
|
||||
graphiql: {
|
||||
title: "Aniplay GraphQL API",
|
||||
},
|
||||
context: ({ request }) => {
|
||||
// Extract Hono context from the request
|
||||
// graphql-yoga passes the raw request, but we need Hono context
|
||||
// This will be provided when we integrate with Hono
|
||||
return request as any;
|
||||
},
|
||||
});
|
||||
|
||||
const app = new Hono<Cloudflare.Env>();
|
||||
|
||||
app.all("/", async (c) => {
|
||||
const graphqlContext = await createGraphQLContext(c);
|
||||
|
||||
// Create a custom request object that includes our GraphQL context
|
||||
const request = c.req.raw.clone();
|
||||
(request as any).graphqlContext = graphqlContext;
|
||||
|
||||
const response = await yoga.fetch(request, graphqlContext);
|
||||
return response;
|
||||
});
|
||||
|
||||
export default app;
|
||||
Reference in New Issue
Block a user