code: def execute(
      schema,
      document_ast,
      root_value=None,
      context_value=None,
      variable_values=None,
      operation_name=None,
      executor=None,
      return_promise=False,
      middleware=None,
  ):
      if use_experimental_executor:
          return experimental_execute(
              schema,
              document_ast,
              root_value,
              context_value,
              variable_values,
              operation_name,
              executor,
              return_promise,
              middleware,
          )
  
      assert schema, "Must provide schema"
      assert isinstance(schema, GraphQLSchema), (
          "Schema must be an instance of GraphQLSchema. Also ensure that there are "
          + "not multiple versions of GraphQL installed in your node_modules directory."
      )
      if middleware:
          if not isinstance(middleware, MiddlewareManager):
              middleware = MiddlewareManager(*middleware)
  
          assert isinstance(middleware, MiddlewareManager), (
              "middlewares have to be an instance"
              ' of MiddlewareManager. Received "{}".'.format(middleware)
          )
  
      if executor is None:
          executor = SyncExecutor()
  
      context = ExecutionContext(
          schema,
          document_ast,
          root_value,
          context_value,
          variable_values,
          operation_name,
          executor,
          middleware,
      )
  
      def executor(resolve, reject):
          return resolve(
              execute_operation(context, context.operation, root_value)
          )
  
      def on_rejected(error):
          context.errors.append(error)
          return None
  
      def on_resolve(data):
          if not context.errors:
              return ExecutionResult(data=data)
          return ExecutionResult(data=data, errors=context.errors)
  
      promise = Promise(executor).catch(on_rejected).then(on_resolve)
      if return_promise:
          return promise
      context.executor.wait_until_finished()
      return promise.get()
  
imports: import collections
  from collections.abc import Iterable
  import functools
  import logging
  import sys
  from wandb_promise import Promise, promise_for_dict, is_thenable
  from ..error import GraphQLError, GraphQLLocatedError
  from ..pyutils.default_ordered_dict import DefaultOrderedDict
  from ..pyutils.ordereddict import OrderedDict
  from ..type import GraphQLEnumType, GraphQLInterfaceType, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLScalarType, GraphQLSchema, GraphQLUnionType
  from .base import ExecutionContext, ExecutionResult, ResolveInfo, Undefined, collect_fields, default_resolve_fn, get_field_def, get_operation_root_type
  from .executors.sync import SyncExecutor
  from .experimental.executor import execute
  from .middleware import MiddlewareManager
label_desc: Use image node_id 1 for calling a global function with example usage: execute(schema, document_ast, root_value, context_value, variable_values, operation_name, executor, return_promise, middleware) and returns: promise, experimental_execute, resolve, None, ExecutionResult, promise, ExecutionResult