Socket
Book a DemoInstallSign in
Socket

@aws-amplify/graphql-generation-transformer

Package Overview
Dependencies
Maintainers
6
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-amplify/graphql-generation-transformer

Amplify GraphQL @generation transformer

1.2.4
latest
Source
npmnpm
Version published
Weekly downloads
8.4K
-24.48%
Maintainers
6
Weekly downloads
 
Created
Source

Amplify GraphQL Generation Transformer

The Amplify GraphQL Generation Transformer is a tool that enables the quick and easy creation of AI-powered Generation routes within your AWS AppSync API. This transformer can be leveraged by using the @generation directive to configure AI models and system prompts for generating content.

Installation

npm install @aws-amplify/graphql-generation-transformer

Directive Definition

The @generation directive is defined as follows:

directive @generation(aiModel: String!, systemPrompt: String!, inferenceConfiguration: GenerationInferenceConfiguration) on FIELD_DEFINITION

Features

  • AI Model Integration: Specify the AI model to be used for generation.
  • System Prompt Configuration: Define a system prompt to guide the AI's output.
  • Inference Configuration: Fine-tune generation parameters like max tokens, temperature, and top-p.
  • Integrates with @auth Directive: Supports existing auth modes like IAM, API key, and Amazon Cognito User Pools.
  • Resolver Creation: Generates resolvers with tool definitions based on the Query field's return type to interact with the specified AI model.
  • Bedrock HTTP Data Source Creation: Creates a AppSync HTTP Data Source for Bedrock to interact with the specified AI model.

Examples

Basic Usage

Scalar Type Generation

type Query {
  generateStory(topic: String!): String
    @generation(
      aiModel: "anthropic.claude-3-haiku-20240307-v1:0"
      systemPrompt: "You are a creative storyteller. Generate a short story based on the given topic."
    )
}

Complex Type Generation

type Recipe {
  name: String!
  ingredients: [String!]!
  instructions: [String!]!
  prepTime: Int!
  cookTime: Int!
  servings: Int!
  difficulty: String!
}

type Query {
  generateRecipe(cuisine: String!, dietaryRestrictions: [String]): Recipe
    @generation(
      aiModel: "anthropic.claude-3-haiku-20240307-v1:0"
      systemPrompt: "You are a professional chef specializing in creating recipes. Generate a detailed recipe based on the given cuisine and dietary restrictions."
    )
}

Advanced Configuration

type Query {
  generateCode(description: String!): String
    @generation(
      aiModel: "anthropic.claude-3-haiku-20240307-v1:0"
      systemPrompt: "You are an expert programmer. Generate code based on the given description."
      inferenceConfiguration: { maxTokens: 500, temperature: 0.7, topP: 0.9 }
    )
}

Limitations

  • The @generation directive can only be used on Query fields.
  • The AI model specified must:
    • be supported by Amazon Bedrock's /converse API
    • support tool usage
  • Some AppSync scalar types are not currently supported.

FAQs

Package last updated on 09 Jun 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.