Quickstart

Quickstart: Wrap the public API in your GraphQL schema

If your app speaks GraphQL, wrap the REST public ring in resolvers so your front-end queries products and quotes in your own graph. This recipe gives you the exact code, uses only the unauthenticated public ring, and links to the endpoints and the application flow so the reader always has a next step.

2 min read

resolversREST behind GraphQL
DataLoaderBatch and cache
one graphUnified schema

Resolve from REST

const resolvers = {
  Query: {
    products: () =>
      fetch(`${BASE}/products`).then(r => r.json()).then(b => b.data),
    quote: (_, { amount, termMonths }) =>
      fetch(`${BASE}/quote`, {
        method: 'POST', headers: { 'Content-Type': 'application/json' },
        body: JSON.stringify({ amount, term_months: termMonths }),
      }).then(r => r.json()),
  },
};

Batch and cache

Use a per-request DataLoader to dedupe product lookups within one query, and cache the catalogue at the resolver so repeated queries do not each hit the REST API.

Frequently asked questions

Why wrap REST in GraphQL?

To give your front-end a single typed graph and combine Credicorp data with your own. The public ring stays the source of truth behind your resolvers.

How do I avoid N+1 calls?

Use DataLoader to batch and cache within a request, and cache the catalogue at the resolver so the same list isn't fetched repeatedly.

Funding for UK limited companies

Credicorp lends to your company, not to you personally — short-term working capital with no personal guarantee. See what your business could access.