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

Add GraphQLTag model #124

Merged
merged 4 commits into from
Oct 7, 2020
Merged

Add GraphQLTag model #124

merged 4 commits into from
Oct 7, 2020

Conversation

ruisaraiva19
Copy link
Collaborator

@ruisaraiva19 ruisaraiva19 commented Oct 6, 2020

Resolves #70

This adds single and plural tags queries.

{
  tag(id: 1) {
    id
    name
  }
}
{
  tags {
    id
    name
  }
}

Using it on a model:

from django.db import models
from modelcluster.fields import ParentalKey
from modelcluster.contrib.taggit import ClusterTaggableManager
from taggit.models import TaggedItemBase
from wagtail.admin.edit_handlers import FieldPanel
from wagtail.core.models import Page
from grapple.models import GraphQLTag


class BlogPageTag(TaggedItemBase):
    content_object = ParentalKey(
        "BlogPage", related_name="tagged_items", on_delete=models.CASCADE
    )


class BlogPage(Page):
    # other fields
    tags = ClusterTaggableManager(through=BlogPageTag, blank=True)

    content_panels = Page.content_panels + [
        # other panels
        FieldPanel("tags"),
    ]

    graphql_fields = [
        # other graphql fields
        GraphQLTag("tags"),
    ]

Copy link
Member

@zerolab zerolab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of minor things, but excellent work!

docs/general-usage/model-types.rst Outdated Show resolved Hide resolved
docs/general-usage/model-types.rst Outdated Show resolved Hide resolved
@ruisaraiva19
Copy link
Collaborator Author

A couple of minor things, but excellent work!

@zerolab All updated!

@ruisaraiva19 ruisaraiva19 changed the title Add GraphQLTags model Add GraphQLTag model Oct 7, 2020
@zerolab zerolab merged commit 166a7c2 into master Oct 7, 2020
@ruisaraiva19 ruisaraiva19 deleted the feature/tags-query-and-model branch October 7, 2020 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to map ClusterTaggableManager
2 participants