当前位置: 首页>>代码示例>>Python>>正文


Python graphene.ID属性代码示例

本文整理汇总了Python中graphene.ID属性的典型用法代码示例。如果您正苦于以下问题:Python graphene.ID属性的具体用法?Python graphene.ID怎么用?Python graphene.ID使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在graphene的用法示例。


在下文中一共展示了graphene.ID属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: perform_mutation

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import ID [as 别名]
def perform_mutation(cls, root, info, **data):
        """Perform the mutation.

        Delete the instance from the database given its `id` attribute
        in the input data.
        """
        instance = cls.get_instance(info, data.get('id'))

        db_id = instance.id
        cls.delete(info, instance)

        # After the instance is deleted, set its ID to the original database's
        # ID so that the success response contains ID of the deleted object.
        instance.id = db_id
        return cls(**{cls._meta.return_field_name: instance})


# Compatibility with older versions 
开发者ID:0soft,项目名称:graphene-django-plus,代码行数:20,代码来源:mutations.py

示例2: __init__

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import ID [as 别名]
def __init__(self, _type, *args, **kwargs):
        kwargs["id"] = ID(
            required=True, description="Django object unique identification field"
        )

        super(DjangoObjectField, self).__init__(_type, *args, **kwargs) 
开发者ID:eamigo86,项目名称:graphene-django-extras,代码行数:8,代码来源:fields.py

示例3: convert_column_to_string

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import ID [as 别名]
def convert_column_to_string(type, attribute, registry=None):
    if attribute.is_hash_key:
        return ID(description=attribute.attr_name, required=not attribute.null)

    return String(description=getattr(attribute, 'attr_name'),
                  required=not (getattr(attribute, 'null', True))) 
开发者ID:yfilali,项目名称:graphql-pynamodb,代码行数:8,代码来源:converter.py

示例4: convert_column_to_float_or_id

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import ID [as 别名]
def convert_column_to_float_or_id(type, attribute, registry=None):
    if attribute.is_hash_key:
        return ID(description=attribute.attr_name, required=not attribute.null)

    return Float(description=attribute.attr_name, required=not attribute.null) 
开发者ID:yfilali,项目名称:graphql-pynamodb,代码行数:7,代码来源:converter.py

示例5: __init__

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import ID [as 别名]
def __init__(self):
        self._typeMap = {}
        self.Field = create_registry_field(self)
        self.Argument = create_registry_argument(self)
        self.List = create_registry_list(self)
        self.NonNull = create_registry_nonnull(self)
        registering_metaclass = create_registering_metaclass(self)
        self.Union = create_union(registering_metaclass, self)
        self.Enum = create_enum(registering_metaclass)
        self.Mutation = graphene.Mutation

        # Not looping over GRAPHENE_TYPES in order to not fool lint
        self.ObjectType = create_registering_class(graphene.ObjectType, registering_metaclass)
        self.InputObjectType = create_registering_class(
            graphene.InputObjectType, registering_metaclass
        )
        self.Interface = create_registering_class(graphene.Interface, registering_metaclass)
        self.Scalar = create_registering_class(graphene.Scalar, registering_metaclass)

        # Not looping over GRAPHENE_BUILTINS in order to not fool lint
        self.String = graphene.String
        self.addType(graphene.String)
        self.Int = graphene.Int
        self.addType(graphene.Int)
        self.Float = graphene.Float
        self.addType(graphene.Float)
        self.Boolean = graphene.Boolean
        self.addType(graphene.Boolean)
        self.ID = graphene.ID
        self.addType(graphene.ID)
        self.GenericScalar = GenericScalar
        self.addType(GenericScalar) 
开发者ID:dagster-io,项目名称:dagster,代码行数:34,代码来源:dauphin_registry.py

