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

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

Open
Luzzzi opened this issue Dec 11, 2023 · 0 comments
Open

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

Luzzzi opened this issue Dec 11, 2023 · 0 comments

Comments

@Luzzzi
Copy link

Luzzzi commented Dec 11, 2023

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"`. 

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

No branches or pull requests

1 participant