Skip to content

Conversation

@dgandhi62
Copy link
Contributor

This PR adds support for migrating GraphQL Lambda resolvers (functions with @function directives) from Amplify Gen 1 to Gen 2. Previously, the migration tool only handled schema, table mappings, and auth modes but ignored Lambda function resolvers entirely.

Example

Gen 1 GraphQL Schema:

type Query {
  customResolver: String @function(name: "myCustomFunction")
  calculator: Int @function(name: "mathFunction")
}

type Todo @model {
  id: ID!
  title: String!
}

Gen2 GraphQL Schema

import { defineData } from '@aws-amplify/backend';
import { myCustomFunction } from './myCustomFunction/resource';
import { mathFunction } from './mathFunction/resource';

const schema = `
  type Query {
    customResolver: String @function(name: "myCustomFunction")
    calculator: Int @function(name: "mathFunction")
  }
  
  type Todo @model {
    id: ID!
    title: String!
  }
`;

export const data = defineData({
  schema,
  functions: {
    myCustomFunction: myCustomFunction,
    mathFunction: mathFunction
  }
});

- Add AdditionalAuthProvider interface for AppSync auth configurations
- Fetch additional auth providers from AWS console via AppSync API
- Generate CDK escape hatches for additionalAuthenticationProviders
- Integrate auth provider migration into data definition pipeline
- Support API_KEY, AWS_IAM, OPENID_CONNECT, COGNITO_USER_POOLS, AWS_LAMBDA auth types
- Add extractFunctions method to DataDefinitionFetcher to scan @function directives
- Add functions property support in data generator with TypeScript AST generation
- Generate proper imports and function mappings for Gen2 defineData()
- Support flexible @function directive parsing with various spacing/quote styles
- Validate function existence in amplify-meta.json before migration
@dgandhi62 dgandhi62 requested a review from a team as a code owner December 10, 2025 20:04
- Add @function directive detection in DataDefinitionFetcher
- Generate function references in defineData() configuration
- Extend AppFunctionsDefinitionFetcher to detect resolver functions
- Map resolver functions to 'api' category for proper generation
- Reuse shared getSchema() method to eliminate code duplication

Enables complete Gen1→Gen2 migration of GraphQL Lambda resolvers including
data resource references, function resource generation, and source code
migration.
@@ -1,10 +1,14 @@
import assert from 'node:assert';
import path from 'node:path';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused import path.
@@ -1,10 +1,14 @@
import assert from 'node:assert';
import path from 'node:path';
import fs from 'node:fs/promises';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused import fs.
import assert from 'node:assert';
import path from 'node:path';
import fs from 'node:fs/promises';
import glob from 'glob';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused import glob.
import { GetFunctionCommand, GetPolicyCommand, LambdaClient } from '@aws-sdk/client-lambda';
import { DescribeRuleCommand, CloudWatchEventsClient } from '@aws-sdk/client-cloudwatch-events';
import { StateManager } from '@aws-amplify/amplify-cli-core';
import { StateManager, pathManager } from '@aws-amplify/amplify-cli-core';

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused import pathManager.
@iliapolo iliapolo marked this pull request as draft December 12, 2025 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant