Skip to content

Commit

Permalink
Remove test enforcing bugged behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
marcvberg committed Aug 15, 2022
1 parent 4a60931 commit 3fa19b2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -636,43 +636,6 @@ describe('ModelTransformer: ', () => {
expectFields(subscriptionType!, ['onUpdatePost', 'onCreatePost', 'onDeletePost']);
});

it('should support advanced subscriptions', () => {
const validSchema = `type Post @model(subscriptions: {
onCreate: ["onFeedUpdated", "onCreatePost"],
onUpdate: ["onFeedUpdated"],
onDelete: ["onFeedUpdated"]
}) {
id: ID!
title: String!
createdAt: String
updatedAt: String
}
`;
const transformer = new GraphQLTransform({
transformers: [new ModelTransformer()],
featureFlags,
});
const out = transformer.transform(validSchema);
expect(out).toBeDefined();
const definition = out.schema;
expect(definition).toBeDefined();
const parsed = parse(definition);
validateModelSchema(parsed);

const subscriptionType = getObjectType(parsed, 'Subscription');
expect(subscriptionType).toBeDefined();
expectFields(subscriptionType!, ['onFeedUpdated', 'onCreatePost']);
const subField = subscriptionType!.fields!.find(f => f.name.value === 'onFeedUpdated');
expect(subField!.directives!.length).toEqual(1);
expect(subField!.directives![0].name!.value).toEqual('aws_subscribe');
const mutationsList = subField!.directives![0].arguments!.find(a => a.name.value === 'mutations')!.value as ListValueNode;
const mutList = mutationsList.values.map((v: any) => v.value);
expect(mutList.length).toEqual(3);
expect(mutList).toContain('createPost');
expect(mutList).toContain('updatePost');
expect(mutList).toContain('deletePost');
});

it('should not generate superfluous input and filter types', () => {
const validSchema = `
type Entity @model(mutations: null, subscriptions: null, queries: {get: "getEntity"}) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ export class ModelTransformer extends TransformerModelBase implements Transforme

// This property override is specifically to address parity between V1 and V2 when the FF is disabled
// If one subscription is defined, just let the others go to null without FF. But if public and none defined, default all subs
if (!ctx.featureFlags.getBoolean('shouldDeepMergeDirectiveConfigDefaults', false)) {
if (!ctx.featureFlags.getBoolean('shouldDeepMergeDirectiveConfigDefaults', false)
&& options?.subscriptions?.level === SubscriptionLevel.public) {
const publicSubscriptionDefaults = {
onCreate: [getFieldNameFor('onCreate', typeName)],
onDelete: [getFieldNameFor('onDelete', typeName)],
Expand All @@ -250,8 +251,7 @@ export class ModelTransformer extends TransformerModelBase implements Transforme
},
ctx.featureFlags,
);
if (baseArgs?.subscriptions?.level === SubscriptionLevel.public
&& !(baseArgs?.subscriptions?.onCreate || baseArgs?.subscriptions?.onDelete || baseArgs?.subscriptions?.onUpdate)) {
if (!(baseArgs?.subscriptions?.onCreate || baseArgs?.subscriptions?.onDelete || baseArgs?.subscriptions?.onUpdate)) {
options.subscriptions = { level: SubscriptionLevel.public, ...publicSubscriptionDefaults };
}
}
Expand Down

0 comments on commit 3fa19b2

Please sign in to comment.