wp-graphql / wp-graphql-jwt-authentication

Authentication for WPGraphQL using JWT (JSON Web Tokens)
GNU General Public License v3.0
340 stars 74 forks source link

Cannot be installed in conjunction with 'wp-graphql-woocommerce' #67

Open efoken opened 4 years ago

efoken commented 4 years ago

I just tried to install this plugin in conjunction with the WPGraphQL WooCommerce addon, but Composer blocks installation because of firebase/php-jwt 5.0 which is required by 'wp-graphql-woocommerce' and this package required version 4.0

Note that I'm using Bedrock with Composer to install WordPress plugins and I'm installing WPGraphQL and addons using GitHub URLs.

Here's what Composer outputs:

Loading composer repositories with package information
Updating dependencies (including require-dev)         
Your requirements could not be resolved to an installable set of packages.

Problem 1
    - Installation request for wp-graphql/wp-graphql-woocommerce dev-develop -> satisfiable by wp-graphql/wp-graphql-woocommerce[dev-develop].
    - wp-graphql/wp-graphql-jwt-authentication dev-master requires firebase/php-jwt ^4.0 -> satisfiable by firebase/php-jwt[v4.0.0].
    - wp-graphql/wp-graphql-jwt-authentication dev-master requires firebase/php-jwt ^4.0 -> satisfiable by firebase/php-jwt[v4.0.0].
    - Conclusion: don't install firebase/php-jwt v4.0.0
    - Installation request for wp-graphql/wp-graphql-jwt-authentication dev-master -> satisfiable by wp-graphql/wp-graphql-jwt-authentication[dev-master].
jasonbahl commented 4 years ago

@efoken interesting. As far as I know these plugins should install their dependencies to their own plugin directories, but we can look into it.

Fredrik-J commented 4 years ago

I got the same problem.

composer require wp-graphql/wp-graphql-jwt-authentication
Using version ^0.3.5 for wp-graphql/wp-graphql-jwt-authentication
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Can only install one of: firebase/php-jwt[v4.0.0, v5.0.0].
    - Can only install one of: firebase/php-jwt[v5.0.0, v4.0.0].
    - Can only install one of: firebase/php-jwt[v4.0.0, v5.0.0].
    - wp-graphql/wp-graphql-jwt-authentication v0.3.5 requires firebase/php-jwt ^4.0 -> satisfiable by firebase/php-jwt[v4.0.0].
    - Installation request for wp-graphql/wp-graphql-jwt-authentication ^0.3.5 -> satisfiable by wp-graphql/wp-graphql-jwt-authentication[v0.3.5].
    - Installation request for firebase/php-jwt (locked at v5.0.0) -> satisfiable by firebase/php-jwt[v5.0.0].

Installation failed, reverting ./composer.json to its original content.
efoken commented 4 years ago

@jasonbahl If I download the plugins as ZIP file and install them, of course, it works as all plugins have their own vendor folder. But if one uses Bedrock and installs these plugins via Composer, all packages install their dependencies into the root vendor directory, so that they can conflict

jasonbahl commented 4 years ago

@efoken is there a way to configure composer.json to make sure these dependencies get installed into their respective project vendor folders? Unless I'm mistaken (@kidunot89 can clarify) WPGraphQL JWT Auth and WPGraphQL for WooCommerce aren't tightly coupled and should be able to run independently or together, regardless of their own composer dependencies.

If we could tell composer to install composer dependencies of the JWT plugin under the JWT plugin vendor directory, and the dependencies for WooGraphQL under the WooGraphQL vendor directory, that might solve the issue.

If WooGraphQL requires WPGraphQL JWT Auth to be active to use, then perhaps WooGraphQL could just remove the composer dependency altogether, document that WPGraphQL JWT Auth needs to be active, and then call the functions/classes that are included by that plugin being active?

I'm not opposed to updating the firebase dependency for this plugin, but I do think the 2 plugins should be able to iterate without a tight coupling to each other if we can make that happen.

kidunot89 commented 4 years ago

@jasonbahl WooGraphQL using firebase/php-jwt to create the Session tokens, but I hadn't don't any testing using the composer package. Is it possible to simply update WPGraphQL-JWT-Auth to 5.0, I don't believe it'll cause any breaks code-wise.

kidunot89 commented 4 years ago

@efoken Have you tried deleting your vendor and composer.lock and running composer install --no-dev?

efoken commented 4 years ago

@jasonbahl Composer handles dependencies like that, we have only one vendor directory, so only one version of a package can be installed – no matter what. The only solution is to update firebase/php-jwt to 5.x, the same version as it is used in wp-graphql. I've created a PR for that #84

https://stackoverflow.com/questions/27150695/how-does-composer-handle-multiple-versions-of-the-same-package/27153452

@kidunot89 I tried ;-)