svelte-add / graphql-server

⚠️ MOVED: https://github.com/svelte-add/svelte-add/ ⚠️ (out of date) A command to add a GraphQL server to your Svelte project
MIT License
31 stars 1 forks source link

Type-graphql issue #5

Open MirrorBytes opened 3 years ago

MirrorBytes commented 3 years ago

Type reflection seems to be buggy. I'm getting random errors like this:

"Unable to infer GraphQL type from TypeScript reflection system. You need to provide explicit type for 'XXXX' of 'XXXX' class."

This is happening with reflect-metadata being imported in the endpoint and the schema file. Importing it into each individual class file doesn't seem to work either. Any ideas?

babichjacob commented 3 years ago

Do you need to enable "emitDecoratorMetadata": true somewhere in TSConfig?

MirrorBytes commented 3 years ago

@babichjacob Already done, along with "experimentalDecorators" being set to true. It's doing it for Entities and Resolvers

babichjacob commented 3 years ago

Can you provide a repository?

MirrorBytes commented 3 years ago

@babichjacob Sorry, had to create one: https://github.com/MirrorBytes/phorm-kit-vercel I trimmed a bit out, including the database connection.

babichjacob commented 3 years ago

I'll have to leave this issue open for a few days because school has to be a higher priority right now. I'm sorry.

MirrorBytes commented 3 years ago

No need to be sorry! I can't seem to figure out if this is a problem with decorators and metadata in sveltekit or specifically graphql.

MirrorBytes commented 3 years ago

@babichjacob

So, I moved the graphql implementation to the api directory that vercel uses, and changed the function to a vercel centric one. It stills errors.

However, if I ditch graphql-helix and use apollo-server-micro, everything works as expected. I believe this is an issue with graphql-helix not liking type-graphql and/or metadata reflection.

I'll update the repo in a little bit incase anyone else has this issue.

MirrorBytes commented 3 years ago

Wait, I lied. This has nothing to do with graphql-helix. It's to do with sveltekit and type reflection, just tried to move it out of the api directory, and it's doing the exact same thing.

MirrorBytes commented 3 years ago

I opened an issue in the SvelteKit repo as I think it pertains to that as opposed to this library: https://github.com/sveltejs/kit/issues/798

babichjacob commented 3 years ago

Relevant upstream issue / comment: https://github.com/sveltejs/kit/issues/1327#issuecomment-831901931