Skip to content

Commit ecdeef3

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

File tree

11 files changed

+31
-19
lines changed

11 files changed

+31
-19
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Fixed
66

77
* config: Fixed `jobs` config section validation.
8+
* hasura: Fixed metadata generation for v2.3.0 and above.
89
* tzkt: Fixed `get_originated_contracts` and `get_similar_contracts` methods response.
910

1011
## 5.0.0-rc3 - 2022-03-28

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.3.1
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.3.1
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.3.1
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.3.1
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.3.1
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.3.1
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.3.1
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
@@ -316,5 +316,7 @@ def _help(self) -> str:
316316
return f"""
317317
Failed to configure Hasura: {self.msg}
318318
319+
Check out Hasura logs for more information.
320+
319321
GraphQL integration docs: https://docs.dipdup.net/graphql/
320322
"""

src/dipdup/hasura.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import orjson as json
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)