torchbox / wagtail-grapple

A Wagtail app that makes building GraphQL endpoints a breeze!

Home Page:https://wagtail-grapple.readthedocs.io/en/latest/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error : "Cannot resolve keyword 'release_date' into field."

Luzzzi opened this issue · comments

This follows a conversation on the Wagtail/support slack

I work on a project with Wagtail Grapple and GraphQL and I struggle to sort my pages. I have a model :

#models.py 

class MyModel(Page): 
    body = StreamField(MyStreamField)
   
    release_date = models.DateTimeField(
        blank=True,
        null=True,
    )

 content_panels = Page.content_panels + [
    FieldPanel("body")
]

 settings_panels = [
        FieldPanel("release_date"),
    ] + Page.settings_panels


    graphql_fields = [
        GraphQLString("release_date"),

    ]

And I have the query associated :

#queries/MyModel.tsx

import { gql } from '@apollo/client';
import { COVER_IMAGE_FIELDS } from './image';

query MYMODEL {
        pages(contentType: "model.MyModel", order:"-release_date") {
            ... on MyModel {
                releaseDate
            }
        }
    }

When I try to sort on the new field release_date I have this error :

{
  "errors": [
    {
      "message": "Cannot resolve keyword 'release_date' into field. Choices are: _revisions, _workflow_states, alias_of, alias_of_id, aliases, articleindexpage, articlepage, content_type, content_type_id, cyclepage, depth, draft_title, expire_at, expired, first_published_at, formsubmission, go_live_at, group_permissions, has_unpublished_changes, homepage, id, index_entries, last_published_at, latest_revision, latest_revision_created_at, latest_revision_id, live, live_revision, live_revision_id, locale, locale_id, locked, locked_at, locked_by, locked_by_id, makeitgreenpage, numchild, owner, owner_id, path, quizpage, ratings, redirect, ressourceindexpage, ressourcepage, search_description, searchpromotion, seo_title, show_in_menus, sites_rooted_here, slug, subscribers, title, translation_key, url_path, view_restrictions, wagtail_admin_comments, workflowpage",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "pages"
      ]
    }
  ],
  "data": null
}```


But it's working with `order:"-mymodel__release-date"`.