Netlify functions - build order

Hello Netlify Support Team,

We are trying to evaluate Netlify functions to see if it can support our use case (below).

We have a Gatsby.js website with an Apollo Server instance as the API (JAM stack). This API has two use cases.

  1. Provide dynamic content during runtime (i.e power AJAX calls)
  2. Provide data to during build time to create pages -

We are considering Netlify hosting option. We would like to know if Netlify functions could be used to host our Apollo Server (API) in a way that satisfies use case #2 above (use case #1 appears to be supported by default).

According to documentation here

“… functions are deployed after the build …”

Above feature contradicts with our use case #2 - where the API (function) needs to be available before the build starts (because build depends on API).

Is there a way we can use Netlify functions to achieve #1 and #2 ?

Kind regards,

Netlify functions are meant to be used by the deployed site, in most cases. You could work around this by deploying your functions on a separate site so that they are available during the build/deploy process of your other site.