---
description:
  Improve your GraphQL schema with the extend transform in GraphQL Mesh. Extend schema with
  additional type definitions and resolvers.
---

import { Callout } from '@theguild/components'

# Extend Transform (experimental)

`extend` transform allows you to extend the source's schema directly on the source level. But this
might cause inconsistency if the schema heavily relies on that schema's existing structure. This
transform can be used for the data sources that return fixed results.

For example, OpenAPI and JSON Schema handlers are good examples of this kind of source. In contrast,
PostGraphile and GraphQL handlers don't because they rely on their existing structure. The resolvers
added by this transform access directly to `root`, `args`, and `context` of that schema, so you
cannot use `selectionSet` (actually, you shouldn't, because this is not a root level transform).

<Callout>
  Note: This transform cannot access other sources; it can only be used at the source level.
</Callout>

<Callout type="warning" emoji="⚠️">
  Please DO NOT use this transform unless you know what you're doing! We strongly recommend you to
  extend the schema using `additionalTypeDefs` and `additionalResolvers` as described in [Extend
  Schema](/docs/guides/extending-unified-schema) part in this documentation.
</Callout>

## How to use?

Add the following configuration under the source configuration;

```yaml filename=".meshrc.yaml"
transforms:
  - extend:
      typeDefs: ./someTypeDefs.graphql
      resolvers: ./someResolvers.ts
```

You can extend the existing types in:

```graphql filename="someTypeDefs.graphql"
extend type User {
  fullName: String
}
```

And define resolvers for those types;

```ts filename="someResolvers.ts"
module.exports = {
  User: {
    fullName: user => `${user.firstName} ${user.lastName}` // e.g. `user` is the raw result returned by your data source
  }
}
```

## Config API Reference

import API from '../../../generated-markdown/ExtendTransform.generated.md'

<API />
