graphql-server icon indicating copy to clipboard operation
graphql-server copied to clipboard

Type-graphql issue

Open MirrorBytes opened this issue 4 years ago • 10 comments

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?

MirrorBytes avatar Mar 30 '21 20:03 MirrorBytes

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

babichjacob avatar Mar 30 '21 20:03 babichjacob

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

MirrorBytes avatar Mar 30 '21 21:03 MirrorBytes

Can you provide a repository?

babichjacob avatar Mar 30 '21 21:03 babichjacob

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

MirrorBytes avatar Mar 30 '21 21:03 MirrorBytes

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.

babichjacob avatar Mar 31 '21 01:03 babichjacob

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 avatar Mar 31 '21 02:03 MirrorBytes

@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 avatar Mar 31 '21 16:03 MirrorBytes

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 avatar Mar 31 '21 17:03 MirrorBytes

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

MirrorBytes avatar Mar 31 '21 18:03 MirrorBytes

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

babichjacob avatar May 04 '21 16:05 babichjacob