-
Notifications
You must be signed in to change notification settings - Fork 2k
Redesign type/schema API to remove instanceof checks #491
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
Comments
Looks like this is because of a limitation in Flow? |
BTW, this is probably not an unfamiliar limitation, but I believe you can work around this by using symlinks in the linked packages. |
By limitation in Flow, do you mean that it's something that first needs to be fixed on their side before the instance of checks can be removed? Should I file an issue? Thanks for the tip about symlinking graphql, that certainly helps! |
We've run into this a bunch during Relay development as well. I think the answer might be to fix npm though. |
Yeah - unfortunately we currently rely on instanceof both for how graphql works, but also because of how Flow works. I don't think it's crazy to change this in the near future, but that would be a very real breaking change for all those dependent on the current types API. |
We ran into an issue where we got:
ie, it was telling us that we weren't allowed to say If so, maybe one partial solution would be to make |
Hi ya'll, This is really annoying issue. Would everyone be open to leveraging class GraphQLObjectType {
static [Symbol.hasInstance](foo) {
return foo && foo[Symbol.for('GraphQLObjectType')];
}
}
GraphQLObjectType.prototype[Symbol.for('GraphQLObjectType')] = true; Should Allow the |
This has bitten me multiple times now:
It's almost impossible to not end up with multiple graphql versions when using a lot of graphql tooling, because graphqljs is still 0.x, so it is not under semver and npm treats the difference between 0.15 and 0.16 as a breaking version, resulting in package duplication if one package depends on ^0.16 and one on ^0.15.
|
If somebody is having trouble with this, I just learned that
If somebody runs into errors like |
Great suggestion @amannn - that's exactly what we do at Facebook for this module and a few others where having a single version is important. |
While that is a viable workaround for yarn users imo this shouldn't be required. Packages should state what versions they are compatible with and npm/yarn should be able to install dependencies, installing multiple versions where needed, and everything should work as long as version requirements are satisfied. Imo the user shouldn't have to hack the dependency graph (essentially overpowering defined dependency ranges) to make this work |
COUGH #989 ;) |
This was resolved in v0.12 and should be closed |
hmm it is technically resolved but doesn't really solve the issue. It still uses instanceof checks but moves it to a utility function. The issue is still that this will fail if you have two instances of graphql installed |
After gathering more insight on this issue over the recent months, I think it's time to close this issue. The problem here is that Overall, avoiding duplicate bytes in your bundle and avoiding hard to debug issues is more important than making Breaking the problem down a bit, we've made serious improvements in the most recent versions of the library. First, predicate utility functions were introduced so that no user of GraphQL.js needs to use |
my main problem with this is that there is no way to solve this without using poorly documented feature in
I don't understand this rationale. Why do care about the byte size of my http server or tool. I don't care about |
Yeah I don't really understand that argument either. This is mostly about GraphQL tooling, which you have as devDependencies, and I don't care at all about how many KB I am downloading for that. I am not bundling them. I see the point of not wanting to allow different arbitrary versions of graphqljs to work with each other. But currently, it's not possible to even have multiple installations of the same version work with each other, and that is the problem. Say you have two GraphQL tools installed -
Now
The package manager acted 100% correctly: It delivered every package its declared dependency of Did the devs of the project or the packages do something wrong here? No. The fact that get-graphql-schema depends on 0.11 shouldn't matter, it is only a CLI to download a schema, and it does so just fine and fulfils its contract. The only workaround I know with npm is to install
Which is obviously bad because now every common shared dependency (in this example, lodash) is not deduplicated anymore. Such a workaround should not be needed, it's incredibly hard for a newcomer to understand what and why he/she has to do this, which harms the growth of graphql in the community. The only other option is to use yarn's |
I've had the most luck with using a monorepo setup and yarn's resolutions field. I've had no issues with this configuration. For non-monorepos that I needed to I generally disagree with the decision here, but at least for my preferred use case (monorepo), the solution is not too bad – as long as the library never releases backward-incompatible changes that force tooling libs to be updated before graphql is updated (due to the version override). |
Well the last three releases (0.10, 0.11, 0.12) with breaking changes where in May, August and December, so on average a breaking release every few months. If you use yarn's |
Running it externally leads to issues with different `graphql-js` packages as described here: graphql/graphql-js#491 This setup also simplifies debugging.
I got this issue today, even though I have not been updating packages. I tripple checked all the commits and nothing in package.json/yarn.lock has been changed in a while. |
this resolution property helps with duplication errors with graphql, more info graphql/graphql-js#491
this resolution property helps with duplication errors with graphql, more info graphql/graphql-js#491
Add resolutions directive for graphql This resolution directive helps yarn know how to resolve version conflicts for GraphQL Based on solution propossed on: graphql/graphql-js#491 (comment)
Per the discussion in #377
The current behavior makes it impossible to use graphql with npm links which is a huge problem if you have multiple interdependent packages as you'll have to rerun npm install for every single change and waste a lot of time.
The text was updated successfully, but these errors were encountered: