How to use the graphene.List 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 mirumee / saleor / saleor / graphql / product / bulk_mutations / products.py View on Github external
graphene.ID,
            required=True,
            description="List of product image IDs to delete.",
        )

    class Meta:
        description = "Deletes product images."
        model = models.ProductImage
        permissions = (ProductPermissions.MANAGE_PRODUCTS,)
        error_type_class = ProductError
        error_type_field = "product_errors"


class ProductBulkPublish(BaseBulkMutation):
    class Arguments:
        ids = graphene.List(
            graphene.ID, required=True, description="List of products IDs to publish."
        )
        is_published = graphene.Boolean(
            required=True, description="Determine if products will be published or not."
        )

    class Meta:
        description = "Publish products."
        model = models.Product
        permissions = (ProductPermissions.MANAGE_PRODUCTS,)
        error_type_class = ProductError
        error_type_field = "product_errors"

    @classmethod
    def bulk_action(cls, queryset, is_published):
        queryset.update(is_published=is_published)
github assembl / assembl / assembl / graphql / schema.py View on Github external
lang=graphene.String(required=True, description=docs.Default.required_language_input),
        description=docs.Schema.has_terms_and_conditions)
    has_cookies_policy = graphene.Boolean(
        lang=graphene.String(required=True, description=docs.Default.required_language_input),
        description=docs.Schema.has_cookies_policy)
    has_privacy_policy = graphene.Boolean(
        lang=graphene.String(required=True, description=docs.Default.required_language_input),
        description=docs.Schema.has_privacy_policy)
    has_user_guidelines = graphene.Boolean(
        lang=graphene.String(required=True, description=docs.Default.required_language_input),
        description=docs.Schema.has_user_guidelines)
    visits_analytics = graphene.Field(lambda: VisitsAnalytics, description=docs.Schema.visits_analytics)
    discussion = graphene.Field(Discussion, description=docs.Schema.discussion)
    landing_page_module_types = graphene.List(LandingPageModuleType, description=docs.Schema.landing_page_module_types)
    landing_page_modules = graphene.List(LandingPageModule, description=docs.Schema.landing_page_modules)
    text_fields = graphene.List(ConfigurableFieldUnion, description=docs.Schema.text_fields)
    profile_fields = graphene.List(ProfileField, description=docs.Schema.profile_fields)
    timeline = graphene.List(DiscussionPhase, description=docs.Schema.timeline)
    posts = SQLAlchemyConnectionField(
        PostConnection,
        start_date=graphene.String(description=docs.SchemaPosts.start_date),
        end_date=graphene.String(description=docs.SchemaPosts.end_date),
        identifiers=graphene.List(graphene.String, description=docs.SchemaPosts.identifiers),
        description=docs.SchemaPosts.__doc__)
    tags = graphene.List(
        lambda: Tag,
        filter=graphene.String(description=docs.SchemaTags.filter),
        limit=graphene.Int(description=docs.SchemaTags.limit),
        description=docs.SchemaTags.__doc__)

    def resolve_tags(self, args, context, info):
        discussion_id = context.matchdict['discussion_id']
github Novvum / MarvelQL / packages / python / marvelTypes.py View on Github external
diamondCode = String()
    ean = String()
    issn = String()
    format = String()
    pageCount = Int()
    textObjects = List(TextObject)
    resourceURI = String()
    urls = List(MarvelUrl)
    series = Field(Summary)
    variants = List(Summary)
    collections = List(Summary)
    collectedIssues = List(Summary)
    dates = List(ComicDate)
    prices = List(ComicPrice)
    thumbnail = String()
    images = List(ComicImage)
    creators = Field(AllList)
    characters = Field(AllList)
    stories = Field(AllList)
    events = Field(AllList)


class Character(ObjectType):
    id = ID()
    name = String()
    description = String()
    resourceURI = String()
    thumbnail = String()
    comics = Field(AllList)
    events = Field(AllList)
    series = Field(AllList)
    stories = Field(AllList)
github syrusakbary / gdom / gdom / schema.py View on Github external
class Node(graphene.Interface):
    '''A Node represents a DOM Node'''
    content = graphene.String(description='The html representation of the subnodes for the selected DOM',
                              selector=graphene.String())
    html = graphene.String(description='The html representation of the selected DOM',
                           selector=graphene.String())
    text = graphene.String(description='The text for the selected DOM',
                           selector=graphene.String())
    tag = graphene.String(description='The tag for the selected DOM',
                          selector=graphene.String())
    attr = graphene.String(description='The DOM attr of the Node',
                           selector=graphene.String(),
                           name=graphene.String(required=True))
    _is = graphene.Boolean(description='Returns True if the DOM matches the selector',
                           name='is', selector=graphene.String(required=True))
    query = graphene.List(lambda: Element,
                          description='Find elements using selector traversing down from self',
                          selector=graphene.String(required=True))
    children = graphene.List(lambda: Element,
                             description='The list of children elements from self',
                             selector=graphene.String())
    parents = graphene.List(lambda: Element,
                            description='The list of parent elements from self',
                            selector=graphene.String())
    parent = graphene.Field(lambda: Element,
                            description='The parent element from self')
    siblings = graphene.List(lambda: Element,
                             description='The siblings elements from self',
                             selector=graphene.String())
    next = graphene.Field(lambda: Element,
                          description='The immediately following sibling from self',
                          selector=graphene.String())
github cylc / cylc-flow / cylc / flow / network / schema.py View on Github external
resolver=get_node_by_id)
    suicide = Boolean()
    cond = Boolean()


class Edges(ObjectType):
    class Meta:
        description = """Dependency edge"""
    edges = List(
        Edge,
        required=True,
        args=edge_args,
        resolver=get_edges_by_ids)
    workflow_polling_tasks = List(PollTask)
    leaves = List(String)
    feet = List(String)


class NodesEdges(ObjectType):
    class Meta:
        description = """Related Nodes & Edges."""
    nodes = List(
        TaskProxy,
        description="""Task nodes from and including root.""")
    edges = List(
        Edge,
        description="""Edges associated with the nodes.""")


# Query declaration
class Queries(ObjectType):
    class Meta:
github assembl / assembl / assembl / graphql / discussion.py View on Github external
discussion_id=discussion.id,
                document_id=document_id
            ).all()
            document.delete_file()
            discussion.db.delete(document)
            for attachment in attachments:
                discussion.attachments.remove(attachment)


class UpdateLegalContents(graphene.Mutation):
    __doc__ = docs.UpdateLegalContents.__doc__

    class Input:
        legal_notice_attachments = graphene.List(graphene.String, description=docs.UpdateLegalContents.legal_notice_attachments)
        terms_and_conditions_attachments = graphene.List(graphene.String, description=docs.UpdateLegalContents.terms_and_conditions_attachments)
        cookies_policy_attachments = graphene.List(graphene.String, description=docs.UpdateLegalContents.cookies_policy_attachments)
        privacy_policy_attachments = graphene.List(graphene.String, description=docs.UpdateLegalContents.privacy_policy_attachments)
        user_guidelines_attachments = graphene.List(graphene.String, description=docs.UpdateLegalContents.user_guidelines_attachments)
        legal_notice_entries = graphene.List(LangStringEntryInput, description=docs.UpdateLegalContents.legal_notice_entries)
        terms_and_conditions_entries = graphene.List(LangStringEntryInput, description=docs.UpdateLegalContents.terms_and_conditions_entries)
        cookies_policy_entries = graphene.List(LangStringEntryInput, description=docs.UpdateLegalContents.cookies_policy_entries)
        privacy_policy_entries = graphene.List(LangStringEntryInput, description=docs.UpdateLegalContents.privacy_policy_entries)
        user_guidelines_entries = graphene.List(LangStringEntryInput, description=docs.UpdateLegalContents.user_guidelines_entries)
        mandatory_legal_contents_validation = graphene.Boolean(required=True, description=docs.UpdateLegalContents.mandatory_legal_contents_validation)

    legal_contents = graphene.Field(lambda: LegalContents)

    @staticmethod
    @abort_transaction_on_exception
    def mutate(root, args, context, info):
        LEGAL_NOTICE_ATTACHMENT = models.AttachmentPurpose.LEGAL_NOTICE_ATTACHMENT.value
        TERMS_AND_CONDITIONS_ATTACHMENT = models.AttachmentPurpose.TERMS_AND_CONDITIONS_ATTACHMENT.value
