Skip to content

Commit

Permalink
Fixes for Datasette 1.0 API changes, refs #96
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Sep 7, 2023
1 parent ded886e commit 3bdcba8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions datasette_graphql/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ class _TableCollection(graphene.ObjectType):
edges = graphene.List(_Edge)

def resolve_totalCount(parent, info):
return parent["filtered_table_rows_count"]
return parent["count"]

def resolve_nodes(parent, info):
return parent["rows"]
Expand Down Expand Up @@ -570,6 +570,8 @@ async def resolve_table(
elif sort_desc:
qs["_sort_desc"] = column_name_rev[sort_desc.value]

qs["_extra"] = "count"

path_with_query_string = "/{}/{}.json?{}".format(
database_name, table_name, urllib.parse.urlencode(qs)
)
Expand All @@ -593,7 +595,6 @@ async def resolve_table(
)

data = (await datasette.client.get(path_with_query_string)).json()
data["rows"] = [dict(zip(data["columns"], row)) for row in data["rows"]]
# If any cells are $base64, decode them into bytes objects
for row in data["rows"]:
for key, value in row.items():
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def get_long_description():
packages=["datasette_graphql"],
entry_points={"datasette": ["graphql = datasette_graphql"]},
install_requires=[
"datasette>=0.58.1",
"datasette>=1.0a5",
"graphene>=3.1.0,<4.0",
"graphql-core>=3.2.1",
"sqlite-utils",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_graphql.py
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ async def test_time_limit_ms(db_path):
assert len(response_json["errors"]) == 1
assert response_json["errors"][0]["message"].startswith("Time limit exceeded: ")
assert response_json["errors"][0]["message"].endswith(
" > 0.1ms - /test/repos.json?_nofacet=1&_size=10&_search=dogspotter"
" > 0.1ms - /test/repos.json?_nofacet=1&_size=10&_search=dogspotter&_extra=count"
)


Expand Down

0 comments on commit 3bdcba8

Please sign in to comment.