Closed MasonD closed 1 year ago
I'm not able to reproduce this issue.
Using the following graphql models schema:
SilverStripe\Security\Group:
fields:
'*': true
SilverStripe\Security\Permission:
fields:
id: true
group: true
operations:
readOne: true
read:
plugins:
sort:
fields:
id: true
group:
'*': true
and the following query:
query getPerms {
readPermissions(sort: {group: {title: DESC}}) {
nodes {
id
group {
id
title
}
}
}
}
I see the results being sorted appropriately. I have tested sorting by other group fields and changing the sort direction as well, and I get the expected resiults.
@MasonD When you say "This does not work", what specifically doesn't work?
Oh, sorry, my bad. That does work. The issue only happens when nesting happens one level further, and including readOne
masks the error because it's implicitly sort: fields: '*'
which read then just extends.
For example with
SilverStripe\Security\Group:
fields:
description: true
sort: true
members: true
SilverStripe\Security\Member:
fields:
id: true
firstName: true
surname: true
SilverStripe\Security\Permission:
fields:
id: true
group: true
operations:
read:
plugins:
sort:
fields:
'*': false
id: true
group:
id: true
members:
'*': true
you should encounter the error
Uncaught SilverStripe\GraphQL\Schema\Exception\SchemaBuilderException: Failed to apply plugin SilverStripe\GraphQL\Schema\DataObject\Plugin\QuerySort to readPermissions. Got error "Could not find field "*" on type "Member". If it is a custom filter field, you will need to provide a
resolver function in the "resolver" config for that field along with an explicit type."
PR merged. Issue solved. Close issue.
If a sort plugin configuration is, say
This does not work, because the relevant code in NestedInputBuilder is
which computes and then immediately discards
buildAllFieldsConfig
for the nested type, doing absolutely nothing.PR should be inc. soon
PRs