github mirumee / saleor / saleor / graphql / payment / types.py View on Github external
class Payment(CountableDjangoObjectType):
    charge_status = PaymentChargeStatusEnum(
        description="Internal payment status.", required=True
    )
    actions = graphene.List(
        OrderAction,
        description="""List of actions that can be performed in
        the current state of a payment.""",
        required=True,
    )
    total = graphene.Field(Money, description="Total amount of the payment.")
    captured_amount = graphene.Field(
        Money, description="Total amount captured for this payment."
    )
    billing_address = graphene.Field(Address, description="Customer billing address.")
    transactions = graphene.List(
        Transaction, description="List of all transactions within this payment."
    )
    available_capture_amount = graphene.Field(
        Money, description="Maximum amount of money that can be captured."
    )
    available_refund_amount = graphene.Field(
        Money, description="Maximum amount of money that can be refunded."
    )
    credit_card = graphene.Field(
        CreditCard, description="The details of the card used for this payment."
    )

    class Meta:
        description = "Represents a payment of a given type."
        interfaces = [relay.Node]
        model = models.Payment
github openstates / openstates.org / graphapi / legislative.py View on Github external
legislative_session = graphene.String()
    relation_type = graphene.String()

    related_bill = graphene.Field("graphapi.legislative.BillNode")


class BillActionNode(graphene.ObjectType):
    organization = graphene.Field(OrganizationNode)
    description = graphene.String()
    date = graphene.String()
    classification = graphene.List(graphene.String)
    order = graphene.Int()
    extras = graphene.String()
    vote = graphene.Field("graphapi.legislative.VoteEventNode")

    related_entities = graphene.List(RelatedEntityNode)

    def resolve_related_entities(self, info):
        if "related_entities" not in getattr(self, "_prefetched_objects_cache", []):
            return optimize(
                self.related_entities.all(), info, None, ["organization", "person"]
            )
        else:
            return self.related_entities.all()


class MimetypeLinkNode(graphene.ObjectType):
    media_type = graphene.String()
    url = graphene.String()
    text = graphene.String()
github msanatan / django_graphql_movies / django_graphql_movies / movies / schema.py View on Github external
def resolve_actors(self, info, **kwargs):
        return Actor.objects.all()

    def resolve_movies(self, info, **kwargs):
        return Movie.objects.all()


# Create Input Object Types
class ActorInput(graphene.InputObjectType):
    id = graphene.ID()
    name = graphene.String()

class MovieInput(graphene.InputObjectType):
    id = graphene.ID()
    title = graphene.String()
    actors = graphene.List(ActorInput)
    year = graphene.Int()

# Create mutations for actors
class CreateActor(graphene.Mutation):
    class Arguments:
        input = ActorInput(required=True)

    ok = graphene.Boolean()
    actor = graphene.Field(ActorType)

    @staticmethod
    def mutate(root, info, input=None):
        ok = True
        actor_instance = Actor(name=input.name)
        actor_instance.save()
        return CreateActor(ok=ok, actor=actor_instance)
github vaexio / vaex / packages / vaex-graphql / vaex / graphql / __init__.py View on Github external
def create_groupby(df, groupby):
    postfix = "_".join(groupby)
    if postfix:
        postfix = "_" + postfix
    class GroupByBase(graphene.ObjectType):
        count = graphene.List(graphene.Int)
        keys = graphene.List(graphene.Int)

        def __init__(self, df, by=None):
            self.df = df
            self.by = [] if by is None else by
            self._groupby = None # cached lazy object
            super(GroupByBase, self).__init__()

        @property
        def groupby(self):
            if self._groupby is None:
                self._groupby = self.df.groupby(self.by)
            return self._groupby

        def resolve_count(self, info):
            dfg = self.groupby.agg('count')