import { type Elysia } from 'elysia'; import type { CreateMobius, Resolver } from 'graphql-mobius'; import { type GraphQLSchemaWithContext, type YogaServerOptions, type YogaInitialContext } from 'graphql-yoga'; import type { IExecutableSchemaDefinition } from '@graphql-tools/schema'; import type { TypeSource } from '@graphql-tools/utils'; type MaybePromise = T | Promise; type Prettify = { [K in keyof T]: T[K]; } & {}; /** * Extra type safety for Yoga * can pass either schema prop defined by * ElysiaYogaConfigWithSchema * * or * * typeDefs and resolvers props * (to build schema with: createSchema()) * defined by * ElysiaYogaConfigWithTypeDefsAndResolvers * */ interface ElysiaYogaConfigWithSchema> | ((initialContext: YogaInitialContext) => MaybePromise)> extends Omit, 'typeDefs' | 'context' | 'cors'>, Omit, 'typeDefs'> { /** * @default /graphql * * path for GraphQL handler */ path?: string; /** * TypeDefs */ typeDefs?: undefined; context?: Context; schema: GraphQLSchemaWithContext; /** * If this field isn't presented, context type is null * It must also contains params when used * I don't know why please help */ useContext?: (_: this['context']) => void; resolvers?: undefined; } interface ElysiaYogaConfigWithTypeDefsAndResolvers> | ((initialContext: YogaInitialContext) => MaybePromise)> extends Omit, 'typeDefs' | 'context' | 'cors'>, Omit, 'resolvers'> { /** * @default /graphql * * path for GraphQL handler */ path?: string; /** * TypeDefs */ typeDefs: TypeDefs; context?: Context; schema?: undefined; /** * If this field isn't presented, context type is null * It must also contains params when used * I don't know why please help */ useContext?: (_: this['context']) => void; resolvers: Resolver : { Query: Record; Mutation: Record; Subscription: Record; }, Context extends undefined ? { request: Request; } : Context extends (a: YogaInitialContext) => infer A ? Prettify> & { request: Request; }> : Prettify> & { request: Request; }>>; } type ElysiaYogaConfig> | ((initialContext: YogaInitialContext) => MaybePromise)> = ElysiaYogaConfigWithSchema | ElysiaYogaConfigWithTypeDefsAndResolvers; /** * GraphQL Yoga supports for Elysia * * @example * ```typescript * import { Elysia } from 'elysia' * import { yoga } from '@elysiajs/graphql-yoga' * * const app = new Elysia() * .use( * yoga({ * typeDefs: ` * type Query { * hi: String * } * `, * resolvers: { * Query: { * hi: () => 'Hi from Elysia' * } * } * }) * ) * .listen(8080) * ``` * * * @example * ```typescript * import { Elysia } from 'elysia' * import { yoga, createSchema } from '@elysiajs/graphql-yoga' * const { loadFiles } = require('@graphql-tools/load-files') * * const schema = createSchema({ * typeDefs: await loadFiles('src/typeDefs/*.graphql') * resolvers: await loadFiles('src/resolvers/*.{js,ts}') * }) * * const app = new Elysia() * .use( * yoga({ * schema * }) * ) * .listen(8080) * ``` */ export declare const yoga: > | ((initialContext: YogaInitialContext) => MaybePromise), Prefix extends string = "/graphql">({ path, typeDefs, resolvers, resolverValidationOptions, inheritResolversFromInterfaces, updateResolversInPlace, schemaExtensions, schema, ...config }: ElysiaYogaConfig) => (app: Elysia) => Elysia<"", { decorator: {}; store: {}; derive: {}; resolve: {}; }, { typebox: {}; error: {}; }, { schema: {}; standaloneSchema: {}; macro: {}; macroFn: {}; parser: {}; response: {}; }, {} & import("elysia").CreateEden, { get: { body: unknown; params: import("elysia/dist/types").IsNever>> extends true ? import("elysia").ResolvePath : import("elysia").ResolvePath>; query: unknown; headers: unknown; response: { [K_1 in keyof ({} extends {} & (import("elysia").EmptyRouteSchema extends Pick, {}, import("elysia/dist/types").JoinPath<"", Prefix>> & {}, keyof import("elysia").EmptyRouteSchema> ? {} : { 422: { type: "validation"; on: string; summary?: string; message?: string; found?: unknown; property?: string; expected?: string; }; }) ? import("elysia/dist/types").ValueToResponseSchema : { [key in 200 | keyof ({} & (import("elysia").EmptyRouteSchema extends Pick, {}, import("elysia/dist/types").JoinPath<"", Prefix>> & {}, keyof import("elysia").EmptyRouteSchema> ? {} : { 422: { type: "validation"; on: string; summary?: string; message?: string; found?: unknown; property?: string; expected?: string; }; }))]: key extends 200 ? key extends keyof ({} & (import("elysia").EmptyRouteSchema extends Pick, {}, import("elysia/dist/types").JoinPath<"", Prefix>> & {}, keyof import("elysia").EmptyRouteSchema> ? {} : { 422: { type: "validation"; on: string; summary?: string; message?: string; found?: unknown; property?: string; expected?: string; }; })) ? import("elysia/dist/types").ValueToResponseSchema[key] | ({} & (import("elysia").EmptyRouteSchema extends Pick, {}, import("elysia/dist/types").JoinPath<"", Prefix>> & {}, keyof import("elysia").EmptyRouteSchema> ? {} : { 422: { type: "validation"; on: string; summary?: string; message?: string; found?: unknown; property?: string; expected?: string; }; }))[key] : import("elysia/dist/types").ValueToResponseSchema[key] : key extends keyof ({} & (import("elysia").EmptyRouteSchema extends Pick, {}, import("elysia/dist/types").JoinPath<"", Prefix>> & {}, keyof import("elysia").EmptyRouteSchema> ? {} : { 422: { type: "validation"; on: string; summary?: string; message?: string; found?: unknown; property?: string; expected?: string; }; })) ? ({} & (import("elysia").EmptyRouteSchema extends Pick, {}, import("elysia/dist/types").JoinPath<"", Prefix>> & {}, keyof import("elysia").EmptyRouteSchema> ? {} : { 422: { type: "validation"; on: string; summary?: string; message?: string; found?: unknown; property?: string; expected?: string; }; }))[key] : never; })]: K_1 extends never ? unknown : ({} extends {} & (import("elysia").EmptyRouteSchema extends Pick, {}, import("elysia/dist/types").JoinPath<"", Prefix>> & {}, keyof import("elysia").EmptyRouteSchema> ? {} : { 422: { type: "validation"; on: string; summary?: string; message?: string; found?: unknown; property?: string; expected?: string; }; }) ? import("elysia/dist/types").ValueToResponseSchema : { [key in 200 | keyof ({} & (import("elysia").EmptyRouteSchema extends Pick, {}, import("elysia/dist/types").JoinPath<"", Prefix>> & {}, keyof import("elysia").EmptyRouteSchema> ? {} : { 422: { type: "validation"; on: string; summary?: string; message?: string; found?: unknown; property?: string; expected?: string; }; }))]: key extends 200 ? key extends keyof ({} & (import("elysia").EmptyRouteSchema extends Pick, {}, import("elysia/dist/types").JoinPath<"", Prefix>> & {}, keyof import("elysia").EmptyRouteSchema> ? {} : { 422: { type: "validation"; on: string; summary?: string; message?: string; found?: unknown; property?: string; expected?: string; }; })) ? import("elysia/dist/types").ValueToResponseSchema[key] | ({} & (import("elysia").EmptyRouteSchema extends Pick, {}, import("elysia/dist/types").JoinPath<"", Prefix>> & {}, keyof import("elysia").EmptyRouteSchema> ? {} : { 422: { type: "validation"; on: string; summary?: string; message?: string; found?: unknown; property?: string; expected?: string; }; }))[key] : import("elysia/dist/types").ValueToResponseSchema[key] : key extends keyof ({} & (import("elysia").EmptyRouteSchema extends Pick, {}, import("elysia/dist/types").JoinPath<"", Prefix>> & {}, keyof import("elysia").EmptyRouteSchema> ? {} : { 422: { type: "validation"; on: string; summary?: string; message?: string; found?: unknown; property?: string; expected?: string; }; })) ? ({} & (import("elysia").EmptyRouteSchema extends Pick, {}, import("elysia/dist/types").JoinPath<"", Prefix>> & {}, keyof import("elysia").EmptyRouteSchema> ? {} : { 422: { type: "validation"; on: string; summary?: string; message?: string; found?: unknown; property?: string; expected?: string; }; }))[key] : never; })[K_1]; } extends infer T ? { [K in keyof T]: T[K]; } : never; }; }> & import("elysia").CreateEden, { post: { body: unknown; params: import("elysia/dist/types").IsNever>> extends true ? import("elysia").ResolvePath : import("elysia").ResolvePath>; query: unknown; headers: unknown; response: { [K_1 in keyof ({} extends {} & (import("elysia").EmptyRouteSchema extends Pick, {}, import("elysia/dist/types").JoinPath<"", Prefix>> & {}, keyof import("elysia").EmptyRouteSchema> ? {} : { 422: { type: "validation"; on: string; summary?: string; message?: string; found?: unknown; property?: string; expected?: string; }; }) ? import("elysia/dist/types").ValueToResponseSchema : { [key in 200 | keyof ({} & (import("elysia").EmptyRouteSchema extends Pick, {}, import("elysia/dist/types").JoinPath<"", Prefix>> & {}, keyof import("elysia").EmptyRouteSchema> ? {} : { 422: { type: "validation"; on: string; summary?: string; message?: string; found?: unknown; property?: string; expected?: string; }; }))]: key extends 200 ? key extends keyof ({} & (import("elysia").EmptyRouteSchema extends Pick, {}, import("elysia/dist/types").JoinPath<"", Prefix>> & {}, keyof import("elysia").EmptyRouteSchema> ? {} : { 422: { type: "validation"; on: string; summary?: string; message?: string; found?: unknown; property?: string; expected?: string; }; })) ? import("elysia/dist/types").ValueToResponseSchema[key] | ({} & (import("elysia").EmptyRouteSchema extends Pick, {}, import("elysia/dist/types").JoinPath<"", Prefix>> & {}, keyof import("elysia").EmptyRouteSchema> ? {} : { 422: { type: "validation"; on: string; summary?: string; message?: string; found?: unknown; property?: string; expected?: string; }; }))[key] : import("elysia/dist/types").ValueToResponseSchema[key] : key extends keyof ({} & (import("elysia").EmptyRouteSchema extends Pick, {}, import("elysia/dist/types").JoinPath<"", Prefix>> & {}, keyof import("elysia").EmptyRouteSchema> ? {} : { 422: { type: "validation"; on: string; summary?: string; message?: string; found?: unknown; property?: string; expected?: string; }; })) ? ({} & (import("elysia").EmptyRouteSchema extends Pick, {}, import("elysia/dist/types").JoinPath<"", Prefix>> & {}, keyof import("elysia").EmptyRouteSchema> ? {} : { 422: { type: "validation"; on: string; summary?: string; message?: string; found?: unknown; property?: string; expected?: string; }; }))[key] : never; })]: K_1 extends never ? unknown : ({} extends {} & (import("elysia").EmptyRouteSchema extends Pick, {}, import("elysia/dist/types").JoinPath<"", Prefix>> & {}, keyof import("elysia").EmptyRouteSchema> ? {} : { 422: { type: "validation"; on: string; summary?: string; message?: string; found?: unknown; property?: string; expected?: string; }; }) ? import("elysia/dist/types").ValueToResponseSchema : { [key in 200 | keyof ({} & (import("elysia").EmptyRouteSchema extends Pick, {}, import("elysia/dist/types").JoinPath<"", Prefix>> & {}, keyof import("elysia").EmptyRouteSchema> ? {} : { 422: { type: "validation"; on: string; summary?: string; message?: string; found?: unknown; property?: string; expected?: string; }; }))]: key extends 200 ? key extends keyof ({} & (import("elysia").EmptyRouteSchema extends Pick, {}, import("elysia/dist/types").JoinPath<"", Prefix>> & {}, keyof import("elysia").EmptyRouteSchema> ? {} : { 422: { type: "validation"; on: string; summary?: string; message?: string; found?: unknown; property?: string; expected?: string; }; })) ? import("elysia/dist/types").ValueToResponseSchema[key] | ({} & (import("elysia").EmptyRouteSchema extends Pick, {}, import("elysia/dist/types").JoinPath<"", Prefix>> & {}, keyof import("elysia").EmptyRouteSchema> ? {} : { 422: { type: "validation"; on: string; summary?: string; message?: string; found?: unknown; property?: string; expected?: string; }; }))[key] : import("elysia/dist/types").ValueToResponseSchema[key] : key extends keyof ({} & (import("elysia").EmptyRouteSchema extends Pick, {}, import("elysia/dist/types").JoinPath<"", Prefix>> & {}, keyof import("elysia").EmptyRouteSchema> ? {} : { 422: { type: "validation"; on: string; summary?: string; message?: string; found?: unknown; property?: string; expected?: string; }; })) ? ({} & (import("elysia").EmptyRouteSchema extends Pick, {}, import("elysia/dist/types").JoinPath<"", Prefix>> & {}, keyof import("elysia").EmptyRouteSchema> ? {} : { 422: { type: "validation"; on: string; summary?: string; message?: string; found?: unknown; property?: string; expected?: string; }; }))[key] : never; })[K_1]; } extends infer T_1 ? { [K in keyof T_1]: T_1[K]; } : never; }; }>, { derive: {}; resolve: {}; schema: {}; standaloneSchema: {}; response: {}; }, { derive: {}; resolve: {}; schema: {}; standaloneSchema: {}; response: {}; }>; export default yoga;