graphql-python / graphene-federation

Federation implementation for Graphene.
MIT License
40 stars 10 forks source link

When is this package ready for usage with graphene 3.1? #2

Closed hansehe closed 2 years ago

hansehe commented 2 years ago

Hi, and this is a much requested package so thanks for the initiative!

I'm having trouble combining this package with graphene version 3.1, and I cannot find the package on pypi.org. Is there a reason to that, or is it not ready yet? If so, do you think it will be ready soon?

I cannot start using graphene 3.1 without proper graphql federation support.

My goal is to have this graphql gateway work with graphene 3.1 and graphql federation:

It's currently working with graphene 2.9 and the graphene_federation 0.1.0 package. It also works with the Strawberry graphql package, both for graphql federation v1 and v2.

erikwrede commented 2 years ago

Hey Hans, this package is a fork of the original preply/graphene-federation package including changes and updates to make it compatible with v3.

@tcleonard probably knows best what is required to support Graphene 3.1.

Since the original package is hosted by preply, they also own the PyPi access. We haven't had the time to contact them yet, but still wanted to make the updates visible to everyone. This was possible due to the MIT License of the preply package. I will try to contact them soon. Until then, you can use pip/conda to install the release tag of this repo:

pip install https://github.com/graphql-python/graphene-federation/archive/refs/tags/v3.0.0.tar.gz
hansehe commented 2 years ago

Ok, I'll try it out and thanks in the meantime.

tcleonard commented 2 years ago

What kind of issues do you get with graphene 3.1? I am using it with graphene 3.x already but maybe I didn't encounter the same issue as you do...

hansehe commented 2 years ago

Using graphene 3.1 had a version dependency on graphql-core, that doesn't match the version required by graphene-federation. And due to that, my application won't start it seems.

erikwrede commented 2 years ago

This could be the cause: https://github.com/graphql-python/graphene-federation/blob/c65d2bb18836c244ed2c8da55515d1b652f4845c/setup.py#L36

The referenced PR has since been released, so we should be able to increase the version

erikwrede commented 2 years ago

I've fixed setup.py. @hansehe Please try this PR out: https://github.com/graphql-python/graphene-federation/pull/3

pip install git+https://github.com/graphql-python/graphene-federation.git@refs/pull/3/head
hansehe commented 2 years ago

Hi again, and sorry for delaying.

So your new graphene-federation package solved the basic problem with my service not working, so now that works! Both queries, mutations and subscriptions (through websockets) work.

However, I still cannot get my graphql-gateway service work with the new versions of graphene3 and graphene-federation. The graphql-gateway is a node based apollo server with the graphql federation implementation.

I get it to work with graphene2 and corresponding version of graphene-federation, and it works with https://strawberry.rocks/.

Do you see any reason on why it doesn't work?

The graphl-gateway service throws this exception:

"Error: request to http://localhost:8181/graphql/ failed, reason: connect ECONNREFUSED 127.0.0.1:8181",
            "    at new CombinedError (/app/node_modules/graphql-tools/src/stitching/errors.ts:85:5)",
            "    at Object.checkResultAndHandleErrors (/app/node_modules/graphql-tools/src/stitching/errors.ts:107:11)",
            "    at Object.<anonymous> (/app/node_modules/graphql-tools/src/stitching/delegateToSchema.ts:94:14)",
            "    at step (/app/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:40:23)",
            "    at Object.next (/app/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:21:53)",
            "    at fulfilled (/app/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:12:58)",
            "    at <anonymous>",
            "    at process._tickDomainCallback (internal/process/next_tick.js:228:7)"

So the graphql-gateway service is able to initially federate the schema from the graphene3 service, but raises an exception when delegating a request to the service. It states clearly some schema delegation error.

tcleonard commented 2 years ago

Are you sure it's not a problem in your schema itself... it's hard to tell without the query in question and the corresponding schema. I have been able to use this lib with apollo gateway and a federated schema using graphene 3.1 so I'm not sure what are the specificity of your setup that cause problem...

hansehe commented 2 years ago

Ok, maybe there is something wrong with my gateway then. Do you have an example code of your apollo gateway that I can test?

hansehe commented 2 years ago

Finally made it work! Seems like I did something wrong, but I made it work like this:

https://github.com/hansehe/graphql-gateway/blob/master/examples/GrapheneExample/main.py