-
Notifications
You must be signed in to change notification settings - Fork 16
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
Location by id with children support #51
Conversation
5f27782
to
4a4bf3d
Compare
4003fd3
to
c74168a
Compare
Hello, it's a good improvement ! Especially query by Depth and by ContentType |
Could you please elaborate a bit ? I'm not sure what you mean here. It is already possible to query a type of item. |
I currently use "_repository" and "children" to get my content structure tree from eZ Platform with this query :
But I get all the Content Type and I would like to filter by one specific content type. We could have a query like this :
And for the depth, we could have a parameter for choosing the maximum depth of the query (e.g. fetching the first two levels of children of the content). |
I see, it makes sense. While it should be fairly easy to implement, I have an alternative solution to that use-case. Usually, when a content's sub-items of a particular type are retrieved, they have a meaning in terms of content. For instance, the I have designed a fieldtype, https://github.com/bdunogier/ezplatform-query-fieldtype, that models exactly this. You can create
The field definition is configured using:
I strongly believe that it is a cleaner, more maintainable solution to the use-case you describe. It lets the content architect model the relationships that exist between items, and lets content consumers focus on rendering the content. I'm available on slack if you need more information. |
4dba441
to
5b7faec
Compare
331a7da
to
0f3a928
Compare
0f3a928
to
8b59c5c
Compare
Ping @webhdx for review :-) |
*/ | ||
public function resolveDomainContentItem(Argument $args, $contentTypeIdentifier) | ||
public function resolveDomainContentItem($args, $contentTypeIdentifier) |
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.
Did it change in overblog graphql package? I though it would always return an Argument
object which implements ArrayAccess
if I'm not mistaken.
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 did change this because in this PR, to resolve a Location's content
field, we call the method directly, with an array as the argument. In src/Resources/config/graphql/Location.types.yml
: resolve: "@=resolver('DomainContentItem', [{id: value.contentId}, null])"
.
I agree that it's not the cleanest thing ever, but... 😊
return $this->locationService->loadLocation($id); | ||
} catch (ApiException\InvalidArgumentException $e) { | ||
} catch (ApiException\NotFoundException $e) { | ||
throw new ArgumentsException($e->getMessage(), $e->getCode(), $e); |
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.
There happens something confusing to me. Why does ArgumentsException
extend NotFoundException
if it thrown for NotFoundException
and for InvalidArgumentException
below? To my understanding it should not extend any particular Exception class because it's very general exception. Also do we need specific ArgumentsException
class if we have InvalidArgumentException
from our API?
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.
The general idea is to make that package only throw its own exceptions (it supposedly catches everything else). Why it extends NotFoundException
... I don't know. A mistake I guess. I'll change it extend \Exception
. Would that work for you ?
Generally speaking, error handling in GraphQL needs to be vastly improved, but I have barely scratched the surface of it.
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.
After thinking about it, I'd like to request your approval to leave this aside for now. The reason why it is implemented that way in this loader is that it was implemented that way in the existing ones.
We must find a proper way to implement exception handling in loaders, but I don't think that we must do it in the context of that PR.
8ce9e0e
to
664f009
Compare
Review comments taken care of, except the two I have answered about, @webhdx. |
Also, the PR has been rebased to contain coherent commits. |
Allows to implement page number based navigation using response data. ``` ... children { pages { number cursor } } ```
664f009
to
2de3a92
Compare
@ezsystems/qa-team, the baby is yours. Since the "real" target is ezsystems/ezplatform-admin-ui-modules#200 that targets v3.0, you should test it on the master branch. I have tested it myself, and it merges as is on Just make sure you're on master, and Once approved, we will merge it to |
It would be helpful to document that changes to these items affect the schema (and require regenerating it): content types, types groups, languages, blocks types, images variations. |
@micszo I'll rebase the PR to squash the fixup commit (done). |
First iterates over fields, and returns the first ezimage or ezimageasset field. If none is found, tries with ezobjectrelation, and returns the first ezimage or ezimageasset field of the related item. If an image field is found, generates the small variation of it, and returns it as a Thumbnail object with uri, width, height, alternativeText.
c41c3d0
to
efe498d
Compare
@lserwatka this one's ready |
@bdunogier you can merge it up |
Merged via 219501b |
Repository.location: Location
field that returns a location by id.Location.children
that returns a connection with the location's childrenLocation.content: Content
ContentInfo.currentVersion: Version
Version.creator: User
Content._thumbnail: Thumbnail
Also adds page number based pagination support using a new connection field,
LocationConnection.pages
.Example:
TODO
Location.id
to be anID
, and addLocation.locationId
with the auto-increment id.