analogjs / analog

The fullstack meta-framework for Angular. Powered by Vite and Nitro
https://analogjs.org
MIT License
2.5k stars 240 forks source link

Feature: Add utility function to read server-side resolver from another resolver #1055

Closed brandonroberts closed 3 months ago

brandonroberts commented 4 months ago

The load resolver can be called from within another resolver by accessing it through the route config.

export const routeMeta: RouteMeta = {
  resolve: {
    data: async(route) => {
      // call server load resolver for this route from another resolver
      const data = await route.routeConfig?.resolve?.['load']?.(route);

      return { ...data };
    }
  }
}

We can add a utility function for this named getLoadResolver and use it as getLoadResolver(route).

import { getLoadResolver } from '@analogjs/router';

export const routeMeta: RouteMeta = {
  resolve: {
    data: async(route) => {
      // call server load resolver for this route from another resolver
      const data = await getLoadResolver(route);

      return { ...data };
    }
  }
}

Originally posted by @brandonroberts in https://github.com/analogjs/analog/issues/1039#issuecomment-2069965764

Tenessy commented 3 months ago

Hello @brandonroberts, can you assigned me to this task please ?

brandonroberts commented 3 months ago

@Tenessy yep, thanks!

brandonroberts commented 3 months ago

Closed by https://github.com/analogjs/analog/pull/1144 and released in 1.5.0