Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upRemove *.gql/*.graphql types #881
Conversation
these types conflict with similar declarations in many projects
|
I know it's been a while, but I still think this is an issue and should be fixed - maybe in the 4.x version, as this might be considered a breaking change. |
|
Hi, As a temporary workaround (I hope), I added the following lines in my {
"scripts": {
"postinstall": "rm -f node_modules/vue-apollo/types/gql.d.ts"
}
}The file |
|
I lost about a couple of hours today trying to hunt down why type defs couldn't be resolved for any .gql files because of this. It's all sorted out now, but it was quite frustrating finding the one commit that had automatically updated vue-apollo from 3.0.3 to 3.0.4 and broke our build. I would have preferred this was included in 4.x as @jbbr suggested. I'm hoping greater care will be taken in future releases. That said, I appreciate the awesome work you guys are doing. Many thanks. |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

The
*.graphqlmodule declaration conflicts with similar declarations in many projects. And in my opinion it's out of the scope of this library. I will try to explain my reasoning:Unfortunately TypeScript doesn't have an option to exclude types from NPM packages. So these these types are loaded without a way to opt-out.
But many projects might have different needs for *.graphql typings. e.g:
Add specific modules for every
*.graphqlfileThe populare tool "Graphql Code Generator" can autogenerate imports for graphql-files, example here: https://graphql-code-generator.com/docs/plugins/typescript-graphql-files-modules#example
Allow named imports from
*.graphql-files (e.g Queries & Mutations) usinggraphql-tag/loader:e.g
import { SomeQuery, AnotherQuery } from 'somefile.graphql'.One way to allow this is by a simple any declaration:
declare module '*.graphql';Not every typescript project has some loader configured to load
*.graphql-files.So having these types by default makes incorrect assumptions.
These kind of custom declarations are not possible when using vue-apollo 3.x due to this fixed type which is bundled with vue-apollo.
I propose to just remove the type file again and add docs which explain the situation.
Failing example
Error:
Workaround
Downgrade and pin
3.0.0-rc.7. Packge json: