

기계 번역으로 제공되는 번역입니다. 제공된 번역과 원본 영어의 내용이 상충하는 경우에는 영어 버전이 우선합니다.

# 해석기
<a name="sam-property-graphqlapi-resolver"></a>

GraphQL API의 필드에 대한 해석기를 구성합니다. AWS Serverless Application Model (AWS SAM)는 [JavaScript 파이프라인 해석기를](https://docs.aws.amazon.com/appsync/latest/devguide/resolver-reference-overview-js.html) 지원합니다.

## 구문
<a name="sam-property-graphqlapi-resolver-syntax"></a>

 AWS Serverless Application Model (AWS SAM) 템플릿에서이 개체를 선언하려면 다음 구문을 사용합니다.

### YAML
<a name="sam-property-graphqlapi-resolver-syntax-yaml"></a>

```
OperationType:
  LogicalId:
    Caching: [CachingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-resolver-cachingconfig.html)
    CodeUri: String
    FieldName: String
    InlineCode: String 
    MaxBatchSize: Integer
    Pipeline: List
    Runtime: Runtime
    Sync: [SyncConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-resolver-syncconfig.html)
```

## 속성
<a name="sam-property-graphqlapi-resolver-properties"></a>

`Caching`  <a name="sam-graphqlapi-resolver-caching"></a>
캐싱이 활성화된 해석기에 대한 캐싱 구성입니다.  
*Type*: [CachingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-resolver-cachingconfig.html)  
*필수 항목 여부*: 아니요  
*CloudFormation 호환성*:이 속성은 `AWS::AppSync::Resolver` 리소스의 `[CachingConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-resolver.html#cfn-appsync-resolver-cachingconfig)` 속성으로 직접 전달됩니다.

`CodeUri`  <a name="sam-graphqlapi-resolver-codeuri"></a>
해석기 함수 코드의 Amazon Simple Storage Service(S3) URI 또는 로컬 폴더 경로.  
로컬 폴더의 경로를 지정하는 경우 배포 전에 파일을 먼저 Amazon S3에 업로드해야 CloudFormation 합니다. AWS SAMCLI를 사용하여 이 프로세스를 용이하게 할 수 있습니다. 자세한 내용은 [가 배포 시 로컬 파일을 AWS SAM 업로드하는 방법](deploy-upload-local-files.md) 단원을 참조하십시오.  
`CodeUri` 또는이 제공되지 않은 경우 `InlineCode`는 요청을 첫 번째 파이프라인 함수로 `InlineCode`리디렉션하고 마지막 파이프라인 함수로부터 응답을 수신하는를 AWS SAM 생성합니다.  
*유형*: 문자열  
*필수 항목 여부*: 아니요  
*CloudFormation 호환성*:이 속성은 `AWS::AppSync::Resolver` 리소스의 `[CodeS3Location](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-resolver.html#cfn-appsync-resolver-codes3location)` 속성으로 직접 전달됩니다.

`FieldName`  <a name="sam-graphqlapi-resolver-fieldname"></a>
해석기의 이름. 이 속성을 지정하여 `LogicalId` 값을 재정의합니다.  
*유형*: 문자열  
*필수 항목 여부*: 아니요  
*CloudFormation 호환성*:이 속성은 `AWS::AppSync::Resolver` 리소스의 `[FieldName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-resolver.html#cfn-appsync-resolver-fieldname)` 속성으로 직접 전달됩니다.

`InlineCode`  <a name="sam-graphqlapi-resolver-inlinecode"></a>
요청 및 응답 함수가 포함된 해석기 코드입니다.  
`CodeUri` 또는이 제공되지 않은 경우 `InlineCode`는 요청을 첫 번째 파이프라인 함수로 `InlineCode`리디렉션하고 마지막 파이프라인 함수로부터 응답을 수신하는를 AWS SAM 생성합니다.  
*유형*: 문자열  
*필수 항목 여부*: 아니요  
*CloudFormation 호환성*:이 속성은 `AWS::AppSync::Resolver` 리소스의 `[Code](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-resolver.html#cfn-appsync-resolver-code)` 속성으로 직접 전달됩니다.

`LogicalId`  <a name="sam-graphqlapi-resolver-logicalid"></a>
해석기의 고유 이름입니다. GraphQL 스키마에서 해석기 이름은 사용된 필드 이름과 일치해야 합니다. `LogicalId`에 같은 필드 이름을 사용합니다.  
*유형*: 문자열  
*필수 항목 여부:* 예  
*CloudFormation 호환성*:이 속성은에 고유 AWS SAM 하며 CloudFormation 동등한 속성이 없습니다.

`MaxBatchSize`  <a name="sam-graphqlapi-resolver-maxbatchsize"></a>
`BatchInvoke` 작업에서 단일 AWS Lambda 함수에 보낼 최대 해석기 요청 입력 수입니다.  
*유형*: 정수  
*필수 항목 여부*: 아니요  
*CloudFormation 호환성*:이 속성은 `AWS::AppSync::Resolver` 리소스의 `[MaxBatchSize](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-resolver.html#cfn-appsync-resolver-maxbatchsize)` 속성으로 직접 전달됩니다.

`OperationType`  <a name="sam-graphqlapi-resolver-operationtype"></a>
해석기와 관련된 GraphQL 작업 유형입니다. 예: `Query`, `Mutation` 또는 `Subscription`. 단일 `OperationType` 내에 `LogicalId`으로 여러 개의 해석기를 중첩할 수 있습니다.  
*유형*: 문자열  
*필수 항목 여부:* 예  
*CloudFormation 호환성*:이 속성은 `AWS::AppSync::Resolver` 리소스의 `[TypeName](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-resolver.html#cfn-appsync-resolver-typename)` 속성으로 직접 전달됩니다.

`Pipeline`  <a name="sam-graphqlapi-resolver-pipeline"></a>
파이프라인 해석기와 연결된 함수. 목록에서 논리적 ID로 함수를 지정합니다.  
*유형*: 목록  
*필수 항목 여부*: 예  
*CloudFormation 호환성*:이 속성은에 고유 AWS SAM 하며 CloudFormation 동등한 속성이 없습니다. 이것은 `[PipelineConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-resolver.html#cfn-appsync-resolver-pipelineconfig)` 리소스의 `AWS::AppSync::Resolver` 속성과 유사합니다.

`Runtime`  <a name="sam-graphqlapi-resolver-runtime"></a>
파이프라인 해석기 또는 함수의 런타임 사용할 런타임의 이름과 버전을 지정합니다.  
*유형*: [런타임](sam-property-graphqlapi-resolver-runtime.md)  
*필수 항목 여부:* 예  
*CloudFormation 호환성*:이 속성은에 고유 AWS SAM 하며 CloudFormation 동등한 속성이 없습니다. 이것은 `[Runtime](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-resolver.html#cfn-appsync-resolver-runtime)` 리소스의 `AWS::AppSync::Resolver` 속성과 유사합니다.

`Sync`  <a name="sam-graphqlapi-resolver-sync"></a>
해석기에 대한 동기화 구성에 대해 설명합니다.  
해석기가 호출될 때 사용할 충돌 감지 전략과 해결 전략을 지정합니다.  
*유형*: [SyncConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-resolver-syncconfig.html)  
*필수 항목 여부*: 아니요  
*CloudFormation 호환성*:이 속성은 `AWS::AppSync::Resolver` 리소스의 `[SyncConfig](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-appsync-resolver.html#cfn-appsync-resolver-syncconfig)` 속성으로 직접 전달됩니다.

## 예제
<a name="sam-property-graphqlapi-resolver-examples"></a>

### AWS SAM 생성된 해석기 함수 코드를 사용하고 필드를 변수로 저장
<a name="sam-property-graphqlapi-resolver-examples-example1"></a>

예제의 GraphQL 스키마는 다음과 같습니다.

```
schema {
  query: Query
  mutation: Mutation
}

type Query {
  getPost(id: ID!): Post
}

type Mutation {
  addPost(author: String!, title: String!, content: String!): Post!
}

type Post {
  id: ID!
  author: String
  title: String
  content: String
}
```

다음은 AWS SAM 템플릿의 코드 조각입니다.

```
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
...
Resources:
  MyGraphQLApi:
    Type: AWS::Serverless::GraphQLApi
    Properties:
      ...
      Functions:
        preprocessPostItem:
          ...
        createPostItem:
          ...
      Resolvers:
        Mutation:
          addPost:
            Runtime:
              Name: APPSYNC_JS
              Version: 1.0.0
            Pipeline:
            - preprocessPostItem
            - createPostItem
```

 AWS SAM 템플릿에서는 `CodeUri` 또는를 지정하지 않습니다`InlineCode`. 배포 시는 해석기에 대해 다음과 같은 인라인 코드를 AWS SAM 자동으로 생성합니다.

```
export function request(ctx) {
  return {};
}

export function response(ctx) {
  return ctx.prev.result;
}
```

이 디폴트 해석기 코드는 요청을 첫 번째 파이프라인 함수로 리디렉션하고 마지막 파이프라인 함수로부터 응답을 받습니다.

첫 번째 파이프라인 함수에서는 제공된 `args` 필드를 사용하여 요청 객체를 파싱하고 변수를 생성할 수 있습니다. 그러면 함수 내에서 이러한 변수를 사용할 수 있습니다. 다음은 `preprocessPostItem` 함수의 예입니다.

```
import { util } from "@aws-appsync/utils";

export function request(ctx) {
  const author = ctx.args.author;
  const title = ctx.args.title;
  const content = ctx.args.content;
  
  // Use variables to process data
  
}

export function response(ctx) {
  return ctx.result;
}
```

# 런타임
<a name="sam-property-graphqlapi-resolver-runtime"></a>

파이프라인 해석기 또는 함수의 런타임 사용할 런타임의 이름과 버전을 지정합니다.

## 구문
<a name="sam-property-graphqlapi-resolver-runtime-syntax"></a>

 AWS Serverless Application Model (AWS SAM) 템플릿에서이 개체를 선언하려면 다음 구문을 사용합니다.

### YAML
<a name="sam-property-graphqlapi-resolver-runtime-syntax-yaml"></a>

```
Name: String
Version: String
```

## 속성
<a name="sam-property-graphqlapi-resolver-runtime-properties"></a>

`Name`  <a name="sam-graphqlapi-resolver-runtime-name"></a>
사용할 런타임의 이름. 현재, 유일하게 허용되는 값은 `APPSYNC_JS`입니다.  
*유형*: 문자열  
*필수 항목 여부:* 예  
*CloudFormation 호환성*:이 속성은 `AWS::AppSync::Resolver AppSyncRuntime` 객체의 `[Name](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-resolver-appsyncruntime.html#cfn-appsync-resolver-appsyncruntime-name)` 속성으로 직접 전달됩니다.

`Version`  <a name="sam-graphqlapi-resolver-runtime-version"></a>
사용할 런타임의 버전. 현재 유일하게 허용되는 버전은 `1.0.0`입니다.  
*유형*: 문자열  
*필수 항목 여부:* 예  
*CloudFormation 호환성*:이 속성은 `AWS::AppSync::Resolver AppSyncRuntime` 객체의 `[RuntimeVersion](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-appsync-resolver-appsyncruntime.html#cfn-appsync-resolver-appsyncruntime-runtimeversion)` 속성으로 직접 전달됩니다.