Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yoga options does not accept schema or yoga property #3

Open
arkmech opened this issue Sep 9, 2023 · 11 comments
Open

Yoga options does not accept schema or yoga property #3

arkmech opened this issue Sep 9, 2023 · 11 comments

Comments

@arkmech
Copy link

arkmech commented Sep 9, 2023

Example from: https://www.npmjs.com/package/@elysiajs/graphql-yoga

import { Elysia } from 'elysia'
import { yoga } from '@elysiajs/graphql-yoga'

import { createYoga, createSchema } from 'graphql-yoga'

const app = new Elysia()
    .use(
        yoga({
           // yoga property doesn't exist
            yoga: createYoga({
                schema: createSchema({
                    typeDefs: `
                        type Query {
                            hi: String
                        }
                `,
                resolvers: {
                    Query: {
                        hi: () => 'Hi from Elysia'
                    }
                }
            })
        })
    )
    .listen(8080)

Error

Object literal may only specify known properties, and 'yoga' does not exist in type 'ElysiaYogaConfig<string, MaybePromise<Record<string, unknown>> | ((initialContext: YogaInitialContext) => unknown) | undefined>'

Desired, yoga accepts schema property createSchema() or from makeExecutableSchema(), can only do typeDefs and resolvers separately.

  app.use(yoga({ schema }));
@fecony
Copy link

fecony commented Sep 9, 2023

Example provided in npm registry and this repo readme is outdated from previous version
You can read how to use plugin on the docs plugin page as they are updated https://elysiajs.com/plugins/graphql-yoga.html

@fecony
Copy link

fecony commented Sep 9, 2023

@SaltyAom How about sending users to the documentation page instead of putting the same code in the readme.md file of the plugin repo? That way, the documentation would become the source of truth instead of trying to keep it up to date with the documentation and vice versa

@arkmech
Copy link
Author

arkmech commented Sep 9, 2023

@fecony , got it. Thanks!

Regardless, would be nice if this was available, for those that do schema stitching

  app.use(yoga({ schema }));

@fecony
Copy link

fecony commented Sep 9, 2023

Regardless, would be nice if this was available, for those that do schema stitching

Yes agreed, I wanted to use https://garph.dev/ once but Elysia plugin doesn't support passing schema. Maybe it would be possible to adjust plugin to let us pass schema or what we do now

But I didn't try to do it and see how hard it would be, pretty sure @SaltyAom can do it while sleeping xd

@arkmech
Copy link
Author

arkmech commented Sep 9, 2023

Regardless, would be nice if this was available, for those that do schema stitching

Yes agreed, I wanted to use https://garph.dev/ once but Elysia plugin doesn't support passing schema. Maybe it would be possible to adjust plugin to let us pass schema or what we do now

But I didn't try to do it and see how hard it would be, pretty sure @SaltyAom can do it while sleeping xd

oh wow...that looks enticing. I might try garph out

@SaltyAom
Copy link
Member

Just wake up, make schema property to accept TypeSource.

Keep in mind that you will not have type-safety from Mobius if you are using external source.

@arkmech
Copy link
Author

arkmech commented Sep 10, 2023

Just upgraded to 0.6.3, and don't see the schema key

@nowlena
Copy link

nowlena commented Sep 10, 2023

Agreed, I'd love to be allowed to pass in our own "schema".

For reference, it's because i want to use Pothos (https:/hayes/pothos)

@arkmech
Copy link
Author

arkmech commented Sep 12, 2023

I'm using graphql-middleware as well. And their applyMiddleware() returns GraphQLSchemaWithFragmentReplacements which is compatible with createYoga() schema type. Don't think there is a way to pull out the typeDefs and resolvers separately from a schema.

schema?: YogaSchemaDefinition<{}> | undefined

If there is anything I can do to help.

@G9000
Copy link

G9000 commented Oct 21, 2023

any plan for this yet? using graphql-tools/merge works but all the type gone 🥲

@renhyl
Copy link
Contributor

renhyl commented Mar 2, 2024

Pull Request: #8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants