@nestjs/common#ParamData TypeScript Examples

The following examples show how to use @nestjs/common#ParamData. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: params.factory.ts    From nestjs-mercurius with MIT License 6 votes vote down vote up
exchangeKeyForValue(type: number, data: ParamData, args: any) {
    if (!args) {
      return null;
    }

    if (!isLoaderContext(args)) {
      return super.exchangeKeyForValue(type, data, args);
    }

    switch (type) {
      case GqlParamtype.ROOT:
        return args[0];
      case GqlParamtype.ARGS:
        return args[0].map(({ params }) =>
          data ? params[data as string] : params,
        );
      case GqlParamtype.CONTEXT:
        return data && args[1] ? args[1][data as string] : args[1];
      default:
        return null;
    }
  }