diff --git a/packages/amplify-category-api/src/commands/api/add-graphql-datasource.js b/packages/amplify-category-api/src/commands/api/add-graphql-datasource.js index 415da07562f..957fdce03e9 100644 --- a/packages/amplify-category-api/src/commands/api/add-graphql-datasource.js +++ b/packages/amplify-category-api/src/commands/api/add-graphql-datasource.js @@ -5,7 +5,8 @@ const path = require('path'); const { RelationalDBSchemaTransformer } = require('graphql-relational-schema-transformer'); const { RelationalDBTemplateGenerator, AuroraServerlessMySQLDatabaseReader } = require('graphql-relational-schema-transformer'); const { mergeTypeDefs } = require('@graphql-tools/merge'); -const { FeatureFlags, ResourceDoesNotExistError, exitOnNextTick } = require('amplify-cli-core'); +const { ResourceDoesNotExistError, exitOnNextTick } = require('amplify-cli-core'); + const subcommand = 'add-graphql-datasource'; const categories = 'categories'; const category = 'api'; @@ -142,11 +143,7 @@ module.exports = { context[rdsResourceName] = resourceName; context[rdsDatasource] = datasource; let template = templateGenerator.createTemplate(context); - template = templateGenerator.addRelationalResolvers( - template, - resolversDir, - FeatureFlags.getBoolean('graphqltransformer.improvePluralization'), - ); + template = templateGenerator.addRelationalResolvers(template, resolversDir); const cfn = templateGenerator.printCloudformationTemplate(template); /** diff --git a/packages/amplify-cli-core/src/feature-flags/featureFlags.ts b/packages/amplify-cli-core/src/feature-flags/featureFlags.ts index 47abc0c880f..2e930666235 100644 --- a/packages/amplify-cli-core/src/feature-flags/featureFlags.ts +++ b/packages/amplify-cli-core/src/feature-flags/featureFlags.ts @@ -515,12 +515,6 @@ export class FeatureFlags { defaultValueForExistingProjects: false, defaultValueForNewProjects: true, }, - { - name: 'improvePluralization', - type: 'boolean', - defaultValueForExistingProjects: false, - defaultValueForNewProjects: true, - }, { name: 'validateTypeNameReservedWords', type: 'boolean', @@ -625,7 +619,7 @@ export class FeatureFlags { type: 'boolean', defaultValueForExistingProjects: false, defaultValueForNewProjects: true, - }, + } ]); this.registerFlag('appSync', [ diff --git a/packages/amplify-e2e-tests/src/schema-api-directives/tests/data-access-patterns.ts b/packages/amplify-e2e-tests/src/schema-api-directives/tests/data-access-patterns.ts index 5c96232ee62..2dd1fb815e0 100644 --- a/packages/amplify-e2e-tests/src/schema-api-directives/tests/data-access-patterns.ts +++ b/packages/amplify-e2e-tests/src/schema-api-directives/tests/data-access-patterns.ts @@ -368,7 +368,7 @@ export const expected_result_query6 = { export const query7 = ` ## 7. See all employees hired recently: -#Having '@key(name: "newHire", fields: ["newHire", "id"])' on the 'Employee' model allows one to query by whether an employee has been hired recently. +#Having '@key(name: "newHire", fields: ["newHire", "id"])' on the 'Employee' model allows one to query by whether an employee has been hired recently. query employeesNewHire { employeesNewHire(newHire: "true") { @@ -685,8 +685,8 @@ export const query16 = ` ## 16. Get total product inventory: #How this would be done depends on the use case. If one just wants a list of all inventories in all warehouses, one could just run a list inventories on the Inventory model: -query listInventories { - listInventories { +query listInventorys { + listInventorys { items { productID warehouseID @@ -696,7 +696,7 @@ query listInventories { }`; export const expected_result_query16 = { data: { - listInventories: { + listInventorys: { items: [ { productID: 'yeezyboost', diff --git a/packages/amplify-graphql-searchable-transformer/src/__tests__/amplify-graphql-searchable-transformer.tests.ts b/packages/amplify-graphql-searchable-transformer/src/__tests__/amplify-graphql-searchable-transformer.tests.ts index 45be2e58cf8..613c4c0ab04 100644 --- a/packages/amplify-graphql-searchable-transformer/src/__tests__/amplify-graphql-searchable-transformer.tests.ts +++ b/packages/amplify-graphql-searchable-transformer/src/__tests__/amplify-graphql-searchable-transformer.tests.ts @@ -3,17 +3,6 @@ import { SearchableModelTransformer } from '../'; import { ModelTransformer } from '@aws-amplify/graphql-model-transformer'; import { anything, countResources, expect as cdkExpect, haveResource } from '@aws-cdk/assert'; import { parse } from 'graphql'; -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; test('Test SearchableModelTransformer validation happy case', () => { const validSchema = ` @@ -26,7 +15,6 @@ test('Test SearchableModelTransformer validation happy case', () => { `; const transformer = new GraphQLTransform({ transformers: [new ModelTransformer(), new SearchableModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -45,7 +33,6 @@ test('Test SearchableModelTransformer vtl', () => { `; const transformer = new GraphQLTransform({ transformers: [new ModelTransformer(), new SearchableModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); @@ -63,7 +50,6 @@ test('Test SearchableModelTransformer with query overrides', () => { `; const transformer = new GraphQLTransform({ transformers: [new ModelTransformer(), new SearchableModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -81,7 +67,6 @@ test('Test SearchableModelTransformer with only create mutations', () => { `; const transformer = new GraphQLTransform({ transformers: [new ModelTransformer(), new SearchableModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -105,7 +90,6 @@ test('Test SearchableModelTransformer with multiple model searchable directives' `; const transformer = new GraphQLTransform({ transformers: [new ModelTransformer(), new SearchableModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -124,7 +108,6 @@ test('Test SearchableModelTransformer with sort fields', () => { `; const transformer = new GraphQLTransform({ transformers: [new ModelTransformer(), new SearchableModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -154,7 +137,6 @@ test('it generates expected resources', () => { `; const transformer = new GraphQLTransform({ transformers: [new ModelTransformer(), new SearchableModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); diff --git a/packages/amplify-graphql-searchable-transformer/src/graphql-searchable-transformer.ts b/packages/amplify-graphql-searchable-transformer/src/graphql-searchable-transformer.ts index ef36cd4827f..db39d2f9cf3 100644 --- a/packages/amplify-graphql-searchable-transformer/src/graphql-searchable-transformer.ts +++ b/packages/amplify-graphql-searchable-transformer/src/graphql-searchable-transformer.ts @@ -158,9 +158,7 @@ export class SearchableModelTransformer extends TransformerPluginBase { searchFieldNameOverride = directiveArguments.queries.search; } } - const fieldName = searchFieldNameOverride - ? searchFieldNameOverride - : graphqlName(`search${plurality(toUpper(definition.name.value), ctx.featureFlags.getBoolean('improvePluralization'))}`); + const fieldName = searchFieldNameOverride ? searchFieldNameOverride : graphqlName(`search${plurality(toUpper(definition.name.value))}`); this.searchableObjectTypeDefinitions.push({ node: definition, fieldName, diff --git a/packages/amplify-graphql-transformer-core/src/transformation/transform.ts b/packages/amplify-graphql-transformer-core/src/transformation/transform.ts index 3442ce2d12c..0bd632467b9 100644 --- a/packages/amplify-graphql-transformer-core/src/transformation/transform.ts +++ b/packages/amplify-graphql-transformer-core/src/transformation/transform.ts @@ -61,7 +61,7 @@ export interface GraphQLTransformOptions { readonly authConfig?: AppSyncAuthConfiguration; readonly buildParameters?: Record; readonly stacks?: Record; - readonly featureFlags?: FeatureFlagProvider; + readonly featuerFlags?: FeatureFlagProvider; } export type StackMapping = { [resourceId: string]: string }; export class GraphQLTransform { @@ -110,7 +110,7 @@ export class GraphQLTransform { this.seenTransformations = {}; const parsedDocument = parse(schema); this.app = new App(); - const context = new TransformerContext(this.app, parsedDocument, this.stackMappingOverrides, this.options.featureFlags); + const context = new TransformerContext(this.app, parsedDocument, this.stackMappingOverrides, this.options.featuerFlags); const validDirectiveNameMap = this.transformers.reduce( (acc: any, t: TransformerPluginProvider) => ({ ...acc, [t.directive.name.value]: true }), { diff --git a/packages/amplify-graphql-transformer-core/src/transformer-context/index.ts b/packages/amplify-graphql-transformer-core/src/transformer-context/index.ts index 002893fa58c..5a3a2ef5959 100644 --- a/packages/amplify-graphql-transformer-core/src/transformer-context/index.ts +++ b/packages/amplify-graphql-transformer-core/src/transformer-context/index.ts @@ -26,20 +26,15 @@ export class TransformerContext implements TransformerContextProvider { public readonly resourceHelper: TransformerResourceHelper; public readonly featureFlags: FeatureFlagProvider; public _api?: GraphQLAPIProvider; - constructor( - app: App, - public readonly inputDocument: DocumentNode, - stackMapping: Record, - featureFlags?: FeatureFlagProvider, - ) { + constructor(app: App, public readonly inputDocument: DocumentNode, stackMapping: Record, featuerFlags?: FeatureFlagProvider) { this.output = new TransformerOutput(inputDocument); this.resolvers = new ResolverManager(); this.dataSources = new TransformerDataSourceManager(); this.providerRegistry = new TransformerContextProviderRegistry(); - const stackManager = new StackManager(app, stackMapping); - this.stackManager = stackManager; + const stackManager = new StackManager(app, stackMapping); + this.stackManager = stackManager this.resourceHelper = new TransformerResourceHelper(stackManager); - this.featureFlags = featureFlags ?? new NoopFeatureFlagProvider(); + this.featureFlags = featuerFlags ?? new NoopFeatureFlagProvider(); } /** diff --git a/packages/amplify-provider-awscloudformation/src/graphql-transformer/transform-graphql-schema.ts b/packages/amplify-provider-awscloudformation/src/graphql-transformer/transform-graphql-schema.ts index 8b27d65556b..e9c01823397 100644 --- a/packages/amplify-provider-awscloudformation/src/graphql-transformer/transform-graphql-schema.ts +++ b/packages/amplify-provider-awscloudformation/src/graphql-transformer/transform-graphql-schema.ts @@ -414,7 +414,7 @@ async function _buildProject(opts: ProjectOptions) { authConfig: opts.authConfig, buildParameters: opts.buildParameters, stacks: opts.projectConfig.stacks || {}, - featureFlags: new AmplifyCLIFeatureFlagAdapter(), + featuerFlags: new AmplifyCLIFeatureFlagAdapter(), }); return transform.transform(userProjectConfig.schema.toString()); } diff --git a/packages/amplify-util-mock/src/__e2e__/model-auth-transformer.e2e.test.ts b/packages/amplify-util-mock/src/__e2e__/model-auth-transformer.e2e.test.ts index 4828563190e..07fad32c720 100644 --- a/packages/amplify-util-mock/src/__e2e__/model-auth-transformer.e2e.test.ts +++ b/packages/amplify-util-mock/src/__e2e__/model-auth-transformer.e2e.test.ts @@ -795,7 +795,7 @@ test(`Test getSalary w/ Admin group protection not authorized`, async () => { expect((req2.errors[0] as any).errorType).toEqual('Unauthorized'); }); -test(`Test listSalaries w/ Admin group protection authorized`, async () => { +test(`Test listSalarys w/ Admin group protection authorized`, async () => { const req = await GRAPHQL_CLIENT_1.query(` mutation { createSalary(input: { wage: 101 }) { @@ -809,7 +809,7 @@ test(`Test listSalaries w/ Admin group protection authorized`, async () => { expect(req.data.createSalary.wage).toEqual(101); const req2 = await GRAPHQL_CLIENT_1.query(` query { - listSalaries(filter: { wage: { eq: 101 }}) { + listSalarys(filter: { wage: { eq: 101 }}) { items { id wage @@ -817,12 +817,12 @@ test(`Test listSalaries w/ Admin group protection authorized`, async () => { } } `); - expect(req2.data.listSalaries.items.length).toEqual(1); - expect(req2.data.listSalaries.items[0].id).toEqual(req.data.createSalary.id); - expect(req2.data.listSalaries.items[0].wage).toEqual(101); + expect(req2.data.listSalarys.items.length).toEqual(1); + expect(req2.data.listSalarys.items[0].id).toEqual(req.data.createSalary.id); + expect(req2.data.listSalarys.items[0].wage).toEqual(101); }); -test(`Test listSalaries w/ Admin group protection not authorized`, async () => { +test(`Test listSalarys w/ Admin group protection not authorized`, async () => { const req = await GRAPHQL_CLIENT_1.query(` mutation { createSalary(input: { wage: 102 }) { @@ -836,7 +836,7 @@ test(`Test listSalaries w/ Admin group protection not authorized`, async () => { expect(req.data.createSalary.wage).toEqual(102); const req2 = await GRAPHQL_CLIENT_2.query(` query { - listSalaries(filter: { wage: { eq: 102 }}) { + listSalarys(filter: { wage: { eq: 102 }}) { items { id wage @@ -844,7 +844,7 @@ test(`Test listSalaries w/ Admin group protection not authorized`, async () => { } } `); - expect(req2.data.listSalaries.items).toEqual([]); + expect(req2.data.listSalarys.items).toEqual([]); }); /** @@ -2377,7 +2377,7 @@ test(`Test createTestIdentity as admin.`, async () => { const listResponse = await GRAPHQL_CLIENT_3.query( `query { - listTestIdentities(filter: { title: { eq: "Test title update" } }, limit: 100) { + listTestIdentitys(filter: { title: { eq: "Test title update" } }, limit: 100) { items { id title @@ -2387,7 +2387,7 @@ test(`Test createTestIdentity as admin.`, async () => { }`, {}, ); - const relevantPost = listResponse.data.listTestIdentities.items.find(p => p.id === getReq.data.getTestIdentity.id); + const relevantPost = listResponse.data.listTestIdentitys.items.find(p => p.id === getReq.data.getTestIdentity.id); logDebug(JSON.stringify(listResponse, null, 4)); expect(relevantPost).toBeTruthy(); expect(relevantPost.title).toEqual('Test title update'); diff --git a/packages/graphql-auth-transformer/src/ModelAuthTransformer.ts b/packages/graphql-auth-transformer/src/ModelAuthTransformer.ts index 920b858e08a..7ac88f2106d 100644 --- a/packages/graphql-auth-transformer/src/ModelAuthTransformer.ts +++ b/packages/graphql-auth-transformer/src/ModelAuthTransformer.ts @@ -368,7 +368,7 @@ export class ModelAuthTransformer extends Transformer { this.propagateAuthDirectivesToNestedTypes(def, rules, ctx); // Retrieve the configuration options for the related @model directive - const modelConfiguration = new ModelDirectiveConfiguration(modelDirective, def, ctx.featureFlags.getBoolean('improvePluralization')); + const modelConfiguration = new ModelDirectiveConfiguration(modelDirective, def); // Get the directives we need to add to the GraphQL nodes const directives = this.getDirectivesForRules(rules, rules.length === 0 ? this.shouldAddDefaultAuthDirective() : false); @@ -516,11 +516,7 @@ Static group authorization should perform as expected.`, const isDeleteRule = isOpRule('delete'); // Retrieve the configuration options for the related @model directive - const modelConfiguration = new ModelDirectiveConfiguration( - modelDirective, - parent, - ctx.featureFlags.getBoolean('improvePluralization'), - ); + const modelConfiguration = new ModelDirectiveConfiguration(modelDirective, parent); // The field handler adds the read rule on the object const readRules = rules.filter((rule: AuthRule) => isReadRule(rule)); this.protectReadForField(ctx, parent, definition, readRules, modelConfiguration); diff --git a/packages/graphql-auth-transformer/src/ModelDirectiveConfiguration.ts b/packages/graphql-auth-transformer/src/ModelDirectiveConfiguration.ts index 44b11846f52..744718a7f52 100644 --- a/packages/graphql-auth-transformer/src/ModelDirectiveConfiguration.ts +++ b/packages/graphql-auth-transformer/src/ModelDirectiveConfiguration.ts @@ -41,14 +41,12 @@ type ModelDirectiveOperation = { export class ModelDirectiveConfiguration { map: Map = new Map(); - constructor(directive: DirectiveNode, def: ObjectTypeDefinitionNode, improvePluralization: boolean) { + constructor(directive: DirectiveNode, def: ObjectTypeDefinitionNode) { const typeName = def.name.value; const directiveArguments: ModelDirectiveArgs = getDirectiveArguments(directive); const makeName = (operation: ModelDirectiveOperationType, nameOverride?: string, isList: boolean = false) => - nameOverride - ? nameOverride - : graphqlName(operation + (isList ? plurality(toUpper(typeName), improvePluralization) : toUpper(typeName))); + nameOverride ? nameOverride : graphqlName(operation + (isList ? plurality(toUpper(typeName)) : toUpper(typeName))); let shouldHaveCreate = true; let shouldHaveUpdate = true; diff --git a/packages/graphql-auth-transformer/src/__tests__/AmplifyAdminAuth.test.ts b/packages/graphql-auth-transformer/src/__tests__/AmplifyAdminAuth.test.ts index a5e3bf380d7..e4ab14130b1 100644 --- a/packages/graphql-auth-transformer/src/__tests__/AmplifyAdminAuth.test.ts +++ b/packages/graphql-auth-transformer/src/__tests__/AmplifyAdminAuth.test.ts @@ -1,18 +1,8 @@ import { GraphQLTransform } from 'graphql-transformer-core'; +import { ResourceConstants } from 'graphql-transformer-common'; import { DynamoDBModelTransformer } from 'graphql-dynamodb-transformer'; import { ModelAuthTransformer } from '../ModelAuthTransformer'; import _ from 'lodash'; -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; test('Test simple model with public auth rule and amplify admin app is present', () => { const validSchema = ` @@ -24,7 +14,6 @@ test('Test simple model with public auth rule and amplify admin app is present', } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ @@ -57,7 +46,6 @@ test('Test simple model with public auth rule and amplify admin app is not enabl } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ @@ -86,7 +74,6 @@ test('Test simple model with private auth rule and amplify admin app is present' } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ @@ -119,7 +106,6 @@ test('Test simple model with private auth rule and amplify admin app not enabled } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ @@ -152,7 +138,6 @@ test('Test model with public auth rule without all operations and amplify admin } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ @@ -197,7 +182,6 @@ test('Test simple model with private auth rule, few operations, and amplify admi } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ @@ -241,7 +225,6 @@ test('Test simple model with private IAM auth rule, few operations, and amplify } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ @@ -280,7 +263,6 @@ test('Test simple model with AdminUI enabled should add IAM policy only for fiel } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ diff --git a/packages/graphql-auth-transformer/src/__tests__/GroupAuthTransformer.test.ts b/packages/graphql-auth-transformer/src/__tests__/GroupAuthTransformer.test.ts index d184c517fd3..a1cd98a8a01 100644 --- a/packages/graphql-auth-transformer/src/__tests__/GroupAuthTransformer.test.ts +++ b/packages/graphql-auth-transformer/src/__tests__/GroupAuthTransformer.test.ts @@ -2,17 +2,6 @@ import { GraphQLTransform } from 'graphql-transformer-core'; import { ResourceConstants } from 'graphql-transformer-common'; import { DynamoDBModelTransformer } from 'graphql-dynamodb-transformer'; import { ModelAuthTransformer } from '../ModelAuthTransformer'; -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; test('Test ModelAuthTransformer validation happy case w/ static groups', () => { const validSchema = ` @@ -24,7 +13,6 @@ test('Test ModelAuthTransformer validation happy case w/ static groups', () => { } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ @@ -40,7 +28,7 @@ test('Test ModelAuthTransformer validation happy case w/ static groups', () => { const out = transformer.transform(validSchema); expect(out).toBeDefined(); expect(out.rootStack.Resources[ResourceConstants.RESOURCES.GraphQLAPILogicalID].Properties.AuthenticationType).toEqual( - 'AMAZON_COGNITO_USER_POOLS', + 'AMAZON_COGNITO_USER_POOLS' ); }); @@ -55,7 +43,6 @@ test('Test ModelAuthTransformer validation happy case w/ dynamic groups', () => } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ @@ -71,7 +58,7 @@ test('Test ModelAuthTransformer validation happy case w/ dynamic groups', () => const out = transformer.transform(validSchema); expect(out).toBeDefined(); expect(out.rootStack.Resources[ResourceConstants.RESOURCES.GraphQLAPILogicalID].Properties.AuthenticationType).toEqual( - 'AMAZON_COGNITO_USER_POOLS', + 'AMAZON_COGNITO_USER_POOLS' ); }); @@ -86,7 +73,6 @@ test('Test ModelAuthTransformer validation happy case w/ dynamic group', () => { } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ @@ -102,7 +88,7 @@ test('Test ModelAuthTransformer validation happy case w/ dynamic group', () => { const out = transformer.transform(validSchema); expect(out).toBeDefined(); expect(out.rootStack.Resources[ResourceConstants.RESOURCES.GraphQLAPILogicalID].Properties.AuthenticationType).toEqual( - 'AMAZON_COGNITO_USER_POOLS', + 'AMAZON_COGNITO_USER_POOLS' ); }); @@ -118,7 +104,6 @@ test('Test ModelAuthTransformer validation @auth on non @model. Should fail.', ( } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ diff --git a/packages/graphql-auth-transformer/src/__tests__/MultiAuth.test.ts b/packages/graphql-auth-transformer/src/__tests__/MultiAuth.test.ts index 63e097c1f52..4287ce66c12 100644 --- a/packages/graphql-auth-transformer/src/__tests__/MultiAuth.test.ts +++ b/packages/graphql-auth-transformer/src/__tests__/MultiAuth.test.ts @@ -4,17 +4,6 @@ import { DynamoDBModelTransformer } from 'graphql-dynamodb-transformer'; import { ModelConnectionTransformer } from 'graphql-connection-transformer'; import { ModelAuthTransformer, AppSyncAuthConfiguration, AppSyncAuthMode } from '../ModelAuthTransformer'; import { KeyTransformer } from '../../../graphql-key-transformer/src/KeyTransformer'; -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; const noAuthModeDefaultConfig: AppSyncAuthConfiguration = { defaultAuthentication: { @@ -191,7 +180,6 @@ const getRecursiveSchemaWithDiffModesOnParentType = (authDir1: string, authDir2: const getTransformer = (authConfig: AppSyncAuthConfiguration) => new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new KeyTransformer(), @@ -742,7 +730,7 @@ describe('Type directive transformation tests', () => { @auth(rules: [ { allow: private, provider: iam, operations: [read] }, { allow: groups, groups: ["Group"], operations: [read, update, delete] } - ]) + ]) @key(name: "byUser", fields: ["postUserId"]) { id: ID! @@ -780,7 +768,7 @@ describe('Type directive transformation tests', () => { title: String! editors: [PostEditor] @connection(keyName: "byPost", fields: ["id"]) } - + # Create a join model and disable queries as you don't need them # and can query through Post.editors and User.posts type PostEditor @@ -794,7 +782,7 @@ describe('Type directive transformation tests', () => { post: Post! @connection(fields: ["postID"]) editor: User! @connection(fields: ["editorID"]) } - + type User @model @auth(rules: [{ allow: owner }]) { id: ID! username: String! diff --git a/packages/graphql-auth-transformer/src/__tests__/NonModelAuthTransformer.test.ts b/packages/graphql-auth-transformer/src/__tests__/NonModelAuthTransformer.test.ts index f3702bb5dfc..8b523ebc4a4 100644 --- a/packages/graphql-auth-transformer/src/__tests__/NonModelAuthTransformer.test.ts +++ b/packages/graphql-auth-transformer/src/__tests__/NonModelAuthTransformer.test.ts @@ -3,17 +3,6 @@ import { DynamoDBModelTransformer } from 'graphql-dynamodb-transformer'; import { FunctionTransformer } from 'graphql-function-transformer'; import { ModelAuthTransformer } from '../ModelAuthTransformer'; import { ObjectTypeDefinitionNode, DocumentNode, Kind, parse } from 'graphql'; -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; describe('@auth directive without @model', async () => { const getObjectType = (doc: DocumentNode, type: string): ObjectTypeDefinitionNode | undefined => { @@ -47,7 +36,6 @@ describe('@auth directive without @model', async () => { `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ @@ -82,7 +70,6 @@ describe('@auth directive without @model', async () => { `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ @@ -117,7 +104,6 @@ operations will be generated by the CLI.`); `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ @@ -151,7 +137,6 @@ are already on an operation already.`); `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ @@ -189,7 +174,6 @@ are already on an operation already.`); `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ @@ -228,7 +212,6 @@ are already on an operation already.`); `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ @@ -268,7 +251,6 @@ are already on an operation already.`); `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new FunctionTransformer(), @@ -307,7 +289,6 @@ are already on an operation already.`); `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new FunctionTransformer(), diff --git a/packages/graphql-auth-transformer/src/__tests__/OperationsArgument.test.ts b/packages/graphql-auth-transformer/src/__tests__/OperationsArgument.test.ts index d0fbf598632..a50edbac8ee 100644 --- a/packages/graphql-auth-transformer/src/__tests__/OperationsArgument.test.ts +++ b/packages/graphql-auth-transformer/src/__tests__/OperationsArgument.test.ts @@ -2,17 +2,6 @@ import { GraphQLTransform } from 'graphql-transformer-core'; import { ResourceConstants } from 'graphql-transformer-common'; import { DynamoDBModelTransformer } from 'graphql-dynamodb-transformer'; import { ModelAuthTransformer } from '../ModelAuthTransformer'; -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; test('Test "read" auth operation', () => { const validSchema = ` @@ -24,7 +13,6 @@ test('Test "read" auth operation', () => { } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ @@ -56,7 +44,6 @@ test('Test "create", "update", "delete" auth operations', () => { } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ @@ -96,7 +83,6 @@ test('Test that operation overwrites queries in auth operations', () => { } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ @@ -138,7 +124,6 @@ test('Test that checks subscription resolvers are generated with auth logic', () } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ @@ -179,7 +164,6 @@ test('Test that checks subscription resolvers are created without auth logic', ( } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ @@ -223,7 +207,6 @@ test('Test that subscriptions are only generated if the respective mutation oper } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ diff --git a/packages/graphql-auth-transformer/src/__tests__/OwnerAuthTransformer.test.ts b/packages/graphql-auth-transformer/src/__tests__/OwnerAuthTransformer.test.ts index a0314833991..62caf321a08 100644 --- a/packages/graphql-auth-transformer/src/__tests__/OwnerAuthTransformer.test.ts +++ b/packages/graphql-auth-transformer/src/__tests__/OwnerAuthTransformer.test.ts @@ -1,20 +1,9 @@ -import { parse } from 'graphql'; +import { parse, DefinitionNode, InputObjectTypeDefinitionNode } from 'graphql'; import { FeatureFlagProvider, GraphQLTransform } from 'graphql-transformer-core'; import { ResourceConstants } from 'graphql-transformer-common'; import { DynamoDBModelTransformer } from 'graphql-dynamodb-transformer'; import { ModelAuthTransformer } from '../ModelAuthTransformer'; import { getObjectType, getField } from './test-helpers'; -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; test('Test ModelAuthTransformer validation happy case', () => { const validSchema = ` @@ -26,7 +15,6 @@ test('Test ModelAuthTransformer validation happy case', () => { } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ @@ -58,7 +46,6 @@ test('Test OwnerField with Subscriptions', () => { postOwner: String }`; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ @@ -115,9 +102,6 @@ describe('add missing implicit owner fields to type', () => { if (name === 'addMissingOwnerFields') { return true; } - if (name === 'improvePluralization') { - return true; - } }), getNumber: jest.fn(), getObject: jest.fn(), diff --git a/packages/graphql-auth-transformer/src/__tests__/PerFieldAuthArgument.test.ts b/packages/graphql-auth-transformer/src/__tests__/PerFieldAuthArgument.test.ts index aae4910f688..6a5237b6df5 100644 --- a/packages/graphql-auth-transformer/src/__tests__/PerFieldAuthArgument.test.ts +++ b/packages/graphql-auth-transformer/src/__tests__/PerFieldAuthArgument.test.ts @@ -4,17 +4,7 @@ import { DynamoDBModelTransformer } from 'graphql-dynamodb-transformer'; import { ModelConnectionTransformer } from 'graphql-connection-transformer'; import { KeyTransformer } from 'graphql-key-transformer'; import { ModelAuthTransformer } from '../ModelAuthTransformer'; -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; + test('Test that subscriptions are only generated if the respective mutation operation exists', () => { const validSchema = ` type Salary @@ -29,7 +19,6 @@ test('Test that subscriptions are only generated if the respective mutation oper secret: String @auth(rules: [{allow: owner}]) }`; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ @@ -72,14 +61,14 @@ test('Test per-field @auth on a @connection field', () => { { id: ID! name: String! - tags: [Tag] + tags: [Tag] @connection(keyName: "byTags", fields: ["id"]) @auth(rules: [ { allow: groups, groups: ["admin"] } ]) } type Tag @model @key(name: "byTags", fields: ["postID"]) - @auth(rules: [ { allow: groups, groups: ["admin"] } ]) + @auth(rules: [ { allow: groups, groups: ["admin"] } ]) { id: ID! postID: ID! @@ -89,7 +78,6 @@ test('Test per-field @auth on a @connection field', () => { } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new KeyTransformer(), @@ -125,7 +113,6 @@ test('Test per-field @auth without model', () => { `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ diff --git a/packages/graphql-auth-transformer/src/__tests__/SearchableAuthTransformer.test.ts b/packages/graphql-auth-transformer/src/__tests__/SearchableAuthTransformer.test.ts index 20c3ffdf08d..1d911ad1240 100644 --- a/packages/graphql-auth-transformer/src/__tests__/SearchableAuthTransformer.test.ts +++ b/packages/graphql-auth-transformer/src/__tests__/SearchableAuthTransformer.test.ts @@ -2,17 +2,6 @@ import { GraphQLTransform } from 'graphql-transformer-core'; import { DynamoDBModelTransformer } from 'graphql-dynamodb-transformer'; import { ModelAuthTransformer } from '../ModelAuthTransformer'; import { SearchableModelTransformer } from 'graphql-elasticsearch-transformer'; -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; test('test auth logic is enabled on owner/static rules in resposne es resolver', () => { const validSchema = ` @@ -28,7 +17,6 @@ test('test auth logic is enabled on owner/static rules in resposne es resolver', } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new SearchableModelTransformer(), @@ -47,11 +35,11 @@ test('test auth logic is enabled on owner/static rules in resposne es resolver', // expect response resolver to contain auth logic for owner rule expect(out).toBeDefined(); expect(out.resolvers['Query.searchComments.res.vtl']).toContain( - '## Authorization rule: { allow: owner, ownerField: "owner", identityClaim: "cognito:username" } **', + '## Authorization rule: { allow: owner, ownerField: "owner", identityClaim: "cognito:username" } **' ); // expect response resolver to contain auth logic for group rule expect(out.resolvers['Query.searchComments.res.vtl']).toContain( - '## Authorization rule: { allow: groups, groups: ["writer"], groupClaim: "cognito:groups" } **', + '## Authorization rule: { allow: groups, groups: ["writer"], groupClaim: "cognito:groups" } **' ); }); @@ -69,7 +57,6 @@ test('test auth logic is enabled for iam/apiKey auth rules in response es resolv } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new SearchableModelTransformer(), diff --git a/packages/graphql-connection-transformer/src/__tests__/ModelConnectionTransformer.test.ts b/packages/graphql-connection-transformer/src/__tests__/ModelConnectionTransformer.test.ts index c4c7bef91bb..911508be9f9 100644 --- a/packages/graphql-connection-transformer/src/__tests__/ModelConnectionTransformer.test.ts +++ b/packages/graphql-connection-transformer/src/__tests__/ModelConnectionTransformer.test.ts @@ -12,17 +12,6 @@ import { GraphQLTransform, TRANSFORM_CURRENT_VERSION } from 'graphql-transformer import { ResolverResourceIDs, ModelResourceIDs, ResourceConstants } from 'graphql-transformer-common'; import { DynamoDBModelTransformer } from 'graphql-dynamodb-transformer'; import { ModelConnectionTransformer } from '../ModelConnectionTransformer'; -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; test('Test ModelConnectionTransformer simple one to many happy case', () => { const validSchema = ` @@ -38,7 +27,6 @@ test('Test ModelConnectionTransformer simple one to many happy case', () => { `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new ModelConnectionTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -79,7 +67,6 @@ test('Test ModelConnectionTransformer simple one to many happy case with custom `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new ModelConnectionTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -120,7 +107,6 @@ test('Test that ModelConnection Transformer throws error when the field in conne `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new ModelConnectionTransformer()], - featureFlags, }); try { transformer.transform(invalidSchema); @@ -149,7 +135,6 @@ test('Test ModelConnectionTransformer simple one to many happy case with custom `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new ModelConnectionTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -193,7 +178,6 @@ test('Test ModelConnectionTransformer complex one to many happy case', () => { `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new ModelConnectionTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -242,7 +226,6 @@ test('Test ModelConnectionTransformer many to many should fail', () => { `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new ModelConnectionTransformer()], - featureFlags, }); try { transformer.transform(validSchema); @@ -271,7 +254,6 @@ test('Test ModelConnectionTransformer many to many should fail due to missing ot `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new ModelConnectionTransformer()], - featureFlags, }); try { transformer.transform(validSchema); @@ -296,7 +278,6 @@ test('Test ModelConnectionTransformer many to many should fail due to missing ot `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new ModelConnectionTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -339,7 +320,6 @@ test('Test ModelConnectionTransformer with non null @connections', () => { `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new ModelConnectionTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -393,7 +373,6 @@ test('Test ModelConnectionTransformer with sortField fails if not specified in a `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new ModelConnectionTransformer()], - featureFlags, }); expect(() => { transformer.transform(validSchema); @@ -416,7 +395,6 @@ test('Test ModelConnectionTransformer with sortField creates a connection resolv `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new ModelConnectionTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -434,7 +412,6 @@ test('Test ModelConnectionTransformer with sortField creates a connection resolv test('Test ModelConnectionTransformer throws with invalid key fields', () => { const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new ModelConnectionTransformer()], - featureFlags, }); const invalidSchema = ` @@ -492,7 +469,6 @@ test('Test ModelConnectionTransformer throws with invalid key fields', () => { test('Test ModelConnectionTransformer does not throw with valid key fields', () => { const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new ModelConnectionTransformer()], - featureFlags, }); const validSchema = ` @@ -565,7 +541,6 @@ test('Test ModelConnectionTransformer sortField with missing @key should fail', const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new ModelConnectionTransformer()], - featureFlags, }); try { @@ -592,7 +567,6 @@ test('Test ModelConnectionTransformer overrides the default limit', () => { const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new ModelConnectionTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); @@ -617,7 +591,6 @@ test('Test ModelConnectionTransformer uses the default limit', () => { `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new ModelConnectionTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -644,7 +617,6 @@ test('Test ModelConnectionTransformer with keyField overrides the default limit' const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new ModelConnectionTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); @@ -669,7 +641,6 @@ test('Test ModelConnectionTransformer with keyField uses the default limit', () `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new ModelConnectionTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -696,7 +667,6 @@ test('Connection on models with no codegen includes AttributeTypeEnum', () => { const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new ModelConnectionTransformer()], - featureFlags, transformConfig: { Version: TRANSFORM_CURRENT_VERSION, }, @@ -713,13 +683,13 @@ test('Connection on models with no codegen includes custom enum filters', () => id: ID!, cartItems: [CartItem] @connection(name: "CartCartItem") } - + type CartItem @model(queries: null, mutations: null, subscriptions: null) { id: ID! productType: PRODUCT_TYPE! cart: Cart @connection(name: "CartCartItem") } - + enum PRODUCT_TYPE { UNIT PACKAGE @@ -728,7 +698,6 @@ test('Connection on models with no codegen includes custom enum filters', () => const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new ModelConnectionTransformer()], - featureFlags, transformConfig: { Version: TRANSFORM_CURRENT_VERSION, }, diff --git a/packages/graphql-connection-transformer/src/__tests__/NewConnectionTransformer.test.ts b/packages/graphql-connection-transformer/src/__tests__/NewConnectionTransformer.test.ts index bb2c42b3467..e5454fb12a4 100644 --- a/packages/graphql-connection-transformer/src/__tests__/NewConnectionTransformer.test.ts +++ b/packages/graphql-connection-transformer/src/__tests__/NewConnectionTransformer.test.ts @@ -13,17 +13,6 @@ import { ResolverResourceIDs } from 'graphql-transformer-common'; import { ModelConnectionTransformer } from '../ModelConnectionTransformer'; import { DynamoDBModelTransformer } from 'graphql-dynamodb-transformer'; import { KeyTransformer } from 'graphql-key-transformer'; -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; test('ModelConnectionTransformer should fail if connection was called on an object that is not a Model type.', () => { const validSchema = ` @@ -41,7 +30,6 @@ test('ModelConnectionTransformer should fail if connection was called on an obje const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new ModelConnectionTransformer()], - featureFlags, }); expect(() => transformer.transform(validSchema)).toThrowError(`@connection must be on an @model object type field.`); @@ -63,7 +51,6 @@ test('ModelConnectionTransformer should fail if connection was with an object th const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new ModelConnectionTransformer()], - featureFlags, }); expect(() => transformer.transform(validSchema)).toThrowError(`Object type Test1 must be annotated with @model.`); @@ -85,7 +72,6 @@ test('ModelConnectionTransformer should fail if the field type where the directi const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new ModelConnectionTransformer()], - featureFlags, }); expect(() => transformer.transform(validSchema)).toThrowError('Unknown type "Test2". Did you mean "Test" or "Test1"?'); @@ -107,7 +93,6 @@ test('ModelConnectionTransformer should fail if an empty list of fields is passe const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new ModelConnectionTransformer()], - featureFlags, }); expect(() => transformer.transform(validSchema)).toThrowError('No fields passed in to @connection directive.'); @@ -133,7 +118,6 @@ test('ModelConnectionTransformer should fail if any of the fields passed in are const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new KeyTransformer(), new ModelConnectionTransformer()], - featureFlags, }); expect(() => transformer.transform(validSchema)).toThrowError('name is not a field in Test'); @@ -159,7 +143,6 @@ test('ModelConnectionTransformer should fail if the query is not run on the defa const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new KeyTransformer(), new ModelConnectionTransformer()], - featureFlags, }); expect(() => transformer.transform(validSchema)).toThrowError( @@ -184,7 +167,6 @@ test('ModelConnectionTransformer should fail if keyName provided does not exist. const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new ModelConnectionTransformer()], - featureFlags, }); expect(() => transformer.transform(validSchema)).toThrowError('Key notDefault does not exist for model Test1'); @@ -207,7 +189,6 @@ test('ModelConnectionTransformer should fail if first field does not match PK of const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new ModelConnectionTransformer()], - featureFlags, }); expect(() => transformer.transform(validSchema)).toThrowError('email field is not of type ID'); @@ -233,7 +214,6 @@ test('ModelConnectionTransformer should fail if sort key type passed in does not const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new KeyTransformer(), new ModelConnectionTransformer()], - featureFlags, }); expect(() => transformer.transform(validSchema)).toThrowError('email field is not of type ID'); @@ -259,7 +239,6 @@ test('ModelConnectionTransformer should fail if partial sort key is passed in co const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new KeyTransformer(), new ModelConnectionTransformer()], - featureFlags, }); expect(() => transformer.transform(validSchema)).toThrowError( @@ -287,7 +266,6 @@ test('ModelConnectionTransformer should accept connection without sort key', () const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new KeyTransformer(), new ModelConnectionTransformer()], - featureFlags, }); expect(() => transformer.transform(validSchema)).not.toThrowError(); @@ -313,7 +291,6 @@ test('ModelConnectionTransformer should fail if sort key type passed in does not const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new KeyTransformer(), new ModelConnectionTransformer()], - featureFlags, }); expect(() => transformer.transform(validSchema)).toThrowError('email field is not of type ID'); @@ -339,7 +316,6 @@ test('ModelConnectionTransformer should fail if partition key type passed in doe const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new KeyTransformer(), new ModelConnectionTransformer()], - featureFlags, }); expect(() => transformer.transform(validSchema)).toThrowError('email field is not of type ID'); @@ -365,7 +341,6 @@ test('Test ModelConnectionTransformer for One-to-One getItem case.', () => { const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new KeyTransformer(), new ModelConnectionTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); @@ -399,7 +374,6 @@ test('Test ModelConnectionTransformer for One-to-Many query case.', () => { const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new KeyTransformer(), new ModelConnectionTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); @@ -437,7 +411,6 @@ test('Test ModelConnectionTransformer for bidirectional One-to-Many query case.' const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new KeyTransformer(), new ModelConnectionTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); @@ -484,7 +457,6 @@ test('Test ModelConnectionTransformer for One-to-Many query with a composite sor const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new KeyTransformer(), new ModelConnectionTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); @@ -524,7 +496,6 @@ test('Test ModelConnectionTransformer for One-to-Many query with a composite sor const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new KeyTransformer(), new ModelConnectionTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); @@ -565,7 +536,6 @@ test('Test ModelConnectionTransformer for One-to-One getItem with composite sort const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new KeyTransformer(), new ModelConnectionTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); @@ -609,7 +579,6 @@ test('Many-to-many without conflict resolution generates correct schema', () => const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new KeyTransformer(), new ModelConnectionTransformer()], - featureFlags, transformConfig: { Version: TRANSFORM_CURRENT_VERSION, }, @@ -650,7 +619,6 @@ test('Many-to-many with conflict resolution generates correct schema', () => { const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new KeyTransformer(), new ModelConnectionTransformer()], - featureFlags, transformConfig: { Version: TRANSFORM_CURRENT_VERSION, ResolverConfig: { diff --git a/packages/graphql-dynamodb-transformer/src/DynamoDBModelTransformer.ts b/packages/graphql-dynamodb-transformer/src/DynamoDBModelTransformer.ts index 3fec283f317..6a886cbf7fa 100644 --- a/packages/graphql-dynamodb-transformer/src/DynamoDBModelTransformer.ts +++ b/packages/graphql-dynamodb-transformer/src/DynamoDBModelTransformer.ts @@ -494,13 +494,7 @@ export class DynamoDBModelTransformer extends Transformer { this.generateModelXConnectionType(ctx, def); // Create the list resolver - const listResolver = this.resources.makeListResolver( - def.name.value, - ctx.featureFlags.getBoolean('improvePluralization'), - listFieldNameOverride, - isSyncEnabled, - ctx.getQueryTypeName(), - ); + const listResolver = this.resources.makeListResolver(def.name.value, listFieldNameOverride, isSyncEnabled, ctx.getQueryTypeName()); const resourceId = ResolverResourceIDs.DynamoDBListResolverResourceID(typeName); ctx.setResource(resourceId, listResolver); ctx.mapResourceToStack(typeName, resourceId); diff --git a/packages/graphql-dynamodb-transformer/src/__tests__/DynamoDBModelTransformer.test.ts b/packages/graphql-dynamodb-transformer/src/__tests__/DynamoDBModelTransformer.test.ts index 57b829288ca..b0c8026424f 100644 --- a/packages/graphql-dynamodb-transformer/src/__tests__/DynamoDBModelTransformer.test.ts +++ b/packages/graphql-dynamodb-transformer/src/__tests__/DynamoDBModelTransformer.test.ts @@ -14,20 +14,6 @@ import { import { FeatureFlagProvider, GraphQLTransform, TRANSFORM_BASE_VERSION, TRANSFORM_CURRENT_VERSION } from 'graphql-transformer-core'; import { DynamoDBModelTransformer } from '../DynamoDBModelTransformer'; import { getBaseType } from 'graphql-transformer-common'; -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - if (name === 'validateTypeNameReservedWords') { - return false; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; test('Test DynamoDBModelTransformer validation happy case', () => { const validSchema = ` @@ -40,7 +26,6 @@ test('Test DynamoDBModelTransformer validation happy case', () => { `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -56,7 +41,6 @@ test('Test DynamoDBModelTransformer with query overrides', () => { `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -91,7 +75,6 @@ test('Test DynamoDBModelTransformer with mutation overrides', () => { `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -113,7 +96,6 @@ test('Test DynamoDBModelTransformer with only create mutations', () => { `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -142,7 +124,6 @@ test('Test DynamoDBModelTransformer with multiple model directives', () => { `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -189,7 +170,6 @@ test('Test DynamoDBModelTransformer with filter', () => { }`; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -222,7 +202,6 @@ test('Test DynamoDBModelTransformer with mutations set to null', () => { `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -242,7 +221,6 @@ test('Test DynamoDBModelTransformer with queries set to null', () => { `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -264,7 +242,6 @@ test('Test DynamoDBModelTransformer with subscriptions set to null', () => { `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -288,7 +265,6 @@ test('Test DynamoDBModelTransformer with queries and mutations set to null', () `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -316,7 +292,6 @@ test('Test DynamoDBModelTransformer with advanced subscriptions', () => { `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -362,7 +337,6 @@ test('Test DynamoDBModelTransformer with non-model types and enums', () => { `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -411,7 +385,6 @@ test('Test DynamoDBModelTransformer with mutation input overrides when mutations `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -446,7 +419,6 @@ test('Test DynamoDBModelTransformer with mutation input overrides when mutations `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -474,7 +446,6 @@ test('Test non model objects contain id as a type for fields', () => { `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -499,7 +470,6 @@ test('Test schema includes attribute enum when only queries specified', () => { `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer()], - featureFlags, transformConfig: { Version: 5, }, @@ -519,7 +489,6 @@ test('Test only get does not generate superfluous input and filter types', () => `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer()], - featureFlags, transformConfig: { Version: 5, }, @@ -539,7 +508,6 @@ test('Test timestamp parameters when generating resolvers and output schema', () `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer()], - featureFlags, }); const result = transformer.transform(validSchema); expect(result).toBeDefined(); @@ -561,7 +529,6 @@ test('Test resolver template not to auto generate createdAt and updatedAt when t `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer()], - featureFlags, }); const result = transformer.transform(validSchema); expect(result).toBeDefined(); @@ -583,7 +550,6 @@ test('Test create and update mutation input should have timestamps as nullable f `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer()], - featureFlags, }); const result = transformer.transform(validSchema); expect(result).toBeDefined(); @@ -603,7 +569,6 @@ test('Test not to include createdAt and updatedAt field when timestamps is set t `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer()], - featureFlags, }); const result = transformer.transform(validSchema); expect(result).toBeDefined(); @@ -637,7 +602,6 @@ test('DynamoDB transformer should add default primary key when not defined', () `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer()], - featureFlags, }); const result = transformer.transform(validSchema); expect(result).toBeDefined(); @@ -663,7 +627,6 @@ test('DynamoDB transformer should not add default primary key when ID is defined `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer()], - featureFlags, }); const result = transformer.transform(validSchema); expect(result).toBeDefined(); @@ -714,7 +677,6 @@ test('Schema should compile successfully when subscription is missing from schem `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -757,7 +719,6 @@ function transformerVersionSnapshot(version: number): string { `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer()], - featureFlags, transformConfig: { Version: version, }, diff --git a/packages/graphql-dynamodb-transformer/src/__tests__/__snapshots__/DynamoDBModelTransformer.test.ts.snap b/packages/graphql-dynamodb-transformer/src/__tests__/__snapshots__/DynamoDBModelTransformer.test.ts.snap index cc9aa4d15d3..90ce484f6b1 100644 --- a/packages/graphql-dynamodb-transformer/src/__tests__/__snapshots__/DynamoDBModelTransformer.test.ts.snap +++ b/packages/graphql-dynamodb-transformer/src/__tests__/__snapshots__/DynamoDBModelTransformer.test.ts.snap @@ -1264,7 +1264,7 @@ enum ModelAttributeTypes { type Query { getEntity(id: ID!): Entity - listEntities(filter: ModelEntityFilterInput, limit: Int, nextToken: String): ModelEntityConnection + listEntitys(filter: ModelEntityFilterInput, limit: Int, nextToken: String): ModelEntityConnection } " `; diff --git a/packages/graphql-dynamodb-transformer/src/resources.ts b/packages/graphql-dynamodb-transformer/src/resources.ts index 35322e35a0f..cf5af051f5f 100644 --- a/packages/graphql-dynamodb-transformer/src/resources.ts +++ b/packages/graphql-dynamodb-transformer/src/resources.ts @@ -685,14 +685,8 @@ export class ResourceFactory { * TODO: actually fill out the right filter expression. This is a placeholder only. * @param type */ - public makeListResolver( - type: string, - improvePluralization: boolean, - nameOverride?: string, - isSyncEnabled: boolean = false, - queryTypeName: string = 'Query', - ) { - const fieldName = nameOverride ? nameOverride : graphqlName('list' + plurality(toUpper(type), improvePluralization)); + public makeListResolver(type: string, nameOverride?: string, isSyncEnabled: boolean = false, queryTypeName: string = 'Query') { + const fieldName = nameOverride ? nameOverride : graphqlName('list' + plurality(toUpper(type))); const requestVariable = 'ListRequest'; return new AppSync.Resolver({ ApiId: Fn.GetAtt(ResourceConstants.RESOURCES.GraphQLAPILogicalID, 'ApiId'), diff --git a/packages/graphql-elasticsearch-transformer/src/SearchableModelTransformer.ts b/packages/graphql-elasticsearch-transformer/src/SearchableModelTransformer.ts index 48746de2b74..8ab736b93b0 100644 --- a/packages/graphql-elasticsearch-transformer/src/SearchableModelTransformer.ts +++ b/packages/graphql-elasticsearch-transformer/src/SearchableModelTransformer.ts @@ -125,7 +125,6 @@ export class SearchableModelTransformer extends Transformer { nonKeywordFields, primaryKey, ctx.getQueryTypeName(), - ctx.featureFlags.getBoolean('improvePluralization'), searchFieldNameOverride, ctx.isProjectUsingDataStore(), ); diff --git a/packages/graphql-elasticsearch-transformer/src/__tests__/SearchableModelTransformer.test.ts b/packages/graphql-elasticsearch-transformer/src/__tests__/SearchableModelTransformer.test.ts index 7a47b2a2bd9..b32dac3d7da 100644 --- a/packages/graphql-elasticsearch-transformer/src/__tests__/SearchableModelTransformer.test.ts +++ b/packages/graphql-elasticsearch-transformer/src/__tests__/SearchableModelTransformer.test.ts @@ -1,17 +1,6 @@ import { GraphQLTransform, TRANSFORM_CURRENT_VERSION, ConflictHandlerType } from 'graphql-transformer-core'; import { DynamoDBModelTransformer } from 'graphql-dynamodb-transformer'; import { SearchableModelTransformer } from '../SearchableModelTransformer'; -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; test('Test SearchableModelTransformer validation happy case', () => { const validSchema = ` @@ -24,7 +13,6 @@ test('Test SearchableModelTransformer validation happy case', () => { `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new SearchableModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -42,7 +30,6 @@ test('Test SearchableModelTransformer with query overrides', () => { `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new SearchableModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -60,7 +47,6 @@ test('Test SearchableModelTransformer with only create mutations', () => { `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new SearchableModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -84,7 +70,6 @@ test('Test SearchableModelTransformer with multiple model searchable directives' `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new SearchableModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -103,7 +88,6 @@ test('Test SearchableModelTransformer with sort fields', () => { `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new SearchableModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -124,7 +108,6 @@ test('SearchableModelTransformer with external versioning', () => { const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new SearchableModelTransformer()], - featureFlags, transformConfig: { Version: TRANSFORM_CURRENT_VERSION, ResolverConfig: { diff --git a/packages/graphql-elasticsearch-transformer/src/resources.ts b/packages/graphql-elasticsearch-transformer/src/resources.ts index 65c081d5153..c7dd78ac2e4 100644 --- a/packages/graphql-elasticsearch-transformer/src/resources.ts +++ b/packages/graphql-elasticsearch-transformer/src/resources.ts @@ -437,11 +437,10 @@ export class ResourceFactory { nonKeywordFields: Expression[], primaryKey: string, queryTypeName: string, - improvePluralization: boolean, nameOverride?: string, includeVersion: boolean = false, ) { - const fieldName = nameOverride ? nameOverride : graphqlName('search' + plurality(toUpper(type), improvePluralization)); + const fieldName = nameOverride ? nameOverride : graphqlName('search' + plurality(toUpper(type))); return new AppSync.Resolver({ ApiId: Fn.GetAtt(ResourceConstants.RESOURCES.GraphQLAPILogicalID, 'ApiId'), DataSourceName: Fn.GetAtt(ResourceConstants.RESOURCES.ElasticsearchDataSourceLogicalID, 'Name'), diff --git a/packages/graphql-key-transformer/src/__tests__/KeyTransformer.test.ts b/packages/graphql-key-transformer/src/__tests__/KeyTransformer.test.ts index 3102d6983dd..7463cf71a42 100644 --- a/packages/graphql-key-transformer/src/__tests__/KeyTransformer.test.ts +++ b/packages/graphql-key-transformer/src/__tests__/KeyTransformer.test.ts @@ -2,20 +2,6 @@ import { parse, InputObjectTypeDefinitionNode, DefinitionNode, DocumentNode, Kin import { GraphQLTransform, InvalidDirectiveError, SyncConfig, ConflictHandlerType, FeatureFlagProvider } from 'graphql-transformer-core'; import { KeyTransformer } from '../KeyTransformer'; import { DynamoDBModelTransformer } from 'graphql-dynamodb-transformer'; -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - if (name === 'skipOverrideMutationInputTypes') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; test('Check KeyTransformer Resolver Code', () => { const validSchema = ` @@ -34,7 +20,6 @@ test('Check KeyTransformer Resolver Code', () => { }`; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new KeyTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -50,7 +35,6 @@ test('KeyTransformer should fail if more than 1 @key is provided without a name. const transformer = new GraphQLTransform({ transformers: [new KeyTransformer()], - featureFlags, }); expect(() => transformer.transform(invalidSchema)).toThrowError(InvalidDirectiveError); @@ -66,7 +50,6 @@ test('KeyTransformer should fail if more than 1 @key is provided with the same n const transformer = new GraphQLTransform({ transformers: [new KeyTransformer()], - featureFlags, }); expect(() => transformer.transform(invalidSchema)).toThrowError(InvalidDirectiveError); @@ -82,7 +65,6 @@ test('KeyTransformer should fail if referencing a field that does not exist.', ( const transformer = new GraphQLTransform({ transformers: [new KeyTransformer()], - featureFlags, }); expect(() => transformer.transform(invalidSchema)).toThrowError(InvalidDirectiveError); @@ -98,7 +80,6 @@ test('Test that a primary @key fails if pointing to nullable fields.', () => { const transformer = new GraphQLTransform({ transformers: [new KeyTransformer()], - featureFlags, }); expect(() => transformer.transform(invalidSchema)).toThrowError(InvalidDirectiveError); @@ -114,7 +95,6 @@ test('Test that model with an LSI but no primary sort key will fail.', () => { const transformer = new GraphQLTransform({ transformers: [new KeyTransformer()], - featureFlags, }); expect(() => transformer.transform(invalidSchema)).toThrowError(InvalidDirectiveError); }); @@ -129,7 +109,6 @@ test('KeyTransformer should fail if a non-existing type field is defined as key const transformer = new GraphQLTransform({ transformers: [new KeyTransformer()], - featureFlags, }); expect(() => transformer.transform(invalidSchema)).toThrowError(InvalidDirectiveError); @@ -149,7 +128,6 @@ test('Check sortDirection validation code present in list resolver code for simp const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new KeyTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -171,7 +149,6 @@ test('Check sortDirection validation code present in list resolver code for comp const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new KeyTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -190,7 +167,6 @@ test('KeyTransformer should remove default primary key when primary key overidde const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new KeyTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -213,7 +189,6 @@ test('KeyTransformer should not remove default primary key when primary key not `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new KeyTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -248,7 +223,6 @@ test('Check KeyTransformer Resolver Code when sync enabled', () => { }; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new KeyTransformer()], - featureFlags, transformConfig: { ResolverConfig: { project: config, @@ -275,7 +249,6 @@ test('Test that sort direction and filter input are generated if default list qu }`; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new KeyTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -313,7 +286,6 @@ test('GSI composite sort keys are wrapped in conditional to check presence in mu `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new KeyTransformer()], - featureFlags, }); const result = transformer.transform(validSchema); @@ -328,6 +300,20 @@ function getInputType(doc: DocumentNode, type: string): InputObjectTypeDefinitio } describe('check schema input', () => { + let ff: FeatureFlagProvider; + beforeEach(() => { + ff = { + getBoolean: jest.fn().mockImplementation((name, defaultValue) => { + if (name === 'skipOverrideMutationInputTypes') { + return true; + } + }), + getNumber: jest.fn(), + getObject: jest.fn(), + getString: jest.fn(), + }; + }); + it('@model mutation with user defined null args ', () => { const validSchema = /* GraphQL */ ` type Call @@ -353,7 +339,7 @@ describe('check schema input', () => { `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new KeyTransformer()], - featureFlags, + featureFlags: ff, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -390,7 +376,7 @@ describe('check schema input', () => { `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new KeyTransformer()], - featureFlags, + featureFlags: ff, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -425,7 +411,7 @@ describe('check schema input', () => { `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new KeyTransformer()], - featureFlags, + featureFlags: ff, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -471,7 +457,7 @@ describe('check schema input', () => { `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new KeyTransformer()], - featureFlags, + featureFlags: ff, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); @@ -520,7 +506,7 @@ describe('check schema input', () => { `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new KeyTransformer()], - featureFlags, + featureFlags: ff, }); const out = transformer.transform(validSchema); expect(out).toBeDefined(); diff --git a/packages/graphql-relational-schema-transformer/src/RelationalDBResolverGenerator.ts b/packages/graphql-relational-schema-transformer/src/RelationalDBResolverGenerator.ts index 77c0eb57671..d233db1d528 100644 --- a/packages/graphql-relational-schema-transformer/src/RelationalDBResolverGenerator.ts +++ b/packages/graphql-relational-schema-transformer/src/RelationalDBResolverGenerator.ts @@ -43,7 +43,7 @@ export class RelationalDBResolverGenerator { * Creates the CRUDL+Q Resolvers as a Map of Cloudform Resources. The output can then be * merged with an existing Template's map of Resources. */ - public createRelationalResolvers(resolverFilePath: string, improvePluralization: boolean) { + public createRelationalResolvers(resolverFilePath: string) { let resources = {}; this.resolverFilePath = resolverFilePath; this.typePrimaryKeyMap.forEach((value: string, key: string) => { @@ -54,7 +54,7 @@ export class RelationalDBResolverGenerator { ...{ [resourceName + 'GetResolver']: this.makeGetRelationalResolver(key) }, ...{ [resourceName + 'UpdateResolver']: this.makeUpdateRelationalResolver(key) }, ...{ [resourceName + 'DeleteResolver']: this.makeDeleteRelationalResolver(key) }, - ...{ [resourceName + 'ListResolver']: this.makeListRelationalResolver(key, improvePluralization) }, + ...{ [resourceName + 'ListResolver']: this.makeListRelationalResolver(key) }, }; // TODO: Add Guesstimate Query Resolvers }); @@ -306,8 +306,8 @@ export class RelationalDBResolverGenerator { * @param type - the graphql type for which the list resolver will be created * @param queryTypeName - will be 'Query' */ - private makeListRelationalResolver(type: string, improvePluralization: boolean, queryTypeName: string = 'Query') { - const fieldName = graphqlName(GRAPHQL_RESOLVER_OPERATION.List + plurality(toUpper(type), improvePluralization)); + private makeListRelationalResolver(type: string, queryTypeName: string = 'Query') { + const fieldName = graphqlName(GRAPHQL_RESOLVER_OPERATION.List + plurality(toUpper(type))); const selectSql = this.generateSelectStatement(type); const reqFileName = `${queryTypeName}.${fieldName}.req.vtl`; const resFileName = `${queryTypeName}.${fieldName}.res.vtl`; diff --git a/packages/graphql-relational-schema-transformer/src/RelationalDBTemplateGenerator.ts b/packages/graphql-relational-schema-transformer/src/RelationalDBTemplateGenerator.ts index bdff2625e80..8074ad90342 100644 --- a/packages/graphql-relational-schema-transformer/src/RelationalDBTemplateGenerator.ts +++ b/packages/graphql-relational-schema-transformer/src/RelationalDBTemplateGenerator.ts @@ -47,9 +47,9 @@ export class RelationalDBTemplateGenerator { * @param template - the Cloudform template * @returns the given template, updated with new resolvers. */ - public addRelationalResolvers(template: Template, resolverFilePath: string, improvePluralization: boolean): Template { + public addRelationalResolvers(template: Template, resolverFilePath: string): Template { let resolverGenerator = new RelationalDBResolverGenerator(this.context); - template.Resources = { ...template.Resources, ...resolverGenerator.createRelationalResolvers(resolverFilePath, improvePluralization) }; + template.Resources = { ...template.Resources, ...resolverGenerator.createRelationalResolvers(resolverFilePath) }; return template; } diff --git a/packages/graphql-relational-schema-transformer/src/__tests__/RelationalDBResolverGenerator.test.ts b/packages/graphql-relational-schema-transformer/src/__tests__/RelationalDBResolverGenerator.test.ts index 41ff1cf57fe..ed9e58961ca 100644 --- a/packages/graphql-relational-schema-transformer/src/__tests__/RelationalDBResolverGenerator.test.ts +++ b/packages/graphql-relational-schema-transformer/src/__tests__/RelationalDBResolverGenerator.test.ts @@ -1,4 +1,6 @@ import * as fs from 'fs-extra'; + +import { JSONMappingParameters } from 'cloudform-types/types/kinesisAnalyticsV2/applicationReferenceDataSource'; import { RelationalDBResolverGenerator } from '../RelationalDBResolverGenerator'; import { TemplateContext } from '../RelationalDBSchemaTransformer'; import { parse } from 'graphql'; @@ -6,7 +8,7 @@ import { parse } from 'graphql'; jest.mock('fs-extra', () => ({ writeFileSync: jest.fn(), })); -const writeFileSync_mock = fs.writeFileSync as jest.MockedFunction; + afterEach(() => jest.clearAllMocks()); /** @@ -39,7 +41,7 @@ test('Test Basic CRUDL Resolver Generation', () => { const generator = new RelationalDBResolverGenerator(context); // TEST - const resources: { [key: string]: any } = generator.createRelationalResolvers('someFilePath', true); + const resources: { [key: string]: any } = generator.createRelationalResolvers('someFilePath'); // VERIFY expect(resources).toBeDefined(); @@ -77,9 +79,9 @@ test('verify generated templates', () => { simplePrimaryKeyTypeMap.set('Tomatoes', 'String'); const context = new TemplateContext(schema, simplePrimaryKeyMap, simpleStringFieldMap, simpleIntFieldMap, simplePrimaryKeyTypeMap); const generator = new RelationalDBResolverGenerator(context); - generator.createRelationalResolvers('testFilePath', true); - expect(writeFileSync_mock.mock.calls.length).toBe(10); - writeFileSync_mock.mock.calls.forEach(call => { + generator.createRelationalResolvers('testFilePath'); + expect(fs.writeFileSync.mock.calls.length).toBe(10); + fs.writeFileSync.mock.calls.forEach(call => { expect(call.length).toBe(3); expect(call[0]).toMatchSnapshot(); expect(call[1]).toMatchSnapshot(); @@ -104,36 +106,9 @@ test('verify generated templates using a Int primary key', () => { simplePrimaryKeyTypeMap.set('Apples', 'Int'); const context = new TemplateContext(schema, simplePrimaryKeyMap, simpleStringFieldMap, simpleIntFieldMap, simplePrimaryKeyTypeMap); const generator = new RelationalDBResolverGenerator(context); - generator.createRelationalResolvers('testFilePath', true); - expect(writeFileSync_mock.mock.calls.length).toBe(10); - writeFileSync_mock.mock.calls.forEach(call => { - expect(call.length).toBe(3); - expect(call[0]).toMatchSnapshot(); - expect(call[1]).toMatchSnapshot(); - expect(call[2]).toBe('utf8'); - }); -}); - -test('verify generated templates with old pluralization', () => { - // SETUP - const schema = parse(` - type Apples { - id: Int - name: String - } - `); - let simpleStringFieldMap = new Map(); - let simpleIntFieldMap = new Map(); - let simplePrimaryKeyMap = new Map(); - let simplePrimaryKeyTypeMap = new Map(); - - simplePrimaryKeyMap.set('Apples', 'Id'); - simplePrimaryKeyTypeMap.set('Apples', 'Int'); - const context = new TemplateContext(schema, simplePrimaryKeyMap, simpleStringFieldMap, simpleIntFieldMap, simplePrimaryKeyTypeMap); - const generator = new RelationalDBResolverGenerator(context); - generator.createRelationalResolvers('testFilePath', false); - expect(writeFileSync_mock.mock.calls.length).toBe(10); - writeFileSync_mock.mock.calls.forEach(call => { + generator.createRelationalResolvers('testFilePath'); + expect(fs.writeFileSync.mock.calls.length).toBe(10); + fs.writeFileSync.mock.calls.forEach(call => { expect(call.length).toBe(3); expect(call[0]).toMatchSnapshot(); expect(call[1]).toMatchSnapshot(); diff --git a/packages/graphql-relational-schema-transformer/src/__tests__/RelationalDBTemplateGenerator.test.ts b/packages/graphql-relational-schema-transformer/src/__tests__/RelationalDBTemplateGenerator.test.ts index aac31eb06a1..242050ec6d3 100644 --- a/packages/graphql-relational-schema-transformer/src/__tests__/RelationalDBTemplateGenerator.test.ts +++ b/packages/graphql-relational-schema-transformer/src/__tests__/RelationalDBTemplateGenerator.test.ts @@ -67,7 +67,7 @@ test('Test Adding Resolvers to CloudForm Template', () => { expect(baseTemplate.Resources).toBeDefined(); expect(baseTemplate.Resources).not.toHaveProperty(''); - const finalTemplate = templateGenerator.addRelationalResolvers(baseTemplate, 'someFilePath', true); + const finalTemplate = templateGenerator.addRelationalResolvers(baseTemplate, 'someFilePath'); expect(finalTemplate).toBeDefined(); }); diff --git a/packages/graphql-relational-schema-transformer/src/__tests__/__snapshots__/RelationalDBResolverGenerator.test.ts.snap b/packages/graphql-relational-schema-transformer/src/__tests__/__snapshots__/RelationalDBResolverGenerator.test.ts.snap index 56f2eef59b9..83c0937907e 100644 --- a/packages/graphql-relational-schema-transformer/src/__tests__/__snapshots__/RelationalDBResolverGenerator.test.ts.snap +++ b/packages/graphql-relational-schema-transformer/src/__tests__/__snapshots__/RelationalDBResolverGenerator.test.ts.snap @@ -95,7 +95,7 @@ exports[`verify generated templates 16`] = ` $utils.toJson($output[0])" `; -exports[`verify generated templates 17`] = `"testFilePath/Query.listTomatoes.req.vtl"`; +exports[`verify generated templates 17`] = `"testFilePath/Query.listTomatoess.req.vtl"`; exports[`verify generated templates 18`] = ` "{ @@ -104,7 +104,7 @@ exports[`verify generated templates 18`] = ` }" `; -exports[`verify generated templates 19`] = `"testFilePath/Query.listTomatoes.res.vtl"`; +exports[`verify generated templates 19`] = `"testFilePath/Query.listTomatoess.res.vtl"`; exports[`verify generated templates 20`] = `"$utils.toJson($utils.rds.toJsonObject($ctx.result)[0])"`; @@ -203,7 +203,7 @@ exports[`verify generated templates using a Int primary key 16`] = ` $utils.toJson($output[0])" `; -exports[`verify generated templates using a Int primary key 17`] = `"testFilePath/Query.listApples.req.vtl"`; +exports[`verify generated templates using a Int primary key 17`] = `"testFilePath/Query.listAppless.req.vtl"`; exports[`verify generated templates using a Int primary key 18`] = ` "{ @@ -212,114 +212,6 @@ exports[`verify generated templates using a Int primary key 18`] = ` }" `; -exports[`verify generated templates using a Int primary key 19`] = `"testFilePath/Query.listApples.res.vtl"`; +exports[`verify generated templates using a Int primary key 19`] = `"testFilePath/Query.listAppless.res.vtl"`; exports[`verify generated templates using a Int primary key 20`] = `"$utils.toJson($utils.rds.toJsonObject($ctx.result)[0])"`; - -exports[`verify generated templates with old pluralization 1`] = `"testFilePath/Mutation.createApples.req.vtl"`; - -exports[`verify generated templates with old pluralization 2`] = ` -"#set( $cols = [] ) -#set( $vals = [] ) -#foreach( $entry in $ctx.args.createApplesInput.keySet() ) - #set( $discard = $cols.add($entry) ) - #set( $discard = $vals.add(\\"'$ctx.args.createApplesInput[$entry]'\\") ) -#end -#set( $valStr = $vals.toString().replace(\\"[\\",\\"(\\").replace(\\"]\\",\\")\\") ) -#set( $colStr = $cols.toString().replace(\\"[\\",\\"(\\").replace(\\"]\\",\\")\\") ) -{ - \\"version\\": \\"2018-05-29\\", - \\"statements\\": [\\"INSERT INTO Apples $colStr VALUES $valStr\\", \\"SELECT * FROM Apples WHERE Id=$ctx.args.createApplesInput.Id\\"] -}" -`; - -exports[`verify generated templates with old pluralization 3`] = `"testFilePath/Mutation.createApples.res.vtl"`; - -exports[`verify generated templates with old pluralization 4`] = `"$utils.toJson($utils.parseJson($utils.rds.toJsonString($ctx.result))[1][0])"`; - -exports[`verify generated templates with old pluralization 5`] = `"testFilePath/Query.getApples.req.vtl"`; - -exports[`verify generated templates with old pluralization 6`] = ` -"{ - \\"version\\": \\"2018-05-29\\", - \\"statements\\": [\\"SELECT * FROM Apples WHERE Id=$ctx.args.Id\\"] -}" -`; - -exports[`verify generated templates with old pluralization 7`] = `"testFilePath/Query.getApples.res.vtl"`; - -exports[`verify generated templates with old pluralization 8`] = ` -"#set( $output = $utils.rds.toJsonObject($ctx.result) ) -#if( $output.isEmpty() ) - $util.error(\\"Invalid response from RDS DataSource. See info for the full response.\\", \\"InvalidResponse\\", {}, $output) -#end -#set( $output = $output[0] ) -#if( $output.isEmpty() ) - #return -#end -$utils.toJson($output[0])" -`; - -exports[`verify generated templates with old pluralization 9`] = `"testFilePath/Mutation.updateApples.req.vtl"`; - -exports[`verify generated templates with old pluralization 10`] = ` -"#set( $updateList = {} ) -#foreach( $entry in $ctx.args.updateApplesInput.keySet() ) - #set( $discard = $updateList.put($entry, \\"'$ctx.args.updateApplesInput[$entry]'\\") ) -#end -#set( $update = $updateList.toString().replace(\\"{\\",\\"\\").replace(\\"}\\",\\"\\") ) -{ - \\"version\\": \\"2018-05-29\\", - \\"statements\\": [\\"UPDATE Apples SET $update WHERE Id=$ctx.args.updateApplesInput.Id}\\", \\"SELECT * FROM Apples WHERE Id=$ctx.args.updateApplesInput.Id\\"] -}" -`; - -exports[`verify generated templates with old pluralization 11`] = `"testFilePath/Mutation.updateApples.res.vtl"`; - -exports[`verify generated templates with old pluralization 12`] = ` -"#set( $output = $utils.rds.toJsonObject($ctx.result) ) -#if( $output.length() < 2 ) - $util.error(\\"Invalid response from RDS DataSource. See info for the full response.\\", \\"InvalidResponse\\", {}, $output) -#end -#set( $output = $output[1] ) -#if( $output.isEmpty() ) - #return -#end -$utils.toJson($output[0])" -`; - -exports[`verify generated templates with old pluralization 13`] = `"testFilePath/Mutation.deleteApples.req.vtl"`; - -exports[`verify generated templates with old pluralization 14`] = ` -"{ - \\"version\\": \\"2018-05-29\\", - \\"statements\\": [\\"SELECT * FROM Apples WHERE Id=$ctx.args.Id\\", \\"DELETE FROM Apples WHERE Id=$ctx.args.Id\\"] -}" -`; - -exports[`verify generated templates with old pluralization 15`] = `"testFilePath/Mutation.deleteApples.res.vtl"`; - -exports[`verify generated templates with old pluralization 16`] = ` -"#set( $output = $utils.rds.toJsonObject($ctx.result) ) -#if( $output.isEmpty() ) - $util.error(\\"Invalid response from RDS DataSource. See info for the full response.\\", \\"InvalidResponse\\", {}, $output) -#end -#set( $output = $output[0] ) -#if( $output.isEmpty() ) - #return -#end -$utils.toJson($output[0])" -`; - -exports[`verify generated templates with old pluralization 17`] = `"testFilePath/Query.listAppless.req.vtl"`; - -exports[`verify generated templates with old pluralization 18`] = ` -"{ - \\"version\\": \\"2018-05-29\\", - \\"statements\\": [\\"SELECT * FROM Apples\\"] -}" -`; - -exports[`verify generated templates with old pluralization 19`] = `"testFilePath/Query.listAppless.res.vtl"`; - -exports[`verify generated templates with old pluralization 20`] = `"$utils.toJson($utils.rds.toJsonObject($ctx.result)[0])"`; diff --git a/packages/graphql-transformer-common/package.json b/packages/graphql-transformer-common/package.json index 32c109ce574..445cb556867 100644 --- a/packages/graphql-transformer-common/package.json +++ b/packages/graphql-transformer-common/package.json @@ -25,8 +25,7 @@ "dependencies": { "graphql": "^14.5.8", "graphql-mapping-template": "4.18.1", - "md5": "^2.2.1", - "pluralize": "8.0.0" + "md5": "^2.2.1" }, "devDependencies": { "@types/md5": "^2.1.33", diff --git a/packages/graphql-transformer-common/src/util.ts b/packages/graphql-transformer-common/src/util.ts index 9e7c8a347c2..cca2086ee79 100644 --- a/packages/graphql-transformer-common/src/util.ts +++ b/packages/graphql-transformer-common/src/util.ts @@ -1,14 +1,9 @@ import md5 from 'md5'; -import pluralize from 'pluralize'; -export function plurality(val: string, improvePluralization: boolean): string { + +export function plurality(val: string): string { if (!val.trim()) { return ''; } - - if (improvePluralization) { - return pluralize(val); - } - return val.concat('s'); } diff --git a/packages/graphql-transformers-e2e-tests/src/__tests__/ConnectionsWithAuthTests.e2e.test.ts b/packages/graphql-transformers-e2e-tests/src/__tests__/ConnectionsWithAuthTests.e2e.test.ts index 2af1b3b923e..d3ed116439d 100644 --- a/packages/graphql-transformers-e2e-tests/src/__tests__/ConnectionsWithAuthTests.e2e.test.ts +++ b/packages/graphql-transformers-e2e-tests/src/__tests__/ConnectionsWithAuthTests.e2e.test.ts @@ -29,17 +29,6 @@ import 'isomorphic-fetch'; jest.setTimeout(2000000); const cf = new CloudFormationClient('us-west-2'); -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; const BUILD_TIMESTAMP = moment().format('YYYYMMDDHHmmss'); const STACK_NAME = `ConnectionsWithAuthTests-${BUILD_TIMESTAMP}`; @@ -159,7 +148,6 @@ beforeAll(async () => { } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelConnectionTransformer(), diff --git a/packages/graphql-transformers-e2e-tests/src/__tests__/CustomRoots.e2e.test.ts b/packages/graphql-transformers-e2e-tests/src/__tests__/CustomRoots.e2e.test.ts index 9c1b075b99a..e522e4553ab 100644 --- a/packages/graphql-transformers-e2e-tests/src/__tests__/CustomRoots.e2e.test.ts +++ b/packages/graphql-transformers-e2e-tests/src/__tests__/CustomRoots.e2e.test.ts @@ -14,17 +14,6 @@ import fs = require('fs'); import path = require('path'); jest.setTimeout(2000000); -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; test('Test custom root types with additional fields.', () => { const validSchema = ` @@ -43,7 +32,6 @@ test('Test custom root types with additional fields.', () => { } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [new DynamoDBModelTransformer()], }); const out = transformer.transform(validSchema); @@ -87,7 +75,6 @@ test('Test custom root query, mutation, and subscriptions.', () => { } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [new DynamoDBModelTransformer()], }); const out = transformer.transform(validSchema); @@ -128,7 +115,6 @@ test('Test custom roots without any directives. This should still be valid.', () } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [new DynamoDBModelTransformer()], }); const out = transformer.transform(validSchema); diff --git a/packages/graphql-transformers-e2e-tests/src/__tests__/DynamoDBModelTransformer.e2e.test.ts b/packages/graphql-transformers-e2e-tests/src/__tests__/DynamoDBModelTransformer.e2e.test.ts index 48fa21cd15c..2bbb1e1281f 100644 --- a/packages/graphql-transformers-e2e-tests/src/__tests__/DynamoDBModelTransformer.e2e.test.ts +++ b/packages/graphql-transformers-e2e-tests/src/__tests__/DynamoDBModelTransformer.e2e.test.ts @@ -15,17 +15,7 @@ jest.setTimeout(2000000); const cf = new CloudFormationClient('us-west-2'); const customS3Client = new S3Client('us-west-2'); const awsS3Client = new S3({ region: 'us-west-2' }); -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; + const BUILD_TIMESTAMP = moment().format('YYYYMMDDHHmmss'); const STACK_NAME = `DynamoDBModelTransformerTest-${BUILD_TIMESTAMP}`; const BUCKET_NAME = `appsync-model-transformer-test-bucket-${BUILD_TIMESTAMP}`; @@ -91,7 +81,6 @@ beforeAll(async () => { } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ diff --git a/packages/graphql-transformers-e2e-tests/src/__tests__/FunctionTransformerTests.e2e.test.ts b/packages/graphql-transformers-e2e-tests/src/__tests__/FunctionTransformerTests.e2e.test.ts index d58119e700c..b3025ebc023 100644 --- a/packages/graphql-transformers-e2e-tests/src/__tests__/FunctionTransformerTests.e2e.test.ts +++ b/packages/graphql-transformers-e2e-tests/src/__tests__/FunctionTransformerTests.e2e.test.ts @@ -18,17 +18,7 @@ jest.setTimeout(2000000); const cf = new CloudFormationClient('us-west-2'); const customS3Client = new S3Client('us-west-2'); const awsS3Client = new S3({ region: 'us-west-2' }); -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; + const BUILD_TIMESTAMP = moment().format('YYYYMMDDHHmmss'); const STACK_NAME = `FunctionTransformerTests-${BUILD_TIMESTAMP}`; const BUCKET_NAME = `appsync-function-transformer-test-bucket-${BUILD_TIMESTAMP}`; @@ -96,7 +86,6 @@ beforeAll(async () => { expect(true).toEqual(false); } const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new FunctionTransformer(), diff --git a/packages/graphql-transformers-e2e-tests/src/__tests__/HttpTransformer.e2e.test.ts b/packages/graphql-transformers-e2e-tests/src/__tests__/HttpTransformer.e2e.test.ts index dde1076aa1f..4e6fe72cee7 100644 --- a/packages/graphql-transformers-e2e-tests/src/__tests__/HttpTransformer.e2e.test.ts +++ b/packages/graphql-transformers-e2e-tests/src/__tests__/HttpTransformer.e2e.test.ts @@ -17,17 +17,7 @@ jest.setTimeout(2000000); const cf = new CloudFormationClient('us-west-2'); const customS3Client = new S3Client('us-west-2'); const awsS3Client = new S3({ region: 'us-west-2' }); -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; + const BUILD_TIMESTAMP = moment().format('YYYYMMDDHHmmss'); const STACK_NAME = `HttpTransformerTest-${BUILD_TIMESTAMP}`; const BUCKET_NAME = `appsync-http-transformer-test-bucket-${BUILD_TIMESTAMP}`; @@ -99,7 +89,6 @@ beforeAll(async () => { } const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ diff --git a/packages/graphql-transformers-e2e-tests/src/__tests__/KeyTransformer.e2e.test.ts b/packages/graphql-transformers-e2e-tests/src/__tests__/KeyTransformer.e2e.test.ts index bf29dbd3d49..75dfdec8da4 100644 --- a/packages/graphql-transformers-e2e-tests/src/__tests__/KeyTransformer.e2e.test.ts +++ b/packages/graphql-transformers-e2e-tests/src/__tests__/KeyTransformer.e2e.test.ts @@ -16,17 +16,7 @@ jest.setTimeout(2000000); const cf = new CloudFormationClient('us-west-2'); const customS3Client = new S3Client('us-west-2'); const awsS3Client = new S3({ region: 'us-west-2' }); -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; + const BUILD_TIMESTAMP = moment().format('YYYYMMDDHHmmss'); const STACK_NAME = `KeyTransformerTests-${BUILD_TIMESTAMP}`; const BUCKET_NAME = `appsync-key-transformer-test-bucket-${BUILD_TIMESTAMP}`; @@ -105,7 +95,6 @@ beforeAll(async () => { console.warn(`Could not create bucket: ${e}`); } const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new KeyTransformer(), diff --git a/packages/graphql-transformers-e2e-tests/src/__tests__/KeyTransformerLocal.e2e.test.ts b/packages/graphql-transformers-e2e-tests/src/__tests__/KeyTransformerLocal.e2e.test.ts index 32c8d630c5b..f1bf02a3f6e 100644 --- a/packages/graphql-transformers-e2e-tests/src/__tests__/KeyTransformerLocal.e2e.test.ts +++ b/packages/graphql-transformers-e2e-tests/src/__tests__/KeyTransformerLocal.e2e.test.ts @@ -10,17 +10,7 @@ import { expectNullableInputValues, expectInputValueToHandle, } from '../testUtil'; -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; + test('Test that a primary @key with a single field changes the hash key.', () => { const validSchema = ` type Test @model @key(fields: ["email"]) { @@ -29,7 +19,6 @@ test('Test that a primary @key with a single field changes the hash key.', () => `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [new DynamoDBModelTransformer(), new KeyTransformer()], }); @@ -55,7 +44,6 @@ test('Test that a primary @key with 2 fields changes the hash and sort key.', () `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [new DynamoDBModelTransformer(), new KeyTransformer()], }); @@ -89,7 +77,6 @@ test('Test that a primary @key with id as hashKey does not have it required in c `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [new DynamoDBModelTransformer(), new KeyTransformer()], }); @@ -117,7 +104,6 @@ test('Test that a primary @key with id and createdAt it is not a required in cre `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [new DynamoDBModelTransformer(), new KeyTransformer()], }); @@ -145,7 +131,6 @@ test('Test that a primary @key with emailId and location makes it a required in `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [new DynamoDBModelTransformer(), new KeyTransformer()], }); @@ -173,7 +158,6 @@ test('Test that a primary @key with 3 fields changes the hash and sort keys.', ( `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [new DynamoDBModelTransformer(), new KeyTransformer()], }); @@ -212,7 +196,6 @@ test('Test that a secondary @key with 3 fields changes the hash and sort keys an `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [new DynamoDBModelTransformer(), new KeyTransformer()], }); @@ -260,7 +243,6 @@ test('Test that a secondary @key with a single field adds a GSI.', () => { `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [new DynamoDBModelTransformer(), new KeyTransformer()], }); @@ -295,7 +277,6 @@ test('Test that a secondary @key with a multiple field adds an GSI.', () => { `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [new DynamoDBModelTransformer(), new KeyTransformer()], }); @@ -345,16 +326,15 @@ test('Test that a secondary @key with a multiple field adds an LSI with GSI FF t } `; - const transformer = new GraphQLTransform({ - transformers: [new DynamoDBModelTransformer(), new KeyTransformer()], - featureFlags: ({ - getBoolean: (featureName: string, defaultValue: boolean) => { - if (featureName === 'secondaryKeyAsGSI') return false; - if (featureName === 'improvePluralization') return true; - return defaultValue || false; - }, - } as unknown) as FeatureFlagProvider, - }); + const transformer = new GraphQLTransform({ + transformers: [new DynamoDBModelTransformer(), new KeyTransformer()], + featureFlags: { + getBoolean: (featureName: string, defaultValue: boolean) => { + if (featureName === 'secondaryKeyAsGSI') return false; + return defaultValue || false; + }, + } as unknown as FeatureFlagProvider + }); const out = transformer.transform(validSchema); let tableResource = out.stacks.Test.Resources.TestTable; @@ -389,16 +369,15 @@ test('Test that a secondary @key with a multiple field adds an GSI based on enab } `; - const transformer = new GraphQLTransform({ - transformers: [new DynamoDBModelTransformer(), new KeyTransformer()], - featureFlags: ({ - getBoolean: (featureName: string, defaultValue: boolean) => { - if (featureName === 'secondaryKeyAsGSI') return true; - if (featureName === 'improvePluralization') return true; - return defaultValue || false; - }, - } as unknown) as FeatureFlagProvider, - }); + const transformer = new GraphQLTransform({ + transformers: [new DynamoDBModelTransformer(), new KeyTransformer()], + featureFlags: { + getBoolean: (featureName: string, defaultValue: boolean) => { + if (featureName === 'secondaryKeyAsGSI') return true; + return defaultValue || false; + }, + } as unknown as FeatureFlagProvider + }); const out = transformer.transform(validSchema); let tableResource = out.stacks.Test.Resources.TestTable; @@ -433,7 +412,6 @@ test('Test that a primary @key with complex fields will update the input objects `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [new DynamoDBModelTransformer(), new KeyTransformer()], }); @@ -497,7 +475,6 @@ test('Test that connection type is generated for custom query when queries is se `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [new DynamoDBModelTransformer(), new KeyTransformer()], }); diff --git a/packages/graphql-transformers-e2e-tests/src/__tests__/KeyWithAuth.e2e.test.ts b/packages/graphql-transformers-e2e-tests/src/__tests__/KeyWithAuth.e2e.test.ts index 059bd5f6c57..267bc3e9a1f 100644 --- a/packages/graphql-transformers-e2e-tests/src/__tests__/KeyWithAuth.e2e.test.ts +++ b/packages/graphql-transformers-e2e-tests/src/__tests__/KeyWithAuth.e2e.test.ts @@ -29,17 +29,7 @@ import 'isomorphic-fetch'; jest.setTimeout(2000000); const cf = new CloudFormationClient('us-west-2'); -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; + const BUILD_TIMESTAMP = moment().format('YYYYMMDDHHmmss'); const STACK_NAME = `KeyWithAuth-${BUILD_TIMESTAMP}`; const BUCKET_NAME = `appsync-key-with-auth-test-bucket-${BUILD_TIMESTAMP}`; @@ -120,7 +110,6 @@ beforeAll(async () => { } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new KeyTransformer(), diff --git a/packages/graphql-transformers-e2e-tests/src/__tests__/ModelAuthTransformer.e2e.test.ts b/packages/graphql-transformers-e2e-tests/src/__tests__/ModelAuthTransformer.e2e.test.ts index d027cbddc7c..8ad8fd7ff6a 100644 --- a/packages/graphql-transformers-e2e-tests/src/__tests__/ModelAuthTransformer.e2e.test.ts +++ b/packages/graphql-transformers-e2e-tests/src/__tests__/ModelAuthTransformer.e2e.test.ts @@ -28,17 +28,7 @@ import 'isomorphic-fetch'; (global as any).fetch = require('node-fetch'); jest.setTimeout(2000000); -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; + describe(`ModelAuthTests`, () => { const cf = new CloudFormationClient('us-west-2'); @@ -205,7 +195,6 @@ describe(`ModelAuthTests`, () => { } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelConnectionTransformer(), @@ -929,7 +918,7 @@ describe(`ModelAuthTests`, () => { expect((req2.errors[0] as any).errorType).toEqual('Unauthorized'); }); - test(`Test listSalaries w/ Admin group protection authorized`, async () => { + test(`Test listSalarys w/ Admin group protection authorized`, async () => { const req = await GRAPHQL_CLIENT_1.query( ` mutation { @@ -947,7 +936,7 @@ describe(`ModelAuthTests`, () => { const req2 = await GRAPHQL_CLIENT_1.query( ` query { - listSalaries(filter: { wage: { eq: 101 }}) { + listSalarys(filter: { wage: { eq: 101 }}) { items { id wage @@ -957,12 +946,12 @@ describe(`ModelAuthTests`, () => { `, {}, ); - expect(req2.data.listSalaries.items.length).toEqual(1); - expect(req2.data.listSalaries.items[0].id).toEqual(req.data.createSalary.id); - expect(req2.data.listSalaries.items[0].wage).toEqual(101); + expect(req2.data.listSalarys.items.length).toEqual(1); + expect(req2.data.listSalarys.items[0].id).toEqual(req.data.createSalary.id); + expect(req2.data.listSalarys.items[0].wage).toEqual(101); }); - test(`Test listSalaries w/ Admin group protection not authorized`, async () => { + test(`Test listSalarys w/ Admin group protection not authorized`, async () => { const req = await GRAPHQL_CLIENT_1.query( ` mutation { @@ -980,7 +969,7 @@ describe(`ModelAuthTests`, () => { const req2 = await GRAPHQL_CLIENT_2.query( ` query { - listSalaries(filter: { wage: { eq: 102 }}) { + listSalarys(filter: { wage: { eq: 102 }}) { items { id wage @@ -990,7 +979,7 @@ describe(`ModelAuthTests`, () => { `, {}, ); - expect(req2.data.listSalaries.items).toEqual([]); + expect(req2.data.listSalarys.items).toEqual([]); }); /** @@ -2828,7 +2817,7 @@ describe(`ModelAuthTests`, () => { const listResponse = await GRAPHQL_CLIENT_3.query( `query { - listTestIdentities(filter: { title: { eq: "Test title update" } }, limit: 100) { + listTestIdentitys(filter: { title: { eq: "Test title update" } }, limit: 100) { items { id title @@ -2838,7 +2827,7 @@ describe(`ModelAuthTests`, () => { }`, {}, ); - const relevantPost = listResponse.data.listTestIdentities.items.find(p => p.id === getReq.data.getTestIdentity.id); + const relevantPost = listResponse.data.listTestIdentitys.items.find(p => p.id === getReq.data.getTestIdentity.id); expect(relevantPost).toBeTruthy(); expect(relevantPost.title).toEqual('Test title update'); expect(relevantPost.owner.slice(0, 19)).toEqual('https://cognito-idp'); diff --git a/packages/graphql-transformers-e2e-tests/src/__tests__/ModelConnectionTransformer.e2e.test.ts b/packages/graphql-transformers-e2e-tests/src/__tests__/ModelConnectionTransformer.e2e.test.ts index ec30f5ab3f3..23824f4044f 100644 --- a/packages/graphql-transformers-e2e-tests/src/__tests__/ModelConnectionTransformer.e2e.test.ts +++ b/packages/graphql-transformers-e2e-tests/src/__tests__/ModelConnectionTransformer.e2e.test.ts @@ -16,17 +16,7 @@ jest.setTimeout(2000000); const cf = new CloudFormationClient('us-west-2'); const customS3Client = new S3Client('us-west-2'); const awsS3Client = new S3({ region: 'us-west-2' }); -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; + const BUILD_TIMESTAMP = moment().format('YYYYMMDDHHmmss'); const STACK_NAME = `ModelConnectionTransformerTest-${BUILD_TIMESTAMP}`; const BUCKET_NAME = `appsync-connection-transformer-test-${BUILD_TIMESTAMP}`; @@ -76,7 +66,6 @@ beforeAll(async () => { } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelConnectionTransformer(), diff --git a/packages/graphql-transformers-e2e-tests/src/__tests__/ModelConnectionWithKeyTransformer.e2e.test.ts b/packages/graphql-transformers-e2e-tests/src/__tests__/ModelConnectionWithKeyTransformer.e2e.test.ts index fd19b3911cf..8267c25dbeb 100644 --- a/packages/graphql-transformers-e2e-tests/src/__tests__/ModelConnectionWithKeyTransformer.e2e.test.ts +++ b/packages/graphql-transformers-e2e-tests/src/__tests__/ModelConnectionWithKeyTransformer.e2e.test.ts @@ -17,17 +17,7 @@ jest.setTimeout(2000000); const cf = new CloudFormationClient('us-west-2'); const customS3Client = new S3Client('us-west-2'); const awsS3Client = new S3({ region: 'us-west-2' }); -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; + const BUILD_TIMESTAMP = moment().format('YYYYMMDDHHmmss'); const STACK_NAME = `ModelConnectionKeyTransformerTest-${BUILD_TIMESTAMP}`; const BUCKET_NAME = `appsync-connection-key-transformer-test-${BUILD_TIMESTAMP}`; @@ -156,7 +146,6 @@ beforeAll(async () => { `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new KeyTransformer(), diff --git a/packages/graphql-transformers-e2e-tests/src/__tests__/MultiAuthModelAuthTransformer.e2e.test.ts b/packages/graphql-transformers-e2e-tests/src/__tests__/MultiAuthModelAuthTransformer.e2e.test.ts index 9e11842052a..146f7480209 100644 --- a/packages/graphql-transformers-e2e-tests/src/__tests__/MultiAuthModelAuthTransformer.e2e.test.ts +++ b/packages/graphql-transformers-e2e-tests/src/__tests__/MultiAuthModelAuthTransformer.e2e.test.ts @@ -38,17 +38,7 @@ jest.setTimeout(2000000); const REGION = 'us-west-2'; const cf = new CloudFormationClient(REGION); -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; + const BUILD_TIMESTAMP = moment().format('YYYYMMDDHHmmss'); const STACK_NAME = `MultiAuthModelAuthTransformerTest-${BUILD_TIMESTAMP}`; const BUCKET_NAME = `appsync-multi-auth-transformer-test-bucket-${BUILD_TIMESTAMP}`; @@ -248,7 +238,6 @@ beforeAll(async () => { `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelConnectionTransformer(), diff --git a/packages/graphql-transformers-e2e-tests/src/__tests__/MutationCondition.e2e.test.ts b/packages/graphql-transformers-e2e-tests/src/__tests__/MutationCondition.e2e.test.ts index 7558bd1354f..a27490b2f60 100644 --- a/packages/graphql-transformers-e2e-tests/src/__tests__/MutationCondition.e2e.test.ts +++ b/packages/graphql-transformers-e2e-tests/src/__tests__/MutationCondition.e2e.test.ts @@ -34,20 +34,9 @@ import AWS = require('aws-sdk'); import 'isomorphic-fetch'; jest.setTimeout(2000000); -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; + const transformAndParseSchema = (schema: string, version: number = TRANSFORM_CURRENT_VERSION): DocumentNode => { const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new VersionedModelTransformer(), @@ -615,7 +604,6 @@ describe(`Deployed Mutation Condition tests`, () => { `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new VersionedModelTransformer(), diff --git a/packages/graphql-transformers-e2e-tests/src/__tests__/NestedStacksTest.e2e.test.ts b/packages/graphql-transformers-e2e-tests/src/__tests__/NestedStacksTest.e2e.test.ts index 051ecee72bb..4797ae50205 100644 --- a/packages/graphql-transformers-e2e-tests/src/__tests__/NestedStacksTest.e2e.test.ts +++ b/packages/graphql-transformers-e2e-tests/src/__tests__/NestedStacksTest.e2e.test.ts @@ -14,17 +14,7 @@ import fs = require('fs'); import path = require('path'); jest.setTimeout(2000000); -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; + test('Test custom root types with additional fields.', () => { const validSchema = ` type Query { @@ -42,7 +32,6 @@ test('Test custom root types with additional fields.', () => { } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [new DynamoDBModelTransformer()], }); // GetAttGraphQLAPIId diff --git a/packages/graphql-transformers-e2e-tests/src/__tests__/NewConnectionTransformer.e2e.test.ts b/packages/graphql-transformers-e2e-tests/src/__tests__/NewConnectionTransformer.e2e.test.ts index 09ff17d1686..a36afb127e9 100644 --- a/packages/graphql-transformers-e2e-tests/src/__tests__/NewConnectionTransformer.e2e.test.ts +++ b/packages/graphql-transformers-e2e-tests/src/__tests__/NewConnectionTransformer.e2e.test.ts @@ -17,17 +17,7 @@ jest.setTimeout(2000000); const cf = new CloudFormationClient('us-west-2'); const customS3Client = new S3Client('us-west-2'); const awsS3Client = new S3({ region: 'us-west-2' }); -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; + const BUILD_TIMESTAMP = moment().format('YYYYMMDDHHmmss'); const STACK_NAME = `NewConnectionTransformerTest-${BUILD_TIMESTAMP}`; const BUCKET_NAME = `appsync-new-connection-transformer-test-${BUILD_TIMESTAMP}`; @@ -134,7 +124,6 @@ type PostAuthor let out: DeploymentResources = undefined; try { const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new KeyTransformer(), diff --git a/packages/graphql-transformers-e2e-tests/src/__tests__/NewConnectionWithAuth.e2e.test.ts b/packages/graphql-transformers-e2e-tests/src/__tests__/NewConnectionWithAuth.e2e.test.ts index 49fcdd847c4..ba0a2be1d42 100644 --- a/packages/graphql-transformers-e2e-tests/src/__tests__/NewConnectionWithAuth.e2e.test.ts +++ b/packages/graphql-transformers-e2e-tests/src/__tests__/NewConnectionWithAuth.e2e.test.ts @@ -30,17 +30,7 @@ import 'isomorphic-fetch'; jest.setTimeout(2000000); const cf = new CloudFormationClient('us-west-2'); -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; + const BUILD_TIMESTAMP = moment().format('YYYYMMDDHHmmss'); const STACK_NAME = `NewConnectionsWithAuthTests-${BUILD_TIMESTAMP}`; const BUCKET_NAME = `new-connections-with-auth-test-bucket-${BUILD_TIMESTAMP}`; @@ -151,7 +141,6 @@ beforeAll(async () => { } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new KeyTransformer(), diff --git a/packages/graphql-transformers-e2e-tests/src/__tests__/NonModelAuthFunction.e2e.test.ts b/packages/graphql-transformers-e2e-tests/src/__tests__/NonModelAuthFunction.e2e.test.ts index b9a6e023885..645ab7364c2 100644 --- a/packages/graphql-transformers-e2e-tests/src/__tests__/NonModelAuthFunction.e2e.test.ts +++ b/packages/graphql-transformers-e2e-tests/src/__tests__/NonModelAuthFunction.e2e.test.ts @@ -32,17 +32,7 @@ import { AuthenticationDetails } from 'amazon-cognito-identity-js'; // to deal with bug in cognito-identity-js (global as any).fetch = require('node-fetch'); -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; + // To overcome of the way of how AmplifyJS picks up currentUserCredentials const anyAWS = AWS as any; @@ -123,7 +113,6 @@ beforeAll(async () => { console.warn(`Could not setup function: ${e}`); } const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new FunctionTransformer(), diff --git a/packages/graphql-transformers-e2e-tests/src/__tests__/NoneEnvFunctionTransformer.e2e.test.ts b/packages/graphql-transformers-e2e-tests/src/__tests__/NoneEnvFunctionTransformer.e2e.test.ts index 51e33e36fdc..be0cd94b53f 100644 --- a/packages/graphql-transformers-e2e-tests/src/__tests__/NoneEnvFunctionTransformer.e2e.test.ts +++ b/packages/graphql-transformers-e2e-tests/src/__tests__/NoneEnvFunctionTransformer.e2e.test.ts @@ -18,17 +18,7 @@ jest.setTimeout(2000000); const cf = new CloudFormationClient('us-west-2'); const customS3Client = new S3Client('us-west-2'); const awsS3Client = new S3({ region: 'us-west-2' }); -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; + const BUILD_TIMESTAMP = moment().format('YYYYMMDDHHmmss'); const STACK_NAME = `NoneEnvFunctionTransformerTests-${BUILD_TIMESTAMP}`; const BUCKET_NAME = `appsync-none-env-func-trans-test-bucket-${BUILD_TIMESTAMP}`; @@ -84,7 +74,6 @@ beforeAll(async () => { console.warn(`Could not setup function: ${e}`); } const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new FunctionTransformer(), diff --git a/packages/graphql-transformers-e2e-tests/src/__tests__/PerFieldAuthTests.e2e.test.ts b/packages/graphql-transformers-e2e-tests/src/__tests__/PerFieldAuthTests.e2e.test.ts index bbb7f70e3a8..f95f1aa8eee 100644 --- a/packages/graphql-transformers-e2e-tests/src/__tests__/PerFieldAuthTests.e2e.test.ts +++ b/packages/graphql-transformers-e2e-tests/src/__tests__/PerFieldAuthTests.e2e.test.ts @@ -29,17 +29,7 @@ import 'isomorphic-fetch'; jest.setTimeout(2000000); const cf = new CloudFormationClient('us-west-2'); -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; + const BUILD_TIMESTAMP = moment().format('YYYYMMDDHHmmss'); const STACK_NAME = `PerFieldAuthTests-${BUILD_TIMESTAMP}`; const BUCKET_NAME = `per-field-auth-tests-bucket-${BUILD_TIMESTAMP}`; @@ -175,7 +165,6 @@ beforeAll(async () => { } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelConnectionTransformer(), diff --git a/packages/graphql-transformers-e2e-tests/src/__tests__/PredictionsTransformerTests.e2e.test.ts b/packages/graphql-transformers-e2e-tests/src/__tests__/PredictionsTransformerTests.e2e.test.ts index 1376a05a935..c9c866c85bb 100644 --- a/packages/graphql-transformers-e2e-tests/src/__tests__/PredictionsTransformerTests.e2e.test.ts +++ b/packages/graphql-transformers-e2e-tests/src/__tests__/PredictionsTransformerTests.e2e.test.ts @@ -18,17 +18,7 @@ const AWS_REGION = 'us-east-2'; const cf = new CloudFormationClient(AWS_REGION); const customS3Client = new S3Client(AWS_REGION); const awsS3Client = new S3({ region: AWS_REGION }); -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; + const BUILD_TIMESTAMP = moment().format('YYYYMMDDHHmmss'); const STACK_NAME = `PredictionsTransformerTests-${BUILD_TIMESTAMP}`; const BUCKET_NAME = `appsync-predictions-transformer-test-bucket-${BUILD_TIMESTAMP}`; @@ -58,7 +48,6 @@ beforeAll(async () => { console.warn(`Could not create bucket: ${e}`); } const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new PredictionsTransformer({ bucketName: BUCKET_NAME }), diff --git a/packages/graphql-transformers-e2e-tests/src/__tests__/SearchableModelTransformer.e2e.test.ts b/packages/graphql-transformers-e2e-tests/src/__tests__/SearchableModelTransformer.e2e.test.ts index 65c5dad5571..73005341825 100644 --- a/packages/graphql-transformers-e2e-tests/src/__tests__/SearchableModelTransformer.e2e.test.ts +++ b/packages/graphql-transformers-e2e-tests/src/__tests__/SearchableModelTransformer.e2e.test.ts @@ -20,17 +20,6 @@ const cf = new CloudFormationClient('us-west-2'); const customS3Client = new S3Client('us-west-2'); const awsS3Client = new S3({ region: 'us-west-2' }); let GRAPHQL_CLIENT: GraphQLClient = undefined; -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; const BUILD_TIMESTAMP = moment().format('YYYYMMDDHHmmss'); const STACK_NAME = `TestSearchableModelTransformer-${BUILD_TIMESTAMP}`; @@ -138,7 +127,6 @@ beforeAll(async () => { } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new KeyTransformer(), diff --git a/packages/graphql-transformers-e2e-tests/src/__tests__/SearchableWithAuthTests.e2e.test.ts b/packages/graphql-transformers-e2e-tests/src/__tests__/SearchableWithAuthTests.e2e.test.ts index 298e0a62d91..6d9273c19b4 100644 --- a/packages/graphql-transformers-e2e-tests/src/__tests__/SearchableWithAuthTests.e2e.test.ts +++ b/packages/graphql-transformers-e2e-tests/src/__tests__/SearchableWithAuthTests.e2e.test.ts @@ -30,17 +30,7 @@ import 'isomorphic-fetch'; // To overcome of the way of how AmplifyJS picks up currentUserCredentials const anyAWS = AWS as any; -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; + if (anyAWS && anyAWS.config && anyAWS.config.credentials) { delete anyAWS.config.credentials; } @@ -162,7 +152,6 @@ beforeAll(async () => { }`; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelConnectionTransformer(), diff --git a/packages/graphql-transformers-e2e-tests/src/__tests__/SubscriptionsWithAuthTest.e2e.test.ts b/packages/graphql-transformers-e2e-tests/src/__tests__/SubscriptionsWithAuthTest.e2e.test.ts index 63986efe9f0..8ab3291167f 100644 --- a/packages/graphql-transformers-e2e-tests/src/__tests__/SubscriptionsWithAuthTest.e2e.test.ts +++ b/packages/graphql-transformers-e2e-tests/src/__tests__/SubscriptionsWithAuthTest.e2e.test.ts @@ -37,17 +37,7 @@ const anyAWS = AWS as any; if (anyAWS && anyAWS.config && anyAWS.config.credentials) { delete anyAWS.config.credentials; } -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; + // to deal with bug in cognito-identity-js (global as any).fetch = require('node-fetch'); // to deal with subscriptions in node env @@ -250,7 +240,6 @@ beforeAll(async () => { }`; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new ModelAuthTransformer({ diff --git a/packages/graphql-transformers-e2e-tests/src/__tests__/TestComplexStackMappingsLocal.e2e.test.ts b/packages/graphql-transformers-e2e-tests/src/__tests__/TestComplexStackMappingsLocal.e2e.test.ts index 36f963d5995..905d4edc05d 100644 --- a/packages/graphql-transformers-e2e-tests/src/__tests__/TestComplexStackMappingsLocal.e2e.test.ts +++ b/packages/graphql-transformers-e2e-tests/src/__tests__/TestComplexStackMappingsLocal.e2e.test.ts @@ -29,17 +29,6 @@ type Post @model @searchable { score: Int @function(name: "scorefunc") } `; -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; /** * We test this schema with the same set of rules multiple times. This protects against a subtle bug in the stack mapping @@ -62,7 +51,6 @@ test('Test that every resource exists in the correct stack given a complex schem function transpileAndCheck(schema: string) { const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new HttpTransformer(), @@ -97,7 +85,7 @@ function transpileAndCheck(schema: string) { 'FunctionDirectiveStack', 'HttpStack', 'NoneDataSource', - ]), + ]) ); expectExactKeys(out.rootStack.Outputs, new Set(['GraphQLAPIIdOutput', 'GraphQLAPIEndpointOutput', 'GraphQLAPIKeyOutput'])); @@ -116,7 +104,7 @@ function transpileAndCheck(schema: string) { 'SubscriptiononCreateUserResolver', 'SubscriptiononDeleteUserResolver', 'SubscriptiononUpdateUserResolver', - ]), + ]) ); expectExactKeys(out.stacks.User.Outputs, new Set(['GetAttUserTableStreamArn', 'GetAttUserDataSourceName', 'GetAttUserTableName'])); @@ -132,11 +120,11 @@ function transpileAndCheck(schema: string) { 'CreateUserPostResolver', 'UpdateUserPostResolver', 'DeleteUserPostResolver', - ]), + ]) ); expectExactKeys( out.stacks.UserPost.Outputs, - new Set(['GetAttUserPostTableStreamArn', 'GetAttUserPostDataSourceName', 'GetAttUserPostTableName']), + new Set(['GetAttUserPostTableStreamArn', 'GetAttUserPostDataSourceName', 'GetAttUserPostTableName']) ); // Check Post @@ -151,7 +139,7 @@ function transpileAndCheck(schema: string) { 'CreatePostResolver', 'UpdatePostResolver', 'DeletePostResolver', - ]), + ]) ); expectExactKeys(out.stacks.Post.Outputs, new Set(['GetAttPostTableStreamArn', 'GetAttPostDataSourceName', 'GetAttPostTableName'])); @@ -166,21 +154,21 @@ function transpileAndCheck(schema: string) { 'ElasticSearchStreamingLambdaFunction', 'SearchablePostLambdaMapping', 'SearchPostResolver', - ]), + ]) ); expectExactKeys(out.stacks.SearchableStack.Outputs, new Set(['ElasticsearchDomainArn', 'ElasticsearchDomainEndpoint'])); // Check connections expectExactKeys( out.stacks.ConnectionStack.Resources, - new Set(['UserpostsResolver', 'UserPostuserResolver', 'UserPostpostResolver', 'PostauthorsResolver']), + new Set(['UserpostsResolver', 'UserPostuserResolver', 'UserPostpostResolver', 'PostauthorsResolver']) ); expectExactKeys(out.stacks.ConnectionStack.Outputs, new Set([])); // Check function stack expectExactKeys( out.stacks.FunctionDirectiveStack.Resources, - new Set(['ScorefuncLambdaDataSourceRole', 'ScorefuncLambdaDataSource', 'InvokeScorefuncLambdaDataSource', 'PostscoreResolver']), + new Set(['ScorefuncLambdaDataSourceRole', 'ScorefuncLambdaDataSource', 'InvokeScorefuncLambdaDataSource', 'PostscoreResolver']) ); expectExactKeys(out.stacks.ConnectionStack.Outputs, new Set([])); diff --git a/packages/graphql-transformers-e2e-tests/src/__tests__/VersionedModelTransformer.e2e.test.ts b/packages/graphql-transformers-e2e-tests/src/__tests__/VersionedModelTransformer.e2e.test.ts index c55267c033a..1ef8371abb9 100644 --- a/packages/graphql-transformers-e2e-tests/src/__tests__/VersionedModelTransformer.e2e.test.ts +++ b/packages/graphql-transformers-e2e-tests/src/__tests__/VersionedModelTransformer.e2e.test.ts @@ -14,17 +14,7 @@ import { cleanupStackAfterTest, deploy } from '../deployNestedStacks'; jest.setTimeout(2000000); const cf = new CloudFormationClient('us-west-2'); -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; + const BUILD_TIMESTAMP = moment().format('YYYYMMDDHHmmss'); const STACK_NAME = `VersionedTest-${BUILD_TIMESTAMP}`; const BUCKET_NAME = `versioned-test-bucket-${BUILD_TIMESTAMP}`; @@ -54,7 +44,6 @@ beforeAll(async () => { } `; const transformer = new GraphQLTransform({ - featureFlags, transformers: [ new DynamoDBModelTransformer(), new VersionedModelTransformer(), diff --git a/packages/graphql-versioned-transformer/src/__tests__/VersionedModelTransformer.test.ts b/packages/graphql-versioned-transformer/src/__tests__/VersionedModelTransformer.test.ts index 2d3f5efa3ea..fdfd9915cdd 100644 --- a/packages/graphql-versioned-transformer/src/__tests__/VersionedModelTransformer.test.ts +++ b/packages/graphql-versioned-transformer/src/__tests__/VersionedModelTransformer.test.ts @@ -2,23 +2,13 @@ import { ObjectTypeDefinitionNode, parse, DocumentNode, Kind, InputObjectTypeDef import { GraphQLTransform } from 'graphql-transformer-core'; import { VersionedModelTransformer } from '../VersionedModelTransformer'; import { DynamoDBModelTransformer } from 'graphql-dynamodb-transformer'; + const getInputType = (schemaDoc: DocumentNode) => (name: string): InputObjectTypeDefinitionNode => schemaDoc.definitions.find(d => d.kind === Kind.INPUT_OBJECT_TYPE_DEFINITION && d.name.value === name) as InputObjectTypeDefinitionNode; const getInputField = (input: InputObjectTypeDefinitionNode, field: string) => input.fields.find(f => f.name.value === field); const getType = (schemaDoc: DocumentNode) => (name: string): ObjectTypeDefinitionNode => schemaDoc.definitions.find(d => d.kind === Kind.OBJECT_TYPE_DEFINITION && d.name.value === name) as ObjectTypeDefinitionNode; const getField = (input: ObjectTypeDefinitionNode, field: string) => input.fields.find(f => f.name.value === field); -const featureFlags = { - getBoolean: jest.fn().mockImplementation((name, defaultValue) => { - if (name === 'improvePluralization') { - return true; - } - return; - }), - getNumber: jest.fn(), - getObject: jest.fn(), - getString: jest.fn(), -}; test('Test VersionedModelTransformer validation happy case', () => { const validSchema = ` @@ -31,7 +21,6 @@ test('Test VersionedModelTransformer validation happy case', () => { `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new VersionedModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); // tslint:disable-next-line @@ -58,7 +47,6 @@ test('Test VersionedModelTransformer validation fails when provided version fiel try { const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new VersionedModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); } catch (e) { @@ -78,7 +66,6 @@ test('Test VersionedModelTransformer version field replaced by non-null if provi `; const transformer = new GraphQLTransform({ transformers: [new DynamoDBModelTransformer(), new VersionedModelTransformer()], - featureFlags, }); const out = transformer.transform(validSchema); const sdl = out.schema; diff --git a/yarn.lock b/yarn.lock index 31530056264..7abee12c951 100644 --- a/yarn.lock +++ b/yarn.lock @@ -19422,7 +19422,7 @@ plist@^3.0.1: xmlbuilder "^9.0.7" xmldom "0.1.x" -pluralize@8.0.0, pluralize@^8.0.0: +pluralize@^8.0.0: version "8.0.0" resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-8.0.0.tgz#1a6fa16a38d12a1901e0320fa017051c539ce3b1" integrity sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==