Skip to content

Commit 6436694

Browse files
committed
Fix Hasura metadata generation for v2.3.0 and above (#279)
* Better error handling * Fix metadata request
1 parent d8bbb3f commit 6436694

File tree

13 files changed

+53
-233
lines changed

13 files changed

+53
-233
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Please use [this](https://docs.gitlab.com/ee/development/changelog.html) documen
77
### Fixed
88

99
* config: Fixed default SQLite path (`:memory:`).
10+
* hasura: Fixed metadata generation for v2.3.0 and above.
1011
* tzkt: Fixed data loss when `skip_history` option is enabled.
1112

1213
## 4.2.6 - 2022-02-25

src/demo_hic_et_nunc/docker/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ services:
3030
retries: 5
3131

3232
hasura:
33-
image: hasura/graphql-engine:v2.2.0
33+
image: hasura/graphql-engine:v2.4.0
3434
ports:
3535
- 127.0.0.1:8080:8080
3636
depends_on:

src/demo_quipuswap/docker/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ services:
3030
retries: 5
3131

3232
hasura:
33-
image: hasura/graphql-engine:v2.2.0
33+
image: hasura/graphql-engine:v2.4.0
3434
ports:
3535
- 127.0.0.1:8080:8080
3636
depends_on:

src/demo_registrydao/docker/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ services:
3030
retries: 5
3131

3232
hasura:
33-
image: hasura/graphql-engine:v2.2.0
33+
image: hasura/graphql-engine:v2.4.0
3434
ports:
3535
- 127.0.0.1:8080:8080
3636
depends_on:

src/demo_tezos_domains/docker/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ services:
3030
retries: 5
3131

3232
hasura:
33-
image: hasura/graphql-engine:v2.2.0
33+
image: hasura/graphql-engine:v2.4.0
3434
ports:
3535
- 127.0.0.1:8080:8080
3636
depends_on:

src/demo_tezos_domains_big_map/docker/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ services:
3030
retries: 5
3131

3232
hasura:
33-
image: hasura/graphql-engine:v2.2.0
33+
image: hasura/graphql-engine:v2.4.0
3434
ports:
3535
- 127.0.0.1:8080:8080
3636
depends_on:

src/demo_tzbtc/docker/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ services:
3030
retries: 5
3131

3232
hasura:
33-
image: hasura/graphql-engine:v2.2.0
33+
image: hasura/graphql-engine:v2.4.0
3434
ports:
3535
- 127.0.0.1:8080:8080
3636
depends_on:

src/demo_tzcolors/docker/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ services:
3030
retries: 5
3131

3232
hasura:
33-
image: hasura/graphql-engine:v2.2.0
33+
image: hasura/graphql-engine:v2.4.0
3434
ports:
3535
- 127.0.0.1:8080:8080
3636
depends_on:

src/dipdup/exceptions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,5 +336,7 @@ def _help(self) -> str:
336336
return f"""
337337
Failed to configure Hasura: {self.msg}
338338
339+
Check out Hasura logs for more information.
340+
339341
GraphQL integration docs: https://docs.dipdup.net/graphql/
340342
"""

src/dipdup/hasura.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import humps # type: ignore
2121
from aiohttp import ClientConnectorError
2222
from aiohttp import ClientOSError
23+
from aiohttp import ClientResponseError
2324
from aiohttp import ServerDisconnectedError
2425
from pydantic.dataclasses import dataclass
2526
from tortoise import fields
@@ -161,16 +162,21 @@ async def configure(self, force: bool = False) -> None:
161162

162163
async def _hasura_request(self, endpoint: str, json: Dict[str, Any]) -> Dict[str, Any]:
163164
self._logger.debug('Sending `%s` request: %s', endpoint, dump_json(json))
164-
result = await self.request(
165-
method='post',
166-
cache=False,
167-
url=f'{self._hasura_config.url}/v1/{endpoint}',
168-
json=json,
169-
headers=self._hasura_config.headers,
170-
)
165+
try:
166+
result = await self.request(
167+
method='post',
168+
cache=False,
169+
url=f'{self._hasura_config.url}/v1/{endpoint}',
170+
json=json,
171+
headers=self._hasura_config.headers,
172+
)
173+
except ClientResponseError as e:
174+
raise HasuraError(f'{e.status} {e.message}') from e
175+
171176
self._logger.debug('Response: %s', result)
172-
if 'error' in result or 'errors' in result:
173-
raise HasuraError(result)
177+
if errors := result.get('error') or result.get('errors'):
178+
raise HasuraError(errors)
179+
174180
return result
175181

176182
async def _healthcheck(self) -> None:
@@ -212,8 +218,11 @@ def _hash_metadata(self, metadata: Dict[str, Any]) -> str:
212218
async def _replace_metadata(self, metadata: Dict[str, Any]) -> None:
213219
self._logger.info('Replacing metadata')
214220
endpoint, json = 'query', {
215-
"type": "replace_metadata",
216-
"args": metadata,
221+
'type': 'replace_metadata',
222+
'args': {
223+
'metadata': metadata,
224+
'allow_inconsistent_metadata': True,
225+
},
217226
}
218227
await self._hasura_request(endpoint, json)
219228

0 commit comments

Comments
 (0)