Skip to content

Commit

Permalink
Revert unnecessary changes for custom types and refs
Browse files Browse the repository at this point in the history
  • Loading branch information
vaisshnavi7 committed Jan 17, 2025
1 parent 949e6ee commit cdb02d1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 53 deletions.
60 changes: 20 additions & 40 deletions packages/data-schema/__tests__/CustomOperations.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1341,14 +1341,15 @@ describe('custom operations + custom type auth inheritance', () => {

test('implicit custom type inherits auth rules from referencing op', () => {
const s = a.schema({
MyQueryReturnType: a.customType({
fieldA: a.string(),
fieldB: a.integer(),
}),
myQuery: a
.query()
.handler(a.handler.function('myFn'))
.returns(a.ref('MyQueryReturnType'))
.returns(
a.customType({
fieldA: a.string(),
fieldB: a.integer(),
}),
)
.authorization((allow) => allow.publicApiKey()),
});

Expand All @@ -1362,22 +1363,23 @@ describe('custom operations + custom type auth inheritance', () => {

test('nested custom types inherit auth rules from top-level referencing op', () => {
const s = a.schema({
MyQueryReturnType: a.customType({
fieldA: a.string(),
fieldB: a.integer(),
nestedCustomType: a.customType({
nestedA: a.string(),
nestedB: a.string(),
grandChild: a.customType({
grandA: a.string(),
grandB: a.string(),
}),
}),
}),
myQuery: a
.query()
.handler(a.handler.function('myFn'))
.returns(a.ref('MyQueryReturnType'))
.returns(
a.customType({
fieldA: a.string(),
fieldB: a.integer(),
nestedCustomType: a.customType({
nestedA: a.string(),
nestedB: a.string(),
grandChild: a.customType({
grandA: a.string(),
grandB: a.string(),
}),
}),
}),
)
.authorization((allow) => allow.publicApiKey()),
});

Expand All @@ -1399,28 +1401,6 @@ describe('custom operations + custom type auth inheritance', () => {
);
});

test('inline custom type inherits auth rules from referencing op', () => {
const s = a.schema({
myQuery: a
.query()
.handler(a.handler.function('myFn'))
.returns(
a.customType({
fieldA: a.string(),
fieldB: a.integer(),
}),
)
.authorization((allow) => allow.publicApiKey()),
});

const result = s.transform().schema;

expect(result).toMatchSnapshot();
expect(result).toEqual(
expect.stringContaining('type MyQueryReturnType @aws_api_key\n{'),
);
});

test('top-level custom type with nested top-level custom types inherits combined auth rules from referencing ops', () => {
const s = a.schema({
myQuery: a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,18 +545,6 @@ type Query {
}"
`;

exports[`custom operations + custom type auth inheritance inline custom type inherits auth rules from referencing op 1`] = `
"type MyQueryReturnType @aws_api_key
{
fieldA: String
fieldB: Int
}
type Query {
myQuery: MyQueryReturnType @function(name: "myFn") @auth(rules: [{allow: public, provider: apiKey}])
}"
`;

exports[`custom operations + custom type auth inheritance nested custom types inherit auth rules from top-level referencing op 1`] = `
"type MyQueryReturnType @aws_api_key
{
Expand Down
2 changes: 1 addition & 1 deletion packages/data-schema/src/SchemaProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,7 @@ function generateInputTypes(
generateInputType,
getRefType,
authRules,
true,
false,
);
nestedGeneratedTypes.forEach((type) => {
generatedTypes.add(type);
Expand Down

0 comments on commit cdb02d1

Please sign in to comment.