示例6: convert_column_to_int_or_id

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import ID [as 别名]
def convert_column_to_int_or_id(type, column, registry=None):
    if column.primary_key or column.foreign_keys:
        return graphene.ID(
            description=get_column_doc(column),
            required=not (is_column_nullable(column)),
        )
    else:
        return graphene.Int(
            description=get_column_doc(column),
            required=not (is_column_nullable(column)),
        ) 
开发者ID:briancappello,项目名称:flask-unchained,代码行数:13,代码来源:object_types.py

示例7: convert_field_to_id

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import ID [as 别名]
def convert_field_to_id(field, registry=None):
    return graphene.ID(
        description=get_field_description(field, registry), required=field.required
    ) 
开发者ID:graphql-python,项目名称:graphene-mongo,代码行数:6,代码来源:converter.py

示例8: test_should_update

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import ID [as 别名]
def test_should_update(fixtures):
    class UpdateEditor(graphene.Mutation):
        class Arguments:
            id = graphene.ID()
            first_name = graphene.String()

        editor = graphene.Field(EditorNode)

        def mutate(self, info, id, first_name):
            editor = Editor.objects.get(id=id)
            editor.first_name = first_name
            editor.save()
            return UpdateEditor(editor=editor)

    class Query(graphene.ObjectType):

        node = Node.Field()

    class Mutation(graphene.ObjectType):

        update_editor = UpdateEditor.Field()

    query = """
        mutation EditorUpdater {
            updateEditor(
                id: "1"
                firstName: "Tony"
            ) {
                editor {
                    firstName
                }
            }
        }
    """
    expected = {"updateEditor": {"editor": {"firstName": "Tony"}}}
    schema = graphene.Schema(query=Query, mutation=Mutation)
    result = schema.execute(query)
    # print(result.data)
    assert not result.errors
    assert result.data == expected 
开发者ID:graphql-python,项目名称:graphene-mongo,代码行数:42,代码来源:test_mutation.py

示例9: test_should_uuid_convert_id

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import ID [as 别名]
def test_should_uuid_convert_id():
    assert_conversion(mongoengine.UUIDField, graphene.ID) 
开发者ID:graphql-python,项目名称:graphene-mongo,代码行数:4,代码来源:test_converter.py

示例10: test_should_object_id_convert_id

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import ID [as 别名]
def test_should_object_id_convert_id():
    assert_conversion(mongoengine.ObjectIdField, graphene.ID) 
开发者ID:graphql-python,项目名称:graphene-mongo,代码行数:4,代码来源:test_converter.py

示例11: convert_form_field_to_list

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import ID [as 别名]
def convert_form_field_to_list(field):
    return List(ID, required=field.required) 
开发者ID:graphql-python,项目名称:graphene-django,代码行数:4,代码来源:converter.py

示例12: convert_form_field_to_id

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import ID [as 别名]
def convert_form_field_to_id(field):
    return ID(required=field.required) 
开发者ID:graphql-python,项目名称:graphene-django,代码行数:4,代码来源:converter.py

示例13: test_should_auto_convert_id

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import ID [as 别名]
def test_should_auto_convert_id():
    assert_conversion(models.AutoField, graphene.ID, primary_key=True) 
开发者ID:graphql-python,项目名称:graphene-django,代码行数:4,代码来源:test_converter.py

示例14: _is_list_of_ids

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import ID [as 别名]
def _is_list_of_ids(field):
    return (
        isinstance(field.type, graphene.List) and
        field.type.of_type == graphene.ID
    ) 
开发者ID:0soft,项目名称:graphene-django-plus,代码行数:7,代码来源:mutations.py

示例15: _is_id_field

# 需要导入模块: import graphene [as 别名]
# 或者: from graphene import ID [as 别名]
def _is_id_field(field):
    return (
        field.type == graphene.ID or
        isinstance(field.type, graphene.NonNull) and
        field.type.of_type == graphene.ID
    ) 
开发者ID:0soft,项目名称:graphene-django-plus,代码行数:8,代码来源:mutations.py


注:本文中的graphene.ID属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。