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

Federation v2 support added #4

Merged
merged 96 commits into from
Mar 23, 2023

Conversation

arun-sureshkumar
Copy link
Contributor

@arun-sureshkumar arun-sureshkumar commented Oct 4, 2022

Add Support to Federation v2

apollo-federation-subgraph-compatibility - Passed

@arun-sureshkumar
Copy link
Contributor Author

@arun-sureshkumar
Copy link
Contributor Author

@erikwrede - Can you please review the PR?

@arun-sureshkumar arun-sureshkumar force-pushed the support-federation-v2 branch 2 times, most recently from b5a7e67 to 10bcb9a Compare October 6, 2022 10:15
@erikwrede
Copy link
Member

@arun-strollby great job! I'll have a look in the weekend, but the final word should be on @tcleonard or @patrick91, since they are more experienced with federation.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 3196356399

  • 152 of 196 (77.55%) changed or added relevant lines in 11 files are covered.
  • 3 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-7.8%) to 83.25%

Changes Missing Coverage Covered Lines Changed/Added Lines %
graphene_federation/override.py 10 14 71.43%
graphene_federation/tag.py 10 14 71.43%
graphene_federation/service.py 43 54 79.63%
graphene_federation/inaccessible.py 19 31 61.29%
graphene_federation/shareable.py 19 32 59.38%
Files with Coverage Reduction New Missed Lines %
graphene_federation/service.py 3 88.33%
Totals Coverage Status
Change from base Build 3015879032: -7.8%
Covered Lines: 333
Relevant Lines: 400

💛 - Coveralls

@coveralls
Copy link

coveralls commented Oct 6, 2022

Pull Request Test Coverage Report for Build 3196356399

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 155 of 188 (82.45%) changed or added relevant lines in 13 files are covered.
  • 28 unchanged lines in 4 files lost coverage.
  • Overall coverage decreased (-7.8%) to 83.25%

Changes Missing Coverage Covered Lines Changed/Added Lines %
graphene_federation/entity.py 12 13 92.31%
graphene_federation/override.py 6 8 75.0%
graphene_federation/tag.py 6 8 75.0%
graphene_federation/service.py 60 65 92.31%
graphene_federation/inaccessible.py 11 21 52.38%
graphene_federation/shareable.py 19 32 59.38%
Files with Coverage Reduction New Missed Lines %
graphene_federation/provides.py 1 96.67%
graphene_federation/types.py 3 75.0%
graphene_federation/service.py 9 88.33%
graphene_federation/entity.py 15 70.37%
Totals Coverage Status
Change from base Build 3015879032: -7.8%
Covered Lines: 333
Relevant Lines: 400

💛 - Coveralls

@erikwrede
Copy link
Member

gentle push, let's get this over the finish line 🙂 @patrick91 @arun-sureshkumar @adarshdigievo

@patrick91
Copy link
Member

@arun-sureshkumar @arunsureshkumar @adarshdigievo are you planning to update this PR or shall I take over? 😊

@arunsureshkumar
Copy link
Collaborator

arunsureshkumar commented Feb 21, 2023 via email

@Meemaw
Copy link

Meemaw commented Mar 7, 2023

@arunsureshkumar any update on getting this in?

@patrick91
Copy link
Member

@arun-sureshkumar let me know if you want us to update the PR 😊 happy to take over it :D

…ort-federation-v2

# Conflicts:
#	README.md
#	examples/inaccessible.py
#	examples/override.py
#	examples/shareable.py
#	examples/tag.py
#	graphene_federation/entity.py
#	graphene_federation/extend.py
#	graphene_federation/external.py
#	graphene_federation/inaccessible.py
#	graphene_federation/override.py
#	graphene_federation/provides.py
#	graphene_federation/requires.py
#	graphene_federation/service.py
#	graphene_federation/shareable.py
#	graphene_federation/tag.py
#	graphene_federation/tests/test_key.py
# Conflicts:
#	graphene_federation/extend.py
#	graphene_federation/service.py
@arun-sureshkumar
Copy link
Contributor Author

