-
-
Notifications
You must be signed in to change notification settings - Fork 901
GraphQl: interface implementation #3306
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
Conversation
@CvekCoding I think this should target @alanpoulain Do you think you could take a look at this? I think it would be a big step forward for our GraphQL-support 🚀 |
if ($resourceMetadata->isInterface()) { | ||
continue; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure skipping the operations for interfaces is the correct approach. And if we do, we should at least trigger warnings or something if they are defined anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weak place, agree.
I did this because in my project I dont need mutations in interfaces. And I use custom operations very few.
Additionally I think I had some issues with mutations in interface types, but dont remember details now :(
We can safely move this conditions to include custom query operations here
core/src/GraphQl/Type/SchemaBuilder.php
Line 90 in a1570c8
/** | ||
* @var bool | ||
*/ | ||
public $isInterface; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
public $implements; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be under the graphql
-key, as this is only supported for the GraphQL format / endpoints.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lukasluecke can you explain graphql-key
- what does it mean? Prefix for property name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@CvekCoding There is already a configuration key graphql
, under which we configure the operations etc. - I think it would make sense to include it inside of that, instead of at the root level.
if (!$this->typesContainer->has($shortName)) { | ||
$shortName .= self::ITEM_POSTFIX; | ||
if (!$this->typesContainer->has($shortName)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably not be used as a fallback, but instead implement the proper checks (i.e. use Item
postfix if the serialization context differs between Item
and Collection
queries)
@alanpoulain What do you think about this? I've been using it in my project for some time now and it's working quite well. I think we should address both the name resolution handling (based on serialization context) and the resource config layout (under Handling the other operations for interface resources could be addressed in a follow-up PR I think. |
I plan to take some time to take a look at it once subscriptions are merged. |
It would be great to see this merged! |
@alanpoulain Any chance to get this revisited? I'd be happy to help and contribute, but would be good to have your input first 🙂 |
@lukasluecke I can't speak for @alanpoulain but I would imagine this PR will at least need to have tests for it to be considered for merging |
@ollietb Of course, but he said he would take a look - not merge it 🙂 this should just serve as an inspiration for a "proper" implementation in my mind, we would first need to define what behavior we want to have, before writing any tests. |
It would be good to see this PR finished, my front-end developers are always complaining about missing features in the GraphQL spec, like interfaces and enums. @alanpoulain would you be able to look at this PR and advise @lukasluecke if he is on the right path before he writes some tests and submits the completed PR? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Added interface feature to
Graphql
.How to use:
In a scheme you will see that:
AAInterface
has two implementations:A
andC
;ABInterface
has one implementations:C
;A
implements one interfaceAAInterface
;C
implements two interfacesAAInterface
andABInterface
.I'm far from thought that my implementation is ready to be merged. Feature was developed in haste because I needed it in my project, but I didnt have time to think about the best architecture.
I'm ready to answer the questions.