# `mockServer`

The `mockServer` option under `graphql` configures the mock server for GraphQL schemas only.
Use it to turn the mock server off for GraphQL, or to change its position and name in the servers dropdown in Replay, without changing the mock server of your OpenAPI descriptions.

Each GraphQL schema file (`.graphql`, `.gql`) gets a mock server at `/_mock/<path-to-schema>/`.
The mock server answers queries and mutations with sample values, and the response follows the selection set of the query.
It doesn't support subscriptions, forced responses, or security scheme checks.

The GraphQL mock server needs version 1.0 or later of the `@redocly/framework` package.
A classic Realm project mocks OpenAPI descriptions only.
A classic Realm project ignores the `graphql.mockServer` option.

The `off` option turns off the mock server URL itself.
The `position` and `description` options change the servers dropdown in Replay, which is in early access for GraphQL.

**Early access**

This is a feature in early access.
It may not be available for your organization yet, and its behavior may change before general availability.

To request access to this feature, contact our [Support team](mailto:team@redocly.com).

The mockServer  is not available in Redoc Community Edition.

## Options

| Option | Type | Description |
| --- | --- | --- |
| off | boolean | Turn off the mock server for GraphQL schemas. Default: `false`. |
| position | string | Controls the position of the mock server in the servers dropdown in Replay. Possible values: `first`, `last`, `replace`, `off`. Default: `first`. |
| description | string | Name of the mock server in the servers dropdown in Replay. Default: `Mock server`. |

The `strictExamples` option of the root [`mockServer`](/docs/platform/config/mock-server) option applies to GraphQL schemas too; set it there, because `graphql.mockServer` does not accept it.
The `errorIfForcedExampleNotFound` option applies to OpenAPI descriptions only.

## Order of precedence

Options merge in the following order, and a later level overrides an earlier one:

1. The root `mockServer` option.
2. The root `graphql.mockServer` option.
3. The `mockServer` option in the `redocly.yaml` file of the folder that contains the schema, for example a product folder.
4. The `graphql.mockServer` option in that file.
5. The `mockServer` option in an API entry under `apis`.
6. The `graphql.mockServer` option in an API entry under `apis`.

## Examples

### Rename the mock server for all GraphQL APIs

The following example lists the mock server after the endpoints from [`servers`](/docs/platform/config/graphql/servers) and names it "Sandbox":

```yaml
graphql:
  mockServer:
    position: last
    description: Sandbox
```

### Turn off the mock server for GraphQL only

The following example keeps the mock server for OpenAPI descriptions and turns it off for every GraphQL schema:

```yaml
graphql:
  mockServer:
    off: true
```

### Turn off the mock server for one GraphQL API

The following example turns the mock server off for the `library` API only:

```yaml
apis:
  library@v1:
    root: ./graphql/library.graphql
    graphql:
      mockServer:
        off: true
```

## Resources

- **[Mock server configuration](/docs/platform/config/mock-server)** - Configure the mock server for every API description in the project
- **[Configure the mock server](/docs/platform/content/api-docs/configure-mock-server)** - Learn how the mock server answers OpenAPI and GraphQL requests
- **[GraphQL servers](/docs/platform/config/graphql/servers)** - Set the GraphQL endpoints that Replay lists next to the mock server
