MCPcopy
hub / github.com/geldata/gel / assert_graphql_query_result

Method assert_graphql_query_result

edb/testbase/http.py:425–485  ·  view source on GitHub ↗
(
        self,
        query,
        result,
        *,
        msg=None,
        sort=None,
        operation_name=None,
        use_http_post=True,
        native_variables=None,
        variables=None,
        globals=None,
        deprecated_globals=None,
        config=None,
    )

Source from the content-addressed store, hash-verified

423 await con.aclose()
424
425 def assert_graphql_query_result(
426 self,
427 query,
428 result,
429 *,
430 msg=None,
431 sort=None,
432 operation_name=None,
433 use_http_post=True,
434 native_variables=None,
435 variables=None,
436 globals=None,
437 deprecated_globals=None,
438 config=None,
439 ):
440 # Try to use the native protocol first!
441 if operation_name is None and config is None:
442 try:
443 res = asyncio.run(self._native_graphql_query(
444 query,
445 variables=(
446 native_variables if native_variables is not None
447 else variables
448 ),
449 globals=globals or deprecated_globals,
450 ))
451
452 if sort is not None:
453 # GQL will always have a single object
454 # returned. The data is in the top-level fields,
455 # so that's what needs to be sorted.
456 for r in res.values():
457 assert_data_shape.sort_results(r, sort)
458
459 assert_data_shape.assert_data_shape(
460 res, result, self.fail, message=msg)
461 except gel.UnsupportedFeatureError as e:
462 if 'Default variables are not supported' in str(e):
463 # Whatever.
464 pass
465 else:
466 raise
467
468 res = self.graphql_query(
469 query,
470 operation_name=operation_name,
471 use_http_post=use_http_post,
472 variables=variables,
473 globals=globals,
474 deprecated_globals=deprecated_globals,
475 config=config,
476 )
477
478 if sort is not None:
479 # GQL will always have a single object returned. The data is
480 # in the top-level fields, so that's what needs to be sorted.
481 for r in res.values():
482 assert_data_shape.sort_results(r, sort)

Calls 5

_native_graphql_queryMethod · 0.95
graphql_queryMethod · 0.95
assert_data_shapeMethod · 0.80
runMethod · 0.45
valuesMethod · 0.45