Do not create globalTypes.ts when it is empty#2163
Do not create globalTypes.ts when it is empty#2163paulmelnikow wants to merge 5 commits intoapollographql:masterfrom
Conversation
Fix apollographql#2080 Alternative to apollographql#2055
b94a187 to
d35143f
Compare
|
The Node 8 and 10 builds are failing with TypeErrors that are generated somewhere in the config system. I can't reproduce these locally (even when using Node 8 or 10). Any idea what might be causing these? |
|
Hi 👋, is there any chance (@maintainers) that we can take a look at this issue? It would also help if the file just has an empty export |
|
I tried it on my project and it did not work. EDIT: I think this is a simple fix: import { isScalarType } from 'graphql'
...
const usedTypes = context.typesUsed.filter(t => !isScalarType(t))
if (usedTypes.length > 0) {
....Just to be clear: I am not a maintainer. Maybe @abernix can help :) |
| output: generatedGlobalFile.fileContents | ||
| }; | ||
|
|
||
| if (context.typesUsed.length > 0) { |
There was a problem hiding this comment.
context.typesUsed.filter(t => !isScalarType(t)).length > 0
to avoid custom scalar types
There was a problem hiding this comment.
Happy to make this change, though it should probably have a test. What's the behavior you're looking for, exactly?
There was a problem hiding this comment.
Custom scalars like (in schema terms): scalar MyCustomScalar are inside this array of typesUsed. However, these do not generate anything in the globals files since the generator does can not know what the data structure is actually. This would still leading to an empty file.
https://www.apollographql.com/docs/apollo-server/schema/custom-scalars/
The test scenario would require a custom scalar type and a query that does not use any enums or other globals, but returns the custom scalar.
|
its important that this gets merged, it leads to completily pointless problems that could easily be avoided. |
…ypes # Conflicts: # CHANGELOG.md
Fix #2080
Alternative to #2055
TODO:
*Make sure changelog entries note which project(s) has been affected. See older entries for examples on what this looks like.