elysiajs / elysia

Ergonomic Framework for Humans
https://elysiajs.com
MIT License
9.74k stars 207 forks source link

Feature request: RAW graphql-js plugin #62

Closed capaj closed 1 week ago

capaj commented 1 year ago

I typically use code first approach to building my graphql APIs. That would be things like https://github.com/hayes/pothos or https://nexusjs.org/

and for those I would prefer to plug them into elysia using just graphql-js. apollo-server and yoga have extra performance overhead I'd like to avoid.

Cauen commented 10 months ago

Hi @capaj It seems the plugin dont support setting schema. But the code of the plugin is baiscally only 2 lines:

Try this:

const graphqlPath = "/graphql"

new Elysia()
  .get('/', (() => `Hello`))
  .get('/id/:id', (({ params: { id } }) => id))
  .get(graphqlPath, async ({ request }) => yoga.fetch(request))
  .post(graphqlPath, async ({ request }) => yoga.fetch(request), { type: 'none' })

Working example with Pothos

Hope that helps :)

nephix commented 4 months ago

Is there a way to make pothos work with the official yoga plugin from https://elysiajs.com/plugins/graphql-yoga, since yoga() doesn't accept a schema?

SaltyAom commented 1 week ago

Closing as not planned in the roadmap. We feels like we have no profession in GraphQL domain enough and don't have enough effort to maintain other GraphQL plugin.

I'd happy to see a third-party plugin as well.

kamalkech commented 4 days ago

@Cauen Property 'fetch' does not exist on type '<TypeDefs extends TypeSource, Context extends MaybePromise<Record<string, unknown>> | ((initialContext: YogaInitialContext) => unknown) | undefined, Prefix extends string = "/graphql">({ path, typeDefs, resolvers, resolverValidationOptions, inheritResolversFromInterfaces, updateResolversInPlace, schemaExtensions, sc...