How to use the graphene-django.examples.cookbook.cookbook.ingredients.schema.CategoryNode function in graphene-django

To help you get started, we’ve selected a few graphene-django examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github graphql-python / graphene / graphene-django / examples / cookbook / cookbook / ingredients / schema.py View on Github external
class IngredientNode(DjangoNode, DjangoObjectType):

    class Meta:
        model = Ingredient
        # Allow for some more advanced filtering here
        filter_fields = {
            'name': ['exact', 'icontains', 'istartswith'],
            'notes': ['exact', 'icontains'],
            'category': ['exact'],
            'category__name': ['exact'],
        }
        filter_order_by = ['name', 'category__name']


class Query(ObjectType):
    category = Field(CategoryNode)
    all_categories = DjangoFilterConnectionField(CategoryNode)

    ingredient = Field(IngredientNode)
    all_ingredients = DjangoFilterConnectionField(IngredientNode)
github graphql-python / graphene / graphene-django / examples / cookbook / cookbook / ingredients / schema.py View on Github external
class Meta:
        model = Ingredient
        # Allow for some more advanced filtering here
        filter_fields = {
            'name': ['exact', 'icontains', 'istartswith'],
            'notes': ['exact', 'icontains'],
            'category': ['exact'],
            'category__name': ['exact'],
        }
        filter_order_by = ['name', 'category__name']


class Query(ObjectType):
    category = Field(CategoryNode)
    all_categories = DjangoFilterConnectionField(CategoryNode)

    ingredient = Field(IngredientNode)
    all_ingredients = DjangoFilterConnectionField(IngredientNode)