Hasura gives you CRUD + realtime GraphQL APIs with authorization & access control. However, in many cases, you will need to write APIs (queries, mutations) that contain custom logic. For example, implementing a payment API, or querying data that is not in your database.
Hasura has the ability to merge remote GraphQL schemas and provide a unified GraphQL API. Think of it
like automated schema stitching. All you need to do is build your own GraphQL service and then provide the HTTP endpoint to Hasura. Your GraphQL service can be written in any language or framework.
This is what Hasura running with "Remote schemas" looks like:
-**Remote Schema name**: an alias for the remote schema that must be unique on an instance of GraphQL Engine.
-**GraphQL server URL**: the endpoint at which your remote GraphQL server is available. This value can be entered
manually or by specifying an environment variable that contains this information. If you want to specify an
environment variable, please note that currently there is no validation that the environment variable is
actually available at the time of this configuration, so any errors in this configuration will result in a
runtime error.
-**Headers**: configure the headers to be sent to your custom GraphQL server.
- Toggle forwarding all headers sent by the client (when making a GraphQL query) to your remote GraphQL server.
- Send additional headers to your remote server - These can be static header name-value pairs; and/or pairs of "header name-environment variable name".
You can specify the value of the header to picked up from the enviroment variable.
**Example**: Let's say your remote GraphQL server needs a ``X-Api-Key`` as a header. As this value contains sensitive data (like API key in this
example), you can configure name of an environment variable which will hold the value. This environment variable needs to be present when you start
GraphQL Engine. When Hasura sends requests to your remote server, it will pick up the value from this environment variable.
..note::
If the remote schema configuration contains environment variables - either
for URL or headers - **environment variables need to be present** (GraphQL
engine should be started with these env variables) with valid values, when
adding the remote schema.
Click on the ``Add Remote Schema`` button to merge the remote schema.
Step-3: Make queries to the remote server from Hasura