# SchemaFile

The Schema for a GraphQL Api.

If no options are configured, schema will be generated
code-first.

Extends: SchemaFile
Implements: ISchema

- Source: [`aws-appsync/lib/schema.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/aws-appsync/lib/schema.ts#L64)
- Type last changed: v2.234.0 · 8 Jan 2026

## Example

```ts
const schema = new appsync.SchemaFile({ filePath: 'mySchemaFile' })
new appsync.GraphqlApi(this, 'api', {
  name: 'myApi',
  definition: appsync.Definition.fromSchema(schema),
  enhancedMetricsConfig: {
    dataSourceLevelMetricsBehavior: appsync.DataSourceLevelMetricsBehavior.FULL_REQUEST_DATA_SOURCE_METRICS,
    operationLevelMetricsConfig: appsync.OperationLevelMetricsConfig.ENABLED,
    resolverLevelMetricsBehavior: appsync.ResolverLevelMetricsBehavior.FULL_REQUEST_RESOLVER_METRICS,
  },
});
```

## Initializer

```ts
new SchemaFile(options: SchemaProps)
```

## Properties

- `definition`: string (required) — The definition for this schema.

## Methods

- `bind(api: IGraphQLApiRef, _options?: SchemaBindOptions): ISchemaConfig` — Called when the GraphQL Api is initialized to allow this object to bind to the stack.

  **Parameters**

  - `api` — The binding GraphQL Api.

- `fromAsset(filePath: string): SchemaFile // chainable` (static) — Generate a Schema from file.

  **Parameters**

  - `filePath` — the file path of the schema file.

  **Returns:** `SchemaAsset` with immutable schema definition
