Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
brandonroberts opened this issue Apr 25, 2024 · 0 comments

Comments

@brandonroberts
Copy link
Member

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 #1039 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant