docs/src/pages/data-sources/remote-schemas.mdx
---
title: Remote Schemas in GrAMPS
---
<PageDescription>
Graphql has the ability to load and proxy other graphql servers using the [remote schema functionality](https://www.apollographql.com/docs/graphql-tools/remote-schemas/). This documentation will go into detail about how remote schemas work with GrAMPS.
</PageDescription>
Adding a remote schema into your GrAMPS set up it quite simple! For remote schemas you don't need to create a connector, model, resolvers, or schema.
That's because the remote graphql server should already have the proper hook ups. Instead you just need to provide GrAMPS with the proper route
to the remote graphql server. Let's take a look at the most basic setup:
```js
// index.js
export default {
namespace: 'Cool',
remoteSchema: {
url: "https://mycoolgraphqlserver.com/graphql", // URL to the remote graphql server
},
};
```
Remote schemas only need a single file. The index.js file. This needs to include a namespace so GrAMPS can keep track of the data source, and object
called `remoteSchema` that defines the location of the remote server. In order for GrAMPS to pull in the remote schema the remote server needs to have
the [introspection option](https://graphql.org/learn/introspection/) set to true.
Additionaly by default the schema pulled from the remote server will automatically be prepended with the name space. For example if you have a query,
`getId` it will be converted to `CoolGetId`. This is to help prevent duplicate query, mutation, and subscriptions across multiple data sources.
There are a few more advanced configuration options. Let's take a look at a fully fleshed out config and what each option is used for.
```js
// index.js
export default {
namespace: 'Cool',
remoteSchema: {
url: "https://mycoolgraphqlserver.com/graphql", // URL to the remote graphql server
prefix: 'CL', // Highly recommended, prefix prepends each typename with the provided string. This helps prevent duplicate types across data sources.
exitOnRemoteFail: true, // If set to false the GrAMPS server will still build even if it can't access a remote schema. By default set to true.
setContextCallback: (req, previousContext) => { // A callback function to add any express middleware to each request.
return {
headers: { // This example shows a session token being attached to the request header for authentication.
Authorization: previousContext.req.session.token
}
}
}
},
};
```