2020-01-14 15:57:45 +03:00
.. meta ::
:description: Manage remote schemas with Hasura
:keywords: hasura, docs, remote schema
2020-03-11 22:42:36 +03:00
.. _remote_schemas:
2020-07-08 00:47:42 +03:00
Remote Schemas
2018-11-23 16:02:46 +03:00
==============
2018-12-03 15:12:24 +03:00
.. contents :: Table of contents
:backlinks: none
2020-07-08 00:47:42 +03:00
:depth: 1
2018-12-03 15:12:24 +03:00
:local:
2020-07-08 00:47:42 +03:00
Introduction
------------
2019-01-18 07:18:54 +03:00
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.
2018-11-23 16:02:46 +03:00
Hasura has the ability to merge remote GraphQL schemas and provide a unified GraphQL API. Think of it
2019-01-18 07:18:54 +03:00
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.
2018-11-23 16:02:46 +03:00
This is what Hasura running with "Remote schemas" looks like:
2020-08-25 19:21:21 +03:00
.. thumbnail :: /img/graphql/core/remote-schemas/remote-schema-arch.png
2018-11-23 16:02:46 +03:00
:class: no-shadow
2020-07-31 18:26:55 +03:00
:width: 900px
2020-01-08 16:20:18 +03:00
:alt: Architecture of Hasura with remote schemas
2018-11-23 16:02:46 +03:00
2019-09-11 10:17:14 +03:00
Use cases
2018-11-23 16:02:46 +03:00
---------
- Custom business logic, like a payment API
- Querying data that is not available in your database
2019-09-11 10:17:14 +03:00
You can handle these use cases by writing resolvers in a custom GraphQL server
2019-01-18 07:18:54 +03:00
and making Hasura merge this "remote schema" with the existing auto-generated
2018-12-12 15:01:18 +03:00
schema. You can also add multiple remote schemas. Think of the merged schema as
a union of top-level nodes from each of the sub-schemas.
2019-01-18 07:18:54 +03:00
.. note ::
2018-11-23 16:02:46 +03:00
2019-01-18 07:18:54 +03:00
If you are looking for adding authorization & access control for your
app users to the GraphQL APIs that are auto-generated via Hasura, head to
2020-03-11 22:42:36 +03:00
:ref: `auth`
2018-11-23 16:02:46 +03:00
2020-07-08 00:47:42 +03:00
Remote schema relationships
---------------------------
2019-01-18 07:18:54 +03:00
2020-07-08 00:47:42 +03:00
You can create remote relationships between your tables and tables from your remote schema. Read more about this in the :ref: `remote_schema_relationships` section.
2019-01-18 07:18:54 +03:00
2020-07-08 00:47:42 +03:00
**See:**
2019-01-18 07:18:54 +03:00
2020-07-08 00:47:42 +03:00
.. toctree ::
:maxdepth: 1
adding-schema
schema-auth