Async_#
Toplevel Subgrounds module
This module implements the toplevel API that most developers will be using when querying The Graph with Subgrounds.
- class subgrounds.client.async_.AsyncSubgrounds(timeout=30, headers=<factory>, global_transforms=<factory>, subgraphs=<factory>, schema_cache=PosixPath('schemas'))#
- property _client#
Cached client
- async load(url, save_schema=False, is_subgraph=True)#
Performs introspection on the provided GraphQL API
url
to get the schema, stores the schema ifsave_schema
isTrue
and returns a generated class representing the GraphQL endpoint with all its entities.
- async load_subgraph(url, save_schema=False)#
Performs introspection on the provided GraphQL API
url
to get the schema, stores the schema ifsave_schema
isTrue
and returns a generated class representing the subgraph with all its entities.- Parameters:
- Returns:
A generated class representing the subgraph and its entities
- Return type:
- async load_api(url, save_schema=False)#
- Performs introspection on the provided GraphQL API
url
to get the schema, stores the schema if
save_schema
isTrue
and returns a generated class representing the GraphQL endpoint with all its entities.
- Performs introspection on the provided GraphQL API
- async execute(req, pagination_strategy=LegacyStrategy)#
Executes a
DataRequest
and returns aDataResponse
.- Parameters:
req (DataRequest) -- The
DataRequest
object to be executedpagination_strategy (Optional[Type[PaginationStrategy]]) -- A Class implementing the
PaginationStrategy
Protocol
. IfNone
, then automatic pagination is disabled. Defaults toLegacyStrategy
.
- Returns:
A
DataResponse
object representing the response- Return type:
- async query_json(fpaths, pagination_strategy=LegacyStrategy)#
See
query_json()
.- Parameters:
fpaths (subgrounds.subgraph.fieldpath.FieldPath | list[subgrounds.subgraph.fieldpath.FieldPath]) -- One or more
FieldPath
objects that should be included in the request.pagination_strategy (Optional[Type[PaginationStrategy]]) -- A Class implementing the
PaginationStrategy
Protocol
. IfNone
, then automatic pagination is disabled. Defaults toLegacyStrategy
.
- Returns:
The reponse data
- Return type:
- async query_df(fpaths, columns=None, concat=False, pagination_strategy=LegacyStrategy)#
See
query_df()
.- Parameters:
fpaths (subgrounds.subgraph.fieldpath.FieldPath | list[subgrounds.subgraph.fieldpath.FieldPath]) -- One or more FieldPath objects that should be included in the request
merge -- Whether or not to merge resulting dataframes.
pagination_strategy (Optional[Type[PaginationStrategy]]) -- A class implementing the
PaginationStrategy
Protocol
. IfNone
, then automatic pagination is disabled.
- Returns:
A
pandas.DataFrame
containing the reponse data.- Return type:
pandas.core.frame.DataFrame | list[pandas.core.frame.DataFrame]
- async query(fpaths, unwrap=True, pagination_strategy=LegacyStrategy)#
See
query()
.- Parameters:
fpaths (subgrounds.subgraph.fieldpath.FieldPath | list[subgrounds.subgraph.fieldpath.FieldPath]) -- One or more
FieldPath
object(s) to query.unwrap (bool) -- Flag indicating whether or not, in the case where the returned data is a list of one element, the element itself should be returned instead of the list. Defaults to
True
.pagination_strategy (Optional[Type[PaginationStrategy]]) -- A Class implementing the
PaginationStrategy
Protocol
. IfNone
, then automatic pagination is disabled. Defaults toLegacyStrategy
.
- Returns:
The
FieldPath
object(s) data- Return type: