Filter with GraphQL

I am totally new to GraphQL. Looking at other examples in the support forums, I thought this filter would work. But I get an error "OData operation is not supported for query: ?$skip=0&$filter=data/name/iv/data/publication/iv eq ‘Spread Charts’."

{
      queryPublicationContents
      (filter:"data/name/iv/data/publication/iv eq 'Spread Charts'")
      {
        id
    
    data {
    
        name{iv {
          data {
            publication {
              iv
            }
          }
        }}
       
      
      title {
        iv
      } 
    }
  }
}

Can you show me your schema?

Filtering on references is not supported.

{
    "properties": {
        "label": "Publications: Items",
        "validateOnPublish": false
    },
    "category": "Publications",
    "scripts": {},
    "fieldsInLists": [
        "title",
        "name"
    ],
    "fieldsInReferences": [],
    "fields": [
        {
            "name": "title",
            "properties": {
                "isRequired": true,
                "isRequiredOnPublish": true,
                "isHalfWidth": false,
                "fieldType": "String",
                "editor": "Input",
                "inlineEditable": false,
                "isUnique": false,
                "contentType": "Unspecified",
                "label": "Title of the publication",
                "hints": "",
                "placeholder": ""
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "invariant"
        },
        {
            "name": "mainContent",
            "properties": {
                "isRequired": true,
                "isRequiredOnPublish": true,
                "isHalfWidth": false,
                "fieldType": "String",
                "editor": "Html",
                "inlineEditable": false,
                "isUnique": false,
                "contentType": "Html",
                "label": "The body of the publication"
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "invariant"
        },
        {
            "name": "coverImage",
            "properties": {
                "isRequired": false,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "Assets",
                "previewMode": "ImageAndFileName",
                "mustBeImage": true,
                "resolveFirst": false,
                "resolveImage": false,
                "allowedExtensions": [
                    "png",
                    "jpg"
                ],
                "allowDuplicates": false,
                "label": "Image at top of publication",
                "hints": "Optional"
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "invariant"
        },
        {
            "name": "summary",
            "properties": {
                "isRequired": false,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "String",
                "editor": "TextArea",
                "inlineEditable": false,
                "isUnique": false,
                "contentType": "Unspecified",
                "label": "Summary of publication",
                "hints": "Optional"
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "invariant"
        },
        {
            "name": "attachedFiles",
            "properties": {
                "isRequired": false,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "Assets",
                "previewMode": "FileName",
                "mustBeImage": false,
                "resolveFirst": false,
                "resolveImage": false,
                "allowedExtensions": [
                    "png",
                    "pdf",
                    "xls",
                    "jpg",
                    "csv"
                ],
                "allowDuplicates": false,
                "label": "Related attachments",
                "hints": "",
                "placeholder": ""
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "invariant"
        },
        {
            "name": "relatedPublications",
            "properties": {
                "isRequired": false,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "References",
                "editor": "List",
                "allowDuplicates": false,
                "resolveReference": false,
                "mustBePublished": false,
                "schemaIds": [
                    "d1d90b93-494c-4e82-b351-d975eabdf016"
                ],
                "label": "Related publications"
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "invariant"
        },
        {
            "name": "createdBy",
            "properties": {
                "isRequired": true,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "References",
                "editor": "List",
                "allowDuplicates": false,
                "resolveReference": false,
                "mustBePublished": false,
                "schemaIds": [
                    "a34e79e2-458d-4ad2-ac3a-563f36b63d1d",
                    "4cd7e0c1-b06f-4ae9-b676-9c0351437375"
                ],
                "label": "Created By",
                "hints": "",
                "placeholder": ""
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "invariant"
        },
        {
            "name": "authors",
            "properties": {
                "isRequired": true,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "References",
                "editor": "List",
                "allowDuplicates": false,
                "resolveReference": false,
                "mustBePublished": true,
                "schemaIds": [
                    "4cd7e0c1-b06f-4ae9-b676-9c0351437375"
                ],
                "label": "Author(s)",
                "hints": "",
                "placeholder": ""
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "invariant"
        },
        {
            "name": "atAGlance",
            "properties": {
                "isRequired": false,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "String",
                "editor": "TextArea",
                "inlineEditable": false,
                "isUnique": false,
                "contentType": "Html",
                "label": "At A Glance",
                "hints": "Bulleted list of content highlights",
                "placeholder": ""
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "invariant"
        },
        {
            "name": "tableOfContents",
            "properties": {
                "isRequired": false,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "String",
                "editor": "TextArea",
                "inlineEditable": false,
                "isUnique": false,
                "contentType": "Html",
                "label": "Table of Contents",
                "hints": "Linked sections in the main content"
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "invariant"
        },
        {
            "name": "allowSharing",
            "properties": {
                "isRequired": false,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "Boolean",
                "editor": "Checkbox",
                "inlineEditable": false,
                "defaultValue": false,
                "label": "Allow Sharing",
                "hints": "",
                "placeholder": ""
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "invariant"
        },
        {
            "name": "allowPrinting",
            "properties": {
                "isRequired": false,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "Boolean",
                "editor": "Checkbox",
                "inlineEditable": false,
                "defaultValue": false,
                "label": "Allow Printing"
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "invariant"
        },
        {
            "name": "tags",
            "properties": {
                "isRequired": false,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "References",
                "editor": "List",
                "allowDuplicates": false,
                "resolveReference": false,
                "mustBePublished": false,
                "schemaIds": [
                    "e34cbb69-b40c-42eb-8dff-188d32116472"
                ],
                "label": "Tag(s)",
                "hints": "",
                "placeholder": ""
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "invariant"
        },
        {
            "name": "categories",
            "properties": {
                "isRequired": false,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "References",
                "editor": "List",
                "minItems": 1,
                "allowDuplicates": false,
                "resolveReference": false,
                "mustBePublished": false,
                "schemaIds": [
                    "fbc4e6c0-c9b6-45e7-87b2-c16fa9816fc7"
                ],
                "label": "Categories"
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "invariant"
        },
        {
            "name": "name",
            "properties": {
                "isRequired": false,
                "isRequiredOnPublish": false,
                "isHalfWidth": false,
                "fieldType": "References",
                "editor": "List",
                "minItems": 1,
                "maxItems": 1,
                "allowDuplicates": false,
                "resolveReference": false,
                "mustBePublished": false,
                "schemaIds": [
                    "7b3ae5a9-7217-4fdc-9910-f2f1599e1a96"
                ],
                "label": "Name"
            },
            "isLocked": false,
            "isHidden": false,
            "isDisabled": false,
            "partitioning": "invariant"
        }
    ],
    "isPublished": true
}

I am also not able to filter on any fields in the data area. I’ve tried flatData as well.

I have no problems with that:

Are there any plans to filter on reference fields?

No,

but you can reverse the query.

Lets say you have authors and blog posts, then you can do something like this:

query {
  queryAuthorContents(filter: "data/name/iv eq 'Sebastian'") {
    id
    flatData {
      name
    }
    queryReferencingBlogPostsContents(top: 10) {
      id {
      flatData {
        title
      }
    }
  }
}

Awesome! On that queryReferencingBlogPostsContents, how do I only get items that are published?

By default graphql over the normal API will return published items only.

When the same query is made over the UI it will also return other items.

EDIT: But you can apply a filter again, so it would be something like

query {
  queryAuthorContents(filter: "data/name/iv eq 'Sebastian'") {
    id
    flatData {
      name
    }
    queryReferencingBlogPostsContents(top: 10, filter: "status eq 'Published'") {
      id {
      flatData {
        title
      }
    }
  }
}
1 Like