Example #1
0
 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
Example #2
0
    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