@@ -102,7 +102,7 @@ def __init__(
102102 self ._hasura_config = hasura_config
103103 self ._database_config = database_config
104104
105- async def configure (self ) -> None :
105+ async def configure (self , force : bool = False ) -> None :
106106 """Generate Hasura metadata and apply to instance with credentials from `hasura` config section."""
107107
108108 if self ._database_config .schema_name != 'public' :
@@ -116,7 +116,7 @@ async def configure(self) -> None:
116116 metadata = await self ._fetch_metadata ()
117117 metadata_hash = self ._hash_metadata (metadata )
118118
119- if hasura_schema .hash == metadata_hash :
119+ if not force and hasura_schema .hash == metadata_hash :
120120 self ._logger .info ('Metadata is up to date, no action required' )
121121 return
122122
@@ -342,6 +342,9 @@ async def _generate_query_collections_metadata(self) -> List[Dict[str, Any]]:
342342 for query_name , query in self ._iterate_graphql_queries ():
343343 queries .append ({'name' : query_name , 'query' : query })
344344
345+ # NOTE: This is the only view we add by ourselves and thus know all params. Won't work for any view.
346+ queries .append (self ._format_rest_head_status_query ())
347+
345348 return queries
346349
347350 async def _generate_rest_endpoints_metadata (self , query_names : List [str ]) -> List [Dict [str , Any ]]:
@@ -455,6 +458,16 @@ def _format_rest_query(self, name: str, table: str, filter: str, fields: Iterabl
455458 'query' : 'query ' + name + ' (' + query_arg + ') {' + table + '(' + query_filter + ') {' + query_fields + '}}' ,
456459 }
457460
461+ def _format_rest_head_status_query (self ) -> Dict [str , Any ]:
462+ name = 'dipdup_head_status'
463+ if self ._hasura_config .camel_case :
464+ name = humps .camelize (name )
465+
466+ return {
467+ 'name' : name ,
468+ 'query' : 'query ' + name + ' ($name: String!) {' + name + '(where: {name: {_eq: $name}}) {status}}' ,
469+ }
470+
458471 def _format_rest_endpoint (self , query_name : str ) -> Dict [str , Any ]:
459472 return {
460473 "definition" : {
0 commit comments