示例#1
0
文件: fields.py 项目: jhgg/graphene
 def get_field(self, schema):
     if self.field_object_type:
         field = NodeTypeField(self.field_object_type)
         field.contribute_to_class(self.object_type, self.field_name)
         return field.internal_field(schema)
     from graphene.relay.types import BaseNode
     return BaseNode.get_definitions(schema).node_field
示例#2
0
文件: fields.py 项目: jhgg/graphene
    def inner_field(self, schema):
        from graphene.relay.types import BaseNode
        node_field = BaseNode.get_definitions(schema).node_field

        def resolver(instance, args, info):
            global_id = args.get('id')
            resolved_global_id = from_global_id(global_id)
            if resolved_global_id.type == self.field_object_type._meta.type_name:
                return node_field.resolver(instance, args, info)

        args = OrderedDict([(a.name, a) for a in node_field.args])
        field = Field(self.field_object_type, id=args['id'], resolve=resolver)
        field.contribute_to_class(self.object_type, self.field_name)

        return field