arun-sureshkumar commented Mar 14, 2023

@arun-sureshkumar let me know if you want us to update the PR 😊 happy to take over it :D

@patrick91 Please check now, let me know your comments!

@arun-sureshkumar
Copy link
Contributor Author

Currently playing around with the PR for my final review and it's working great so far!

I have some minor remarks. We should discuss the behavior of the @shareable directive on interfaces:

@shareable
class ReviewInterface(Interface):
    interfaced_body = graphene.String()

class Review(ObjectType):
    class Meta:
        interfaces = (ReviewInterface,)

    id = graphene.ID()
    body = graphene.String()
    interfaced_body = graphene.String()

    def resolve_interfaced_body(self, info):
        return "".join([self.body, "interfaced"])

Currently, this ignores the directive on the interfaces (i.e. it is not included in the SDL). According to the Federation Docs, starting from federation v2.2 this should not be allowed instead of ignored:

The @Shareable directive is about indicating when an object field can be resolved by multiple subgraphs. As interface fields are not directly resolved (their implementation is), @Shareable is not meaningful on an interface field and is not allowed (at least since federation 2.2; earlier versions of federation 2 mistakenly ignored @Shareable on interface fields).

Since we are just introducing Federation v2 here, maybe we should adopt this behavior from the start to avoid making breaking changes later on. What do you guys think?

This will not be allowed instead of ignored, updating the code.

Fix: Lint Error
Passed: Test Cases
@arun-sureshkumar
Copy link
Contributor Author

Correcting my above post, it seems like Interfaces in general do not work with the directives yet. For example: inaccessible on graphene.Interface doesn't seem to work either, using strawberry federation as a working python reference:

@strawberry.interface(directives=[Inaccessible()])
class ReviewInterface:
    interfaced_body: str

@strawberry.type
class Review(ReviewInterface):
    id: int
    body: str

Resulting SDL:

type Review implements ReviewInterface {
  interfacedBody: String!
  id: Int!
  body: String!
}

interface ReviewInterface @inaccessible {
  interfacedBody: String!
}

Versus the SDL from my example above using @inaccessible instead of @shareable:

type Review implements ReviewInterface {
  interfacedBody: String
  id: ID
  body: String
}

interface ReviewInterface {
  interfacedBody: String
}

As a consequence, ReviewInterface is included in the stitched schema.

Seems like the Apollo Subgraph Compatibility test doesn't incorporate this case, which is probably why it was missed. Maybe it makes sense to add some additional tests specifically for Interfaces here. On the other hand, I don't want to hold the release of this back if it's too much work to add. What do you guys think? @patrick91 @arun-sureshkumar

This issue is fixed.

@arun-sureshkumar arun-sureshkumar requested review from patrick91 and removed request for tcleonard March 14, 2023 19:50
@erikwrede
Copy link
Member

Awesome, thanks for the changes! Can we add some tests for the added behavior? Apart from that LGTM!

@arun-sureshkumar
Copy link
Contributor Author

Awesome, thanks for the changes! Can we add some tests for the added behavior? Apart from that LGTM!

Sure thing!

@arun-sureshkumar
Copy link
Contributor Author

Awesome, thanks for the changes! Can we add some tests for the added behavior? Apart from that LGTM!

Sure thing!

Please check and let me know if anything to be added.

@arun-sureshkumar arun-sureshkumar requested review from erikwrede and removed request for patrick91 March 14, 2023 21:25
@patrick91
Copy link
Member

@arun-sureshkumar @erikwrede I'll do a review in the couple of days 😊

@patrick91
Copy link
Member

Just tested this locally and it seems to work well :D @erikwrede what are the next steps for getting this released?

@patrick91 patrick91 merged commit 8b5e1e7 into graphql-python:main Mar 23, 2023
@erikwrede
Copy link
Member

Thanks everyone for the amazing work on this! 🎉

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

Successfully merging this pull request may close these issues.

None yet

7 participants