Skip to content
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

Meteor package depends on apollo-link-ddp client code. #315

Open
alxmhe opened this issue Jun 25, 2019 · 6 comments
Open

Meteor package depends on apollo-link-ddp client code. #315

alxmhe opened this issue Jun 25, 2019 · 6 comments

Comments

@alxmhe
Copy link

alxmhe commented Jun 25, 2019

Because meteor/swydo:ddp-link requires an install of apollo-link-ddp, we also need to install the npm package graphql.

} from 'apollo-link-ddp';

These result in 2 graphql packages in the node_modules directory and conflicts.

Exception while invoking method '__graphql' TypeError: execute is not a function
at Promise.asyncApply (packages/swydo:ddp-apollo/lib/server/createGraphQLMethod.js:28:12)

I would prefer not importing the Apollo Link DDP npm module for the client in the server code.

@jamiter
Copy link
Contributor

jamiter commented Jun 25, 2019

Hm, I believe the latest version of the client code (apollo-link-ddp) does not depend on graphql anymore, so that should not be an issue. We can still remove the dependency of course, but please check if you are using the latest version of apollo-link-ddp.

@alxmhe
Copy link
Author

alxmhe commented Jun 25, 2019

It seems apollo-link-ddp requires apollo-link (peer dependency) and it itself requires graphql (peer dependency).

Error: Cannot find module 'apollo-link'

Error: Cannot find module 'graphql/language/visitor'

@alxmhe
Copy link
Author

alxmhe commented Jun 25, 2019

Here is the full issue I have when the 2 graphql are present :

Exception while invoking method '__graphql' Error: Cannot use GraphQLSchema "[object GraphQLSchema]" from another module or realm.

Ensure that there is only one instance of "graphql" in the node_modules
directory. If different versions of "graphql" are the dependencies of other
relied on modules, use "resolutions" to ensure only one version is installed.

https://yarnpkg.com/en/docs/selective-version-resolutions

Duplicate "graphql" modules cannot be used at the same time since different
versions may have different capabilities and behavior. The data from one
version used in the function from another could produce confusing and
spurious results.

at instanceOf (/node_modules/graphql/jsutils/instanceOf.js:37:13)
at isSchema (/node_modules/graphql/type/schema.js:34:34)
at assertSchema (/node_modules/graphql/type/schema.js:38:4)
at validateSchema (/node_modules/graphql/type/validate.js:53:28)
at assertValidSchema (/node_modules/graphql/type/validate.js:77:16)
at assertValidExecutionArguments (/node_modules/graphql/execution/execute.js:146:35)
at executeImpl (/node_modules/graphql/execution/execute.js:67:3)
at execute (/node_modules/graphql/execution/execute.js:62:256)
at Promise.asyncApply (packages/swydo:ddp-apollo/lib/server/createGraphQLMethod.js:28:12)

I hope this helps somehow.

@jamiter
Copy link
Contributor

jamiter commented Jun 25, 2019

@jamiter
Copy link
Contributor

jamiter commented Jun 25, 2019

May I ask, where is the second graphql installation coming from? Although it would be better not to depend on apollo-link-ddp on the server, you could still just install one version of graphql. Or do the dependency versions mismatch?

@alxmhe
Copy link
Author

alxmhe commented Jun 26, 2019

In my setup, most of my backend setup is in a Meteor package. I would like to "Npm.depends" graphql and apollo's links.
With the peer dependency on apollo-link-ddp, I need to add the NPM packages in all my projects package.json. And then add apollo-link and graphql.

The second graphql installation came from the Meteor package. I put the graphql-tools needed for building the schema with makeExecutableSchema and call setup({ schema }) in ddp-apollo.

Removing all GraphQL NPM packages from Npm.depends and moving them to the apps' package.json works for now but adds a bit of work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants