How to use the graphene.Field function in graphene

To help you get started, we’ve selected a few graphene 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 andela / mrm_api / api / room_resource / schema.py View on Github external
"""
        Query to get room resources
    """

    all_resources = graphene.Field(
        PaginatedResource,
        page=graphene.Int(),
        per_page=graphene.Int(),
        unique=graphene.Boolean(),
        resource_labels=graphene.String(),
        description="Returns a list of paginated room resources and accepts the arguments\
            \n- page: Field for page of the room response\
            \n- per_page: Field for number of responses per page\
            \n- unique: Boolean field for uniqueroom response\
            \n- resource_labels: Labels to filter the resources with")
    get_resources_by_room_id = graphene.Field(
        lambda: RoomResources,
        room_id=graphene.Int(),
        description="Returns a list of room's resources. Accepts the argument\
            \n- room_id: Unique identifier of a room")

    resource_by_name = graphene.List(
        Resource,
        search_name=graphene.String(),
        description="Returns resources that match search name. Accepts the argument\
            \n- search_name: Unique name of a resource")

    rooms_containing_resource = graphene.List(
        RoomResource,
        resource_id=graphene.Int(),
        description="Returns a list of rooms containing the supplied resource id.\
            \n- resource_id: Unique identifier of a resource")
github torchbox / wagtail-torchbox / tbx / graphql / schema.py View on Github external
work_pages = work_pages.filter(
            related_services__pk__in=self.related_services.values_list(
                'pk', flat=True
            )
        ).distinct()

        return work_pages[:limit]

    class Meta:
        interfaces = [PageInterface]


class ServicePageKeyPointObjectType(graphene.ObjectType):
    text = graphene.String()
    linked_page = graphene.Field(PageLink)


class ServicePageClientLogoObjectType(graphene.ObjectType):
    image = graphene.Field(ImageObjectType)


class ServicePageTestimonialObjectType(graphene.ObjectType):
    quote = graphene.String()
    name = graphene.String()
    role = graphene.String()


class ProcessObjectType(graphene.ObjectType):
    title = graphene.String()
    description = graphene.String()
    page_link = graphene.Field(PageLink)
github mirumee / saleor / saleor / graphql / product / mutations / digital_contents.py View on Github external
    @classmethod
    @permission_required(ProductPermissions.MANAGE_PRODUCTS)
    def mutate(cls, _root, info, variant_id):
        variant = cls.get_node_or_error(
            info, variant_id, "id", only_type=ProductVariant
        )

        if hasattr(variant, "digital_content"):
            variant.digital_content.delete()

        return DigitalContentDelete(variant=variant)


class DigitalContentUpdate(BaseMutation):
    variant = graphene.Field(ProductVariant)
    content = graphene.Field(DigitalContent)

    class Arguments:
        variant_id = graphene.ID(
            description=("ID of a product variant with digital content to update."),
            required=True,
        )
        input = DigitalContentInput(
            required=True, description="Fields required to update a digital content."
        )

    class Meta:
        description = "Update digital content."
        error_type_class = ProductError
        error_type_field = "product_errors"
github cylc / cylc-flow / cylc / flow / network / schema.py View on Github external
description="""Task first parent.""",
        args=proxy_args,
        resolver=get_node_by_id)
    ancestors = List(
        lambda: FamilyProxy,
        description="""First parent ancestors.""",
        args=proxy_args,
        resolver=get_nodes_by_ids)


class Family(ObjectType):
    class Meta:
        description = """Task definition, static fields"""
    id = ID(required=True)
    name = String(required=True)
    meta = Field(DefMeta)
    depth = Int()
    proxies = List(
        lambda: FamilyProxy,
        description="""Associated cycle point proxies""",
        args=proxy_args,
        resolver=get_nodes_by_ids)
    parents = List(
        lambda: Family,
        description="""Family definition parent.""",
        args=def_args,
        resolver=get_nodes_by_ids)
    child_tasks = List(
        Task,
        description="""Descendant definition tasks.""",
        args=def_args,
        resolver=get_nodes_by_ids)
