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

Implement support for interfaces implementing interfaces #740

Merged
merged 11 commits into from
Jan 23, 2021

Conversation

Kingdutch
Copy link
Contributor

@Kingdutch Kingdutch commented Nov 26, 2020

What's new
This adds the option to have interfaces implement other interfaces. I’ve mostly looked at the interface implementation of normal type. A lot of the work in the parser will continue to work similarly because the specification forces objects to implement all interfaces that a parent interface may implement.

Tests
Tests have been implemented according to https://github.com/graphql/graphql-js/pull/2084/files

Backwards Compatibility
There was some discussion in #728 about whether this should be postponed to 15.0 or could be included included in 14.x. From what I can tell so far, all code changes are either backwards compatible, or internal to the library (private in a class). Additionally, the changes don't make any schema that's currently valid, invalid. It does allow schema's that were previously invalid to be valid, but that's not a breaking change :)

Cheers!
I want to commend the previous contributors to this project on the comments littered throughout the codebase. It has helped me using the library in extending projects but also made it easy to understand what is going on while working in the project. I think this project could be a great way for people to learn about ASTs and parsers :D

Closes #728

@Kingdutch
Copy link
Contributor Author

Tests are currently blocked by #741

@coveralls
Copy link

coveralls commented Nov 27, 2020

Coverage Status

Coverage increased (+0.1%) to 86.375% when pulling 1f2a1e4 on Kingdutch:master into 769a474 on webonyx:master.

@Kingdutch Kingdutch marked this pull request as ready for review November 27, 2020 12:02
@spawnia
Copy link
Collaborator

spawnia commented Nov 27, 2020

This library sticks pretty close to the reference implementation. For the tests, you should be able to pretty much copy graphql/graphql-js#2084

@Kingdutch
Copy link
Contributor Author

I've added the tests from the linked PR :D Let's see if this works in one go or I made a booboo somewhere (or it reveals an implementation error) ^^

@Kingdutch
Copy link
Contributor Author

Kingdutch commented Nov 27, 2020

Wow, that process was a lot rougher than I expected. Who would've guessed it isn't easy to reliably apply a JavaScript diff to a PHP project ^^

Nearly there though(?)

This ports the JavaScript tests for `RFC: Allow interfaces to
implement other interfaces` to PHP. This should ensure that there is
sufficient test coverage for the changes made to support interfaces
implementing interfaces.

Tests taken from https://github.com/graphql/graphql-js/pull/2084/files
including any typoes in test description strings to aid in comparison.
This is part of the update to allow interfaces to implement interfaces.
A single extend statement to add an implementation of an interface
without field declarations is valid. This was caught by tests and brings
in a change from graphql/graphql-js#2084
Part of the work done to implement interfaces implementing interfaces.
This was caught by test and improves on the previously done changes for
the SchemaValidationContext by implementing
`validateTypeImplementsAncestors` which was missing.
Co-authored-by: Benedikt Franke <benedikt@franke.tech>
@spawnia
Copy link
Collaborator

spawnia commented Dec 10, 2020

@Kingdutch mind if I modify the PR to clarify type signatures? That helps me understand the changes better.

@Kingdutch
Copy link
Contributor Author

@spawnia Go for it! That's why "allow modifications by maintainers" is enabled :)

Kingdutch added a commit to goalgorilla/open_social that referenced this pull request Dec 11, 2020
This solves some issues where types couldn't be reconciled because they
implemented multiple interfaces. The PR for this in the GraphQL PHP
project is now far enough along (all tests passing) that this should be
available in an update for us in time.

See: webonyx/graphql-php/pull/740
Copy link
Collaborator

@spawnia spawnia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work, big effort 👍

@Kingdutch
Copy link
Contributor Author

@spawnia It looks like your last changes introduced a coding standards error, any idea why?

@spawnia
Copy link
Collaborator

spawnia commented Dec 15, 2020

@spawnia It looks like your last changes introduced a coding standards error, any idea why?

I think the array shape was the culprit: 602bf4e

@Kingdutch
Copy link
Contributor Author

Cool! Then this is all green again and ready to be committed :D

@spawnia spawnia requested a review from vladar December 15, 2020 16:07
Kingdutch added a commit to goalgorilla/open_social that referenced this pull request Jan 8, 2021
This solves some issues where types couldn't be reconciled because they
implemented multiple interfaces. The PR for this in the GraphQL PHP
project is now far enough along (all tests passing) that this should be
available in an update for us in time.

See: webonyx/graphql-php/pull/740
Kingdutch added a commit to goalgorilla/open_social that referenced this pull request Jan 8, 2021
The GraphQL PHP library has a PR ready to implement support for
interfaces implementing other interfaces, which is supported by the
GraphQL spec. This is relied upon by some of the types in Open
Social.

We add the changes as a patch to the library so that we can use the
version that's shipped with drupal/graphql.

See webonyx/graphql-php#740
Copy link
Member

@vladar vladar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's awesome. Such a huge work! Thank you 👍

There is one small breaking change in BreakingChangesFinder 😄 (see my comment below) It makes me hesitant about publishing it as a minor. What if we revert constant names for 14.x?

This way we'll be able to publish it as minor - then we can rename them in 15.0 and document properly in the migration guide.

So my recommendation would be:

  1. Rename those constraints back in this PR - then we can merge it and publish as a minor
  2. Open a separate PR with new names for those constants and a note in the UPGRADE.md. We will merge this PR in 15.0.0

src/Utils/BreakingChangesFinder.php Show resolved Hide resolved
Removing a public constant is a breaking change and can not be
implemented in a minor version. Instead the internal value is changed to
ensure that existing code keeps working with the new interface
implementation logic.
@Kingdutch
Copy link
Contributor Author

@vladar will you add the changelog or should I do it?

Copy link
Member

@vladar vladar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@vladar vladar merged commit c4d2f82 into webonyx:master Jan 23, 2021
vredeling pushed a commit to vredeling/open_social that referenced this pull request Jan 26, 2021
This solves some issues where types couldn't be reconciled because they
implemented multiple interfaces. The PR for this in the GraphQL PHP
project is now far enough along (all tests passing) that this should be
available in an update for us in time.

See: webonyx/graphql-php/pull/740
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow interfaces to implement other interfaces
4 participants