def test_fetch_entities():
    global Product

    @strawberry.federation.type(keys=['upc'])
    class Product():
        upc: str

        @classmethod
        def resolve_reference(cls, upc):
            return Product(upc)

    @strawberry.federation.type(extend=True)
    class Query():

        @strawberry.field
        def top_products(self, first: int) -> typing.List[Product]:
            return []
    schema = strawberry.federation.Schema(query=Query)
    query = '\n        query ($representations: [_Any!]!) {\n            _entities(representations: $representations) {\n                ... on Product {\n                    upc\n                }\n            }\n        }\n    '
    result = schema.execute_sync(query, variable_values={'representations': [{'__typename': 'Product', 'upc': 'B00005N5PF'}]})
    assert (not result.errors)
    assert (result.data == {'_entities': [{'upc': 'B00005N5PF'}]})
    del Product
def test_fetch_entities():
    global Product

    @strawberry.federation.type(keys=['upc'])
    class Product():
        upc: str

        @classmethod
        def resolve_reference(cls, upc):
            return Product(upc)

    @strawberry.federation.type(extend=True)
    class Query():

        @strawberry.field
        def top_products(self, first: int) -> typing.List[Product]:
            return []
    schema = strawberry.federation.Schema(query=Query)
    query = '\n        query ($representations: [_Any!]!) {\n            _entities(representations: $representations) {\n                ... on Product {\n                    upc\n                }\n            }\n        }\n    '
    result = schema.execute_sync(query, variable_values={'representations': [{'__typename': 'Product', 'upc': 'B00005N5PF'}]})
    assert (not result.errors)
    assert (result.data == {'_entities': [{'upc': 'B00005N5PF'}]})
    del Product