github mirumee / saleor / saleor / graphql / order / types.py View on Github external
"Informs whether a draft order can be finalized"
            "(turned into a regular order)."
        ),
        required=True,
    )
    total_authorized = graphene.Field(
        Money, description="Amount authorized for the order."
    )
    total_captured = graphene.Field(Money, description="Amount captured by payment.")
    events = gql_optimizer.field(
        graphene.List(
            OrderEvent, description="List of events associated with the order."
        ),
        model_field="events",
    )
    total_balance = graphene.Field(
        Money,
        description="The difference between the paid and the order total amount.",
        required=True,
    )
    user_email = graphene.String(
        required=False, description="Email address of the customer."
    )
    is_shipping_required = graphene.Boolean(
        description="Returns True, if order requires shipping.", required=True
    )
    discount_amount = graphene.Field(
        Money,
        deprecation_reason=(
            "DEPRECATED: Will be removed in Saleor 2.10, use discount instead."
        ),
        required=True,
github mirumee / saleor / saleor / graphql / payment / schema.py View on Github external
from ..decorators import permission_required
from .mutations import PaymentCapture, PaymentRefund, PaymentSecureConfirm, PaymentVoid
from .resolvers import resolve_client_token, resolve_payments
from .types import Payment


class PaymentQueries(graphene.ObjectType):
    payment = graphene.Field(
        Payment,
        description="Look up a payment by ID.",
        id=graphene.Argument(
            graphene.ID, description="ID of the payment.", required=True
        ),
    )
    payments = PrefetchingConnectionField(Payment, description="List of payments.")
    payment_client_token = graphene.Field(
        graphene.String,
        gateway=graphene.String(required=True, description="A payment gateway."),
        deprecation_reason=(
            "DEPRECATED: Will be removed in Saleor 2.10, "
            "use payment gateway config instead in availablePaymentGateways."
        ),
    )

    @permission_required(OrderPermissions.MANAGE_ORDERS)
    def resolve_payment(self, info, **data):
        return graphene.Node.get_node_from_global_id(info, data.get("id"), Payment)

    @permission_required(OrderPermissions.MANAGE_ORDERS)
    def resolve_payments(self, info, query=None, **_kwargs):
        return resolve_payments(info, query)
github lablup / backend.ai-manager / src / ai / backend / gateway / admin.py View on Github external
rescan_images = RescanImages.Field()


class QueryForAdmin(graphene.ObjectType):
    '''
    Available GraphQL queries for the admin privilege.
    It allows use of any access keys regardless of the one specified in the
    authorization header as well as querying the keypair information of all
    users.
    '''

    agent = graphene.Field(
        Agent,
        agent_id=graphene.String(required=True))

    agent_list = graphene.Field(
        AgentList,
        limit=graphene.Int(required=True),
        offset=graphene.Int(required=True),
        status=graphene.String())

    agents = graphene.List(
        Agent,
        status=graphene.String())

    image = graphene.Field(
        Image,
        reference=graphene.String(required=True))

    images = graphene.List(
        Image,
        is_installed=graphene.Boolean(),
github deathbeds / jupyter-graphql / src / jupyter_graphql / schema / nbformat / cells.py View on Github external
class HasAttachments(G.Interface):
    attachments = G.List(Attachment)

    def resolve_attachments(it, info):
        return it.get("attachments").items()


# The actual Cells


class CodeCell(G.ObjectType):
    class Meta:
        interfaces = (Cell, G.relay.Node)

    metadata = G.Field(CodeCellMetaData, required=True)
    execution_count = G.Int()
    outputs = G.List(Output)


class MarkdownCell(G.ObjectType):
    class Meta:
        interfaces = (Cell, HasAttachments, G.relay.Node)

    metadata = G.Field(MarkdownCellMetaData)


class RawCell(G.ObjectType):
    class Meta:
        interfaces = (Cell, HasAttachments, G.relay.Node)

    metadata = G.Field(RawCellMetaData)
github yatsu / react-tornado-graphql-example / tornado / tornado_graphql_example / schema.py View on Github external
todo = graphene.Field(lambda: Todo)

    def mutate(self, args, context, info):
        todo = Todo(str(len(todo_data) + 1),
                    args.get('text', ''),
                    args.get('completed', False))
        todo_data[todo.id] = todo
        return AddTodo(todo=todo)


class ToggleTodo(graphene.Mutation):
    class Input:
        id = graphene.ID()

    todo = graphene.Field(lambda: Todo)

    def mutate(self, args, context, info):
        todo = todo_data[args.get('id')]
        todo.completed = not todo.completed
        return ToggleTodo(todo)


class Mutation(graphene.ObjectType):
    add_todo = AddTodo.Field()
    toggle_todo = ToggleTodo.Field()


schema = graphene.Schema(query=Query, mutation=Mutation)
github vapor-ware / synse-server / synse / schema / device.py View on Github external
('product_info', ProductInfo)
    ]

    board_info = graphene.Field(BoardInfo, required=True)
    chassis_info = graphene.Field(ChassisInfo, required=True)
    product_info = graphene.Field(ProductInfo, required=True)


class DeviceInterface(graphene.Interface):
    _data = None

    id = graphene.String(required=True)
    device_type = graphene.String(required=True)
    info = graphene.String(required=True)
    location = graphene.Field(Location, required=True)
    asset = graphene.Field(Asset, required=True)
    timestamp = graphene.Int()
    request_received = graphene.Int()

    @graphene.resolve_only_args
    def resolve_location(self):
        return Location(_data=self._location())

    @graphene.resolve_only_args
    def resolve_asset(self):
        return Asset(_data=self._asset())

    @graphene.resolve_only_args
    def resolve_timestamp(self):
        return self._resolve_detail().get('timestamp')

    @graphene.resolve_only_args