コード例 #1
0
ファイル: fields.py プロジェクト: se77en/graphene
 def resolve(self, instance, args, info):
     resolved = super(ConnectionField, self).resolve(instance, args, info)
     if resolved:
         resolved = self.wrap_resolved(resolved, instance, args, info)
         assert isinstance(
             resolved, Iterable), 'Resolved value from the connection field have to be iterable'
         return connection_from_list(resolved, args)
コード例 #2
0
ファイル: types.py プロジェクト: SweepSouth/graphene
 def from_list(cls, iterable, args, context, info):
     assert isinstance(
         iterable, Iterable), 'Resolved value from the connection field have to be iterable'
     connection = connection_from_list(
         iterable, args, connection_type=cls,
         edge_type=cls.edge_type, pageinfo_type=PageInfo)
     connection.set_connection_data(iterable)
     return connection
コード例 #3
0
 def from_list(cls, iterable, args, info):
     assert isinstance(
         iterable, Iterable), 'Resolved value from the connection field have to be iterable'
     connection = connection_from_list(
         iterable, args, connection_type=cls,
         edge_type=cls.edge_type, pageinfo_type=PageInfo)
     connection.set_connection_data(iterable)
     return connection
コード例 #4
0
ファイル: fields.py プロジェクト: sevki/graphene
    def resolve(self, instance, args, info):
        from graphene.relay.types import PageInfo
        schema = info.schema.graphene_schema

        resolved = super(ConnectionField, self).resolve(instance, args, info)
        if resolved:
            resolved = self.wrap_resolved(resolved, instance, args, info)
            assert isinstance(
                resolved, Iterable), 'Resolved value from the connection field have to be iterable'

            node = self.get_object_type(schema)
            connection_type = self.get_connection_type(node)
            edge_type = self.get_edge_type(node)

            connection = connection_from_list(resolved, args, connection_type=connection_type,
                                              edge_type=edge_type, pageinfo_type=PageInfo)
            connection.set_connection_data(resolved)
            return connection
コード例 #5
0
#   }
factionType = GraphQLObjectType(
    name='Faction',
    description='A faction in the Star Wars saga',
    fields=lambda: {
        'id': global_id_field('Faction'),
        'name': GraphQLField(
            GraphQLString,
            description='The name of the faction.',
        ),
        'ships': GraphQLField(
            shipConnection,
            description='The ships used by the faction.',
            args=connection_args,
            resolver=lambda faction, args, *_: connection_from_list(
                [getShip(ship) for ship in faction.ships],
                args
            ),
        )
    },
    interfaces=[node_interface]
)

# This is the type that will be the root of our query, and the
# entry point into our schema.
#
# This implements the following type system shorthand:
#   type Query {
#     rebels: Faction
#     empire: Faction
#     node(id: String!): Node
#   }
コード例 #6
0
ファイル: schema.py プロジェクト: sjhewitt/graphql-relay-py
    name='Faction',
    description='A faction in the Star Wars saga',
    fields=lambda: {
        'id':
        global_id_field('Faction'),
        'name':
        GraphQLField(
            GraphQLString,
            description='The name of the faction.',
        ),
        'ships':
        GraphQLField(
            shipConnection,
            description='The ships used by the faction.',
            args=connection_args,
            resolver=lambda faction, args, *_: connection_from_list(
                [getShip(ship) for ship in faction.ships], args),
        )
    },
    interfaces=[node_interface])

# This is the type that will be the root of our query, and the
# entry point into our schema.
#
# This implements the following type system shorthand:
#   type Query {
#     rebels: Faction
#     empire: Faction
#     node(id: String!): Node
#   }
queryType = GraphQLObjectType(
    name='Query',