How to use the @nestjs/graphql.DelegateProperty function in @nestjs/graphql

To help you get started, we’ve selected a few @nestjs/graphql examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Innovic-io / angular-nestjs-rendering / src / server / modules / pets / pets.resolvers.ts View on Github external
// TODO this need improvement
  // not sure is it right
  @Subscription('dateChanged')
  async dateChanged(obj, args, context, info) {

    return {

      subscribe: async () => {

        return await ownerSubscription.asyncIterator('dateChanged');
      },
    };
  }

  @DelegateProperty('chirps')
  findChirpsByUserId() {
    return (mergeInfo: MergeInfo) => ({
      fragment: `fragment OwnerFragment on Owner { _id }`,
      resolve(parent, args, context?, info?) {

        const ownerId = parent._id;
        return mergeInfo.delegate(
          'query',
          'chirpsByOwnerId',
          {
            ownerId,
          },
          context,
          info,
        );
      },