def execute_and_validate_and_strip( schema, document_ast, *args, **kwargs ): """ Args: schema (GraphQLSchema) document_ast (Document) args (Any) kwargs (Any) Returns Union[ExecutionResult, Observable] """ result = execute_and_validate(schema, document_ast, *args, **kwargs) # Search request document to determine if 'stripNull: true' is set # as and argument. It can not be done in the middleware, as they # can be Promises/futures (so may not been resolved at this point). variable_values = kwargs['variable_values'] or {} doc_args = AstDocArguments(schema, document_ast, variable_values) if doc_args.has_arg_val(STRIP_ARG, True): if kwargs.get('return_promise', False) and hasattr(result, 'then'): return result.then(null_stripper) return null_stripper(result) return result
def execute_and_validate_and_strip( schema: 'GraphQLSchema', document_ast: 'Document', *args: Any, **kwargs: Any) -> Union['ExecutionResult', Observable]: """Wrapper around graphql ``execute_and_validate()`` that adds null stripping.""" result = execute_and_validate(schema, document_ast, *args, **kwargs) # Search request document to determine if 'stripNull: true' is set # as and argument. It can not be done in the middleware, as they # can be Promises/futures (so may not been resolved at this point). variable_values = kwargs['variable_values'] or {} doc_args = AstDocArguments(schema, document_ast, variable_values) if doc_args.has_arg_val(STRIP_ARG, True): if kwargs.get('return_promise', False) and hasattr(result, 'then'): return result.then(null_stripper) # type: ignore[union-attr] return null_stripper(result) return result