# NoneDataSource

An AppSync dummy datasource.

Extends: [Construct](/cdk/api/v2/docs/constructs.Construct.html) › [BaseDataSource](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.BaseDataSource.html) › NoneDataSource
Implements: [IConstruct](/cdk/api/v2/docs/constructs.IConstruct.html), [IDependable](/cdk/api/v2/docs/constructs.IDependable.html)

- Source: [`aws-appsync/lib/data-source.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/aws-appsync/lib/data-source.ts#L235)
- Type last changed: v2.60.0 · 12 Jan 2023

## Example

TypeScript:

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

const noneDS = api.addNoneDataSource('none', {
  metricsConfig: appsync.DataSourceMetricsConfig.ENABLED,
});

noneDS.createResolver('noneResolver', {
  typeName: 'Mutation',
  fieldName: 'addDemoMetricsConfig',
  metricsConfig: appsync.ResolverMetricsConfig.ENABLED,
});
```

Python:

```python
schema = appsync.SchemaFile(file_path="mySchemaFile")
api = appsync.GraphqlApi(self, "api",
    name="myApi",
    definition=appsync.Definition.from_schema(schema),
    enhanced_metrics_config=appsync.EnhancedMetricsConfig(
        data_source_level_metrics_behavior=appsync.DataSourceLevelMetricsBehavior.PER_DATA_SOURCE_METRICS,
        operation_level_metrics_config=appsync.OperationLevelMetricsConfig.ENABLED,
        resolver_level_metrics_behavior=appsync.ResolverLevelMetricsBehavior.PER_RESOLVER_METRICS
    )
)

none_ds = api.add_none_data_source("none",
    metrics_config=appsync.DataSourceMetricsConfig.ENABLED
)

none_ds.create_resolver("noneResolver",
    type_name="Mutation",
    field_name="addDemoMetricsConfig",
    metrics_config=appsync.ResolverMetricsConfig.ENABLED
)
```

Java:

```java
SchemaFile schema = SchemaFile.Builder.create().filePath("mySchemaFile").build();
GraphqlApi api = GraphqlApi.Builder.create(this, "api")
        .name("myApi")
        .definition(Definition.fromSchema(schema))
        .enhancedMetricsConfig(EnhancedMetricsConfig.builder()
                .dataSourceLevelMetricsBehavior(DataSourceLevelMetricsBehavior.PER_DATA_SOURCE_METRICS)
                .operationLevelMetricsConfig(OperationLevelMetricsConfig.ENABLED)
                .resolverLevelMetricsBehavior(ResolverLevelMetricsBehavior.PER_RESOLVER_METRICS)
                .build())
        .build();

NoneDataSource noneDS = api.addNoneDataSource("none", DataSourceOptions.builder()
        .metricsConfig(DataSourceMetricsConfig.ENABLED)
        .build());

noneDS.createResolver("noneResolver", BaseResolverProps.builder()
        .typeName("Mutation")
        .fieldName("addDemoMetricsConfig")
        .metricsConfig(ResolverMetricsConfig.ENABLED)
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
var schema = new SchemaFile(new SchemaProps { FilePath = "mySchemaFile" });
var api = new GraphqlApi(this, "api", new GraphqlApiProps {
    Name = "myApi",
    Definition = Definition.FromSchema(schema),
    EnhancedMetricsConfig = new EnhancedMetricsConfig {
        DataSourceLevelMetricsBehavior = DataSourceLevelMetricsBehavior.PER_DATA_SOURCE_METRICS,
        OperationLevelMetricsConfig = OperationLevelMetricsConfig.ENABLED,
        ResolverLevelMetricsBehavior = ResolverLevelMetricsBehavior.PER_RESOLVER_METRICS
    }
});

var noneDS = api.AddNoneDataSource("none", new DataSourceOptions {
    MetricsConfig = DataSourceMetricsConfig.ENABLED
});

noneDS.CreateResolver("noneResolver", new BaseResolverProps {
    TypeName = "Mutation",
    FieldName = "addDemoMetricsConfig",
    MetricsConfig = ResolverMetricsConfig.ENABLED
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
schema := appsync.NewSchemaFile(&SchemaProps{
	FilePath: jsii.String("mySchemaFile"),
})
api := appsync.NewGraphqlApi(this, jsii.String("api"), &GraphqlApiProps{
	Name: jsii.String("myApi"),
	Definition: appsync.Definition_FromSchema(schema),
	EnhancedMetricsConfig: &EnhancedMetricsConfig{
		DataSourceLevelMetricsBehavior: appsync.DataSourceLevelMetricsBehavior_PER_DATA_SOURCE_METRICS,
		OperationLevelMetricsConfig: appsync.OperationLevelMetricsConfig_ENABLED,
		ResolverLevelMetricsBehavior: appsync.ResolverLevelMetricsBehavior_PER_RESOLVER_METRICS,
	},
})

noneDS := api.AddNoneDataSource(jsii.String("none"), &DataSourceOptions{
	MetricsConfig: appsync.DataSourceMetricsConfig_ENABLED,
})

noneDS.CreateResolver(jsii.String("noneResolver"), &BaseResolverProps{
	TypeName: jsii.String("Mutation"),
	FieldName: jsii.String("addDemoMetricsConfig"),
	MetricsConfig: appsync.ResolverMetricsConfig_ENABLED,
})
```

## Initializer

TypeScript:

```ts
new NoneDataSource(scope: Construct, id: string, props: NoneDataSourceProps)
```

Python:

```python
NoneDataSource(scope: Construct, id: str, props: NoneDataSourceProps)
```

Java:

```java
new NoneDataSource(Construct scope, String id, NoneDataSourceProps props)
```

C# / .NET:

```csharp
new NoneDataSource(Construct scope, string id, NoneDataSourceProps props)
```

Golang:

```go
NewNoneDataSource(Scope Construct, Id *string, Props NoneDataSourceProps)
```

## Construct Props

- `api`: [IGraphQLApiRef](/cdk/api/v2/docs/aws-cdk-lib.interfaces.aws_appsync.IGraphQLApiRef.html) (required) — The API to attach this data source to.

- `description`: string = None — the description of the data source.

- `metricsConfig`: [DataSourceMetricsConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.DataSourceMetricsConfig.html) — Whether to enable enhanced metrics of the data source Value will be ignored, if `enhancedMetricsConfig.dataSourceLevelMetricsBehavior` on AppSync GraphqlApi construct is set to `FULL_REQUEST_DATA_SOURCE_METRICS`.

  **Default:** no metrics configuration

- `name`: string — The name of the data source.

  **Default:** id of data source

## Properties

- `ds`: [CfnDataSource](/cdk/api/v2/docs/aws-cdk-lib.aws_appsync.CfnDataSource.html) — the underlying CFN data source resource.

- `name`: string — the name of the data source.

- `node`: [Node](/cdk/api/v2/docs/constructs.Node.html) — The tree node.

## Methods

- `createFunction(id: string, props: BaseAppsyncFunctionProps): AppsyncFunction` — creates a new appsync function for this datasource and API using the given properties.

- `createResolver(id: string, props: BaseResolverProps): Resolver` — creates a new resolver for this datasource and API using the given properties.

- `isConstruct(x: any): boolean` (static) — Checks if `x` is a construct.

  Use this method instead of `instanceof` to properly detect `Construct`
  instances, even when the construct library is symlinked.

  Explanation: in JavaScript, multiple copies of the `constructs` library on
  disk are seen as independent, completely different libraries. As a
  consequence, the class `Construct` in each copy of the `constructs` library
  is seen as a different class, and an instance of one class will not test as
  `instanceof` the other class. `npm install` will not create installations
  like this, but users may manually symlink construct libraries together or
  use a monorepo tool: in those cases, multiple copies of the `constructs`
  library can be accidentally installed, and `instanceof` will behave
  unpredictably. It is safest to avoid using `instanceof`, and using
  this type-testing method instead.

  **Parameters**

  - `x` — Any object.

  **Returns:** true if `x` is an object created from a class which extends `Construct`.

- `toString(): string` — Returns a string representation of this construct.

- `with(...mixins: IMixin[]): IConstruct` — Applies one or more mixins to this construct.

  Mixins are applied in order. The list of constructs is captured at the
  start of the call, so constructs added by a mixin will not be visited.
  Use multiple `with()` calls if subsequent mixins should apply to added
  constructs.

  **Parameters**

  - `mixins` — The mixins to apply.

  **Returns:** This construct for chaining
