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

Document the need for graphql_fields on custom rendition models #237

Open
zerolab opened this issue Jul 25, 2022 · 0 comments
Open

Document the need for graphql_fields on custom rendition models #237

zerolab opened this issue Jul 25, 2022 · 0 comments
Labels
documentation Improvements or additions to documentation

Comments

@zerolab
Copy link
Member

zerolab commented Jul 25, 2022

When using a custom image model, with a custom rendition model one needs to add

 graphql_fields = [
        GraphQLString("id"),
        GraphQLString("url"),
        GraphQLString("width"),
        GraphQLString("height"),
        GraphQLImage("image"),
        GraphQLString("file"),
    ]

to the custom rendition model. (Alternatively

class CustomImageRendition(AbstractRendition):
image = models.ForeignKey(
"CustomImage", related_name="renditions", on_delete=models.CASCADE
)
class Meta:
unique_together = (("image", "filter_spec", "focal_point_key"),)
def custom_rendition_property(self, info, **kwargs):
return "Rendition Model!"
graphql_fields = (
GraphQLString("custom_rendition_property", required=True),
GraphQLInt("id", required=True),
GraphQLString("url", required=True),
GraphQLString("width", required=True),
GraphQLString("height", required=True),
GraphQLImage("image", required=True),
GraphQLString("file", required=True),
)
)

Document, or fix so it is not needed

@zerolab zerolab added the documentation Improvements or additions to documentation label Sep 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

1 participant