plugins/ant-graphql/functions/subscribe.js
async function subscribe (ant, field, directiveArgs, fieldArgs) {
  if (ant && field && directiveArgs && directiveArgs.to) {
    const antFunction =  ant.functionController.getFunction(directiveArgs.to);
    if (!antFunction) {
      logger.error(new AntError(
        `Could not find "${directiveArgs.to}" function`
      ));
      return null;
    }
    try {
      const currentValue = antFunction.run(fieldArgs);
      if (currentValue instanceof Observable) {
        return new AsyncIterableObserver(field.fieldName, currentValue);
      }
      return currentValue;
    } catch (e) {
      logger.error(new AntError(
        `Could not run "${directiveArgs.to}" function`,
        e
      ));
    }
  }
  return null;
}
async function subscribe (ant, field, directiveArgs, fieldArgs) {
  if (ant && field && directiveArgs && directiveArgs.to) {
    const antFunction =  ant.functionController.getFunction(directiveArgs.to);
    if (!antFunction) {
      logger.error(new AntError(
        `Could not find "${directiveArgs.to}" function`
      ));
      return null;
    }
    try {
      const currentValue = antFunction.run(fieldArgs);
      if (currentValue instanceof Observable) {
        return new AsyncIterableObserver(field.fieldName, currentValue);
      }
      return currentValue;
    } catch (e) {
      logger.error(new AntError(
        `Could not run "${directiveArgs.to}" function`,
        e
      ));
    }
  }
  return null;
}
async function subscribe ( ant , field , directiveArgs , fieldArgs ) { if ( ant && field && directiveArgs && directiveArgs . to ) { const antFunction = ant . functionController . getFunction ( directiveArgs . to ) ; if ( ! antFunction ) { logger . error ( new AntError ( ` ${ directiveArgs . to } ` ) ) ; return null ; } try { const currentValue = antFunction . run ( fieldArgs ) ; if ( currentValue instanceof Observable ) { return new AsyncIterableObserver ( field . fieldName , currentValue ) ; } return currentValue ; } catch ( e ) { logger . error ( new AntError ( ` ${ directiveArgs . to } ` , e ) ) ; } } return null ; }
This function resolves a GraphQL @subscribe directive value.
This function resolves a GraphQL