Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions grapple/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ class UnmanagedMeta:

class StubMeta:
model = stub_model
fields = "__all__"

# Gather any interfaces, and discard None values
interface_classes = getattr(cls, "graphql_interfaces", ())
Expand Down Expand Up @@ -311,7 +312,7 @@ class Meta:

type_meta = {"Meta": Meta, "id": graphene.ID(), "name": type_name}

exclude_fields = []
exclude = []
base_type_for_exclusion_checks = (
base_type if not issubclass(cls, WagtailPage) else WagtailPage
)
Expand All @@ -326,7 +327,7 @@ class Meta:
):
continue

exclude_fields.append(field)
exclude.append(field)

# Add any custom fields to node if they are defined.
methods = {}
Expand All @@ -340,14 +341,14 @@ class Meta:
type_meta[field.field_name] = field_type

# Remove field from excluded list
if field.field_name in exclude_fields:
exclude_fields.remove(field.field_name)
if field.field_name in exclude:
exclude.remove(field.field_name)

# Add a custom resolver for each field
methods[f"resolve_{field.field_name}"] = model_resolver(field)

# Replace stud node with real thing
type_meta["Meta"].exclude_fields = exclude_fields
type_meta["Meta"].exclude = exclude
node = type(type_name, (base_type,), type_meta)

# Add custom resolvers for fields
Expand Down
1 change: 1 addition & 0 deletions grapple/types/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class CollectionObjectType(DjangoObjectType):

class Meta:
model = Collection
fields = "__all__"

id = graphene.ID(required=True)
name = graphene.String(required=True)
Expand Down
1 change: 1 addition & 0 deletions grapple/types/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def resolve_tags(self, info, **kwargs):

class Meta:
model = WagtailDocument
fields = "__all__"


def get_document_type():
Expand Down
2 changes: 2 additions & 0 deletions grapple/types/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class ImageRenditionObjectType(DjangoObjectType):

class Meta:
model = WagtailImageRendition
fields = "__all__"

def resolve_url(
instance: WagtailImageRendition, info: GraphQLResolveInfo, **kwargs
Expand Down Expand Up @@ -127,6 +128,7 @@ class ImageObjectType(DjangoObjectType):

class Meta:
model = WagtailImage
fields = "__all__"

def resolve_rendition(
instance: WagtailImage, info: GraphQLResolveInfo, **kwargs
Expand Down
1 change: 1 addition & 0 deletions grapple/types/pages.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class Page(DjangoObjectType):
class Meta:
model = WagtailPage
interfaces = (get_page_interface(),)
fields = "__all__"


def get_preview_page(token):
Expand Down
1 change: 1 addition & 0 deletions grapple/types/sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def resolve_page(self, info, **kwargs):

class Meta:
model = Site
fields = "__all__"


def SitesQuery():
Expand Down