After you tested your Mesh with
dev command, it is time to build Mesh artifacts for advanced usage with the following command.
dev command, GraphQL Mesh fetches your remote data sources at runtime, during initialisation, to retrieve their raw schema and potentially translate it into GraphQL (when relevant).
However, to reduce dependencies at runtime, GraphQL Mesh allows you to cache the raw schema of your remote data sources so they are locally available at runtime.
This is important because if, for instance, one of the data sources you consume experiences downtime when your GraphQL Mesh server is starting, this would cause a failure and will ultimately force you to restart your server; effectively making this unavailable until you're able to start it successfully (in this case, only when all your data sources can provide their raw schemas).
By following the steps below, you can instead move this dependency from runtime to build-time, by invoking a command that downloads the remote schemas and save them into a local file to be used as cache during server initialisation. In this case if one of your remote resources is not available when you attempt to build this local cache, it would cause a build failure which will stop your deployment process; hence not affecting your service availability.
Mesh is now able to start a GraphQL Server and it doesn't need other services running.
You can use the Mesh
GraphQLSchema instance to query your data from your application code by using
getBuiltMesh with your configuration object.
This will return for your a modified version of GraphQL's
execute, so you can use it directly to fetch your data:
You can find dumped schema under
.mesh folder as
You can make sure your existing Mesh artifacts are still valid and safe to use in production. So when you run the following command, Mesh will validate the existing artifacts by introspecting the input sources again.