-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Types are not generated for introspection query #643
Comments
Interesting. Thanks @FredyC ! I think we might ignore fields that starts with |
@FredyC We are ignoring the internal fields of GraphQL because otherwise it will bloat the results (see https://github.com/dotansimha/graphql-code-generator/blob/master/packages/graphql-codegen-core/src/schema/schema-to-template-context.ts#L27) . I can make this filtering an option, and then it will solve your issue. |
I've noticed that when I use simply a
gives me:
Notice the trailing |
@dotansimha I am having the same issues on the latest version, I really need to do some internal types queries |
I tried to fix it in #1380, could you guys check if that works in your projects? A canary release under |
Fixed in 0.18.0 🎉 |
@dotansimha 0.19.0-alpha.e87c7ccf in this version the services are being generated like this:
They should be like this:
|
@Jonatthu the alpha version you are using is the latest refactor, and it should output without any namespaces at all. |
@dotansimha Well it is having typescript issues or bugs like this, this is giving me a compilation error |
@Jonatthu You shouldn't be probably using alpha version if you look for stability ;) Either way, namespaces are going to be dropped, so you will either have to adapt or stick to a current version for a while. Btw namespaces are legacy and being removed from TypeScript (sadly), so you will do yourself a service if you start adapting for non-namespaces environment. I really recommend you to have a look at https://graphql-code-generator.com/docs/plugins/typescript-react-apollo plugin if you use React. It will generate whole bunch of stuff for you and you don't need to bother with types that much. |
@FredyC I think namespaces was a really good solution to the individual types, I do not understand why the change... |
@Jonatthu Well, ask the Microsoft, they have deprecated namespaces from TypeScript. For the same reason, they are not supported by Babel TypeScript implementation, so it's a kinda wrong path to follow altogether. |
@FredyC So what's the workaround now?
|
@FredyC microsoft/TypeScript#30994 |
Ok, that's certainly new information, but I don't really miss namespaces. I don't follow why do you need them for your use case. You can as well namespace with a custom delimiter of yours (or none), eg. |
First now I am only able to define the type of my query but not of a selection of a section of the query Second on hover the definition of my second property, this definition is really not dev friendly, specially if is really big type And finally, if I wanna strong type this property my only option is to put the base type of this and this tooltip is showing a good definition of my selection BUT this will not match if on my query I only selected one of the properties. |
Well, sorry, I don't have any viable workarounds here. Since I started using generators, I don't bother with types that much to be bothered by it. |
@FredyC, @dotansimha |
@dotansimha Looks like introspection namespaces are not being created, is there a flag that we are missing on the docs? |
@Jonatthu actually, the internal introspection types was not included in 0.18, so it's not an issue with backward compatibility. |
@dotansimha What’s the solution? Is it something on development or something that I can use now? |
@Jonatthu They are generated only if one of your documents asks for it. So if your operations are querying for fields that are declared as internal introspection fields, it will generate those fields as part of your @kamilkisiela implemented this a while ago. |
This is not correct. |
@dotansimha @FredyC I know could be hard but based on this... Could be bring back the namespace convention that this project used to have?
Would be nice to keep the old behavior creating interfaces instead of grabbing parts of a type this way
Anyways this is an amazing project and it is doing a great job, but sometimes old features are still totally fine to keep. Specially if helps to devs to maintain and understand the code generated right away. Maybe we can improve the compatibility plugin some how to generate this interfaces but aside of that, the query interface should use this models instead this:
This new way to use |
@Jonatthu we choose this path because we would to be able to create base package and use it. I think, maybe, in the future, we can add a configuration for resolving the type and not using |
@dotansimha I think for the future would be a great investment, but thanks for all the current work, the cli is looking awesome and feeling professional. |
@Jonatthu I opened a new issue for that: #1925 , and regarding resolving the actual type: #1904 (comment) |
Describe the bug
I have a query like this which reads introspection in runtime to figure user permissions. Unfortunately, the generated types do not include the
GUserPermissions
type at all. But if I add something else to that query, it appears there, but without the introspection part.To Reproduce
I am using API approach and call it like this. Full introspection is generated in JSON file. I've checked and it includes types for
__schema
, so that should be a problem.Expected behavior
To have TypeScript types based on introspection query.
Environment:
The text was updated successfully, but these errors were encountered: