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

Nested filtering issue #588

Open
2 tasks done
jackkemmish opened this issue May 18, 2024 · 1 comment
Open
2 tasks done

Nested filtering issue #588

jackkemmish opened this issue May 18, 2024 · 1 comment
Labels

Comments

@jackkemmish
Copy link

jackkemmish commented May 18, 2024

Module version(s) affected

5.2

Description

Hi there,

I am trying to filter on a field which is part of a page type I have, but I am getting a an error e.g. Failed to resolve field readOneResourcePage returning ResourcePageInterface..

I have seen this open ticket around nested filtering #307 but can also see in the docs I should be able to filter by default here Nested fields are supported by default: https://docs.silverstripe.org/en/5/developer_guides/graphql/working_with_dataobjects/query_plugins/

How to reproduce

I am still very much in the learning stages here so I may be missing something, but here is my code (I have reduced it for the example):

Schema:

models:
  Sdots\App\ResourcePage:
    fields:
      '*': true
      link:
        type: String
        property: Link
    operations:
      read: true
      readOne:
        plugins:
          getByLink: true
  Sdots\App\ResourceListPage:
    fields:
      '*': true
      link:
        type: String
        property: Link
    operations:
      read: true
      readOne:
        plugins:
          getByLink: true
  Sdots\Tagging\Model\TagGroup:
    fields: '*'
    operations:
      read: true
  Sdots\Tagging\Model\Tag:
    fields: '*'
    operations:
      read: true

I would assume that the above would allow me to filter by ID on the tagGroup or tags as it's exposed in the schema. I have also attached an image of the structure of the schema in the GraphQL IDE, and the error.

Screenshot 2024-05-18 at 21 01 28 Screenshot 2024-05-18 at 21 02 12

I feel like I'm either missing something, or something is not working :/

Thanks in advance.

Jack

Possible Solution

No response

Additional Context

No response

Validations

  • Check that there isn't already an issue that reports the same bug
  • Double check that your reproduction steps work in a fresh installation of silverstripe/installer (with any code examples you've provided)
@jackkemmish
Copy link
Author

One thing I'm also not quite following is although something like link is available to the filter argument, it's not actually allowing me to filter on it.

E.g.

query {
  readPages(
    filter: {
      link: {
        eq: "/"
      }
    }
  ) {
    nodes {
      __typename
      id
      title
      link
    }
  }
}

This just throws an error:
"message": "Failed to resolve field readPages returning PageInterfaceConnection!.\\n\\n\n Got error: Couldn't run query:\n\nSELECT DISTINCT count(DISTINCT \"SiteTree_Live\".\"ID\") AS \"Count\"\n\nFROM \"SiteTree_Live\"\nLEFT JOIN \"Page_Live\" ON \"Page_Live\".\"ID\" = \"SiteTree_Live\".\"ID\"\n\nWHERE (\"Link\" = ?)\n AND (\"SiteTree_Live\".\"ClassName\" IN (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?))\n\nUnknown column 'Link' in 'where clause'\\n\\n\n Path: readPages\\n\\n\n Resolver (closure) failed in execution chain:\\n\\n\n array (\n 0 => \n array (\n 0 => 'SilverStripe\\\\GraphQL\\\\Schema\\\\DataObject\\\\ReadCreator',\n 1 => 'resolve',\n ),\n)\narray (\n 0 => \n array (\n 0 => 'SilverStripe\\\\Versioned\\\\GraphQL\\\\Resolvers\\\\VersionedResolver',\n 1 => 'resolveVersionedRead',\n ),\n)\narray (\n 0 => \n array (\n 0 => 'SilverStripe\\\\GraphQL\\\\Schema\\\\DataObject\\\\Plugin\\\\QueryFilter\\\\QueryFilter',\n 1 => 'filter',\n ),\n)\narray (\n 0 => \n array (\n 0 => 'SilverStripe\\\\GraphQL\\\\Schema\\\\DataObject\\\\Plugin\\\\QuerySort',\n 1 => 'sort',\n ),\n)\narray (\n 0 => \n array (\n 0 => 'SilverStripe\\\\GraphQL\\\\Schema\\\\DataObject\\\\Plugin\\\\Paginator',\n 1 => 'paginate',\n ),\n)\narray (\n 0 => \n array (\n 0 => 'SilverStripe\\\\GraphQL\\\\Schema\\\\DataObject\\\\Plugin\\\\CanViewPermission',\n 1 => 'permissionCheck',\n ),\n)\\n\\n\n Args: {\n \"filter\": {\n \"link\": {\n \"eq\": \"\\/\"\n }\n },\n \"limit\": \"100\",\n \"offset\": \"0\"\n}\\n\\n",

However I can filter on the title or id for example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants