Skip to content

Commit

Permalink
refactor: move createInfo to staticTypes (#5443)
Browse files Browse the repository at this point in the history
* refactor: move createInfo to staticTypes

* test: update snapshots
  • Loading branch information
mjfwebb authored Aug 7, 2024
1 parent 991eca3 commit ae9ab22
Show file tree
Hide file tree
Showing 11 changed files with 91 additions and 127 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ export class StaticSchemaTypes {
});
}

public get createInfo(): ObjectTypeComposer {
return this.schemaBuilder.getOrCreateObjectType("CreateInfo", () => {
return {
fields: {
nodesCreated: this.schemaBuilder.types.int.NonNull,
relationshipsCreated: this.schemaBuilder.types.int.NonNull,
},
};
});
}

@Memoize()
public get sortDirection(): EnumTypeComposer {
return this.schemaBuilder.createEnumType("SortDirection", ["ASC", "DESC"]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -303,23 +303,11 @@ export class TopLevelEntitySchemaTypes {
public get createType(): ObjectTypeComposer {
return this.schemaBuilder.getOrCreateObjectType(this.entityTypeNames.createResponse, () => {
const nodeType = this.nodeType;
const info = this.createInfo;

return {
fields: {
[this.entityTypeNames.queryField]: nodeType.NonNull.List.NonNull,
info,
},
};
});
}

public get createInfo(): ObjectTypeComposer {
return this.schemaBuilder.getOrCreateObjectType(this.entityTypeNames.createInfo, () => {
return {
fields: {
nodesCreated: this.schemaBuilder.types.int.NonNull,
relationshipsCreated: this.schemaBuilder.types.int.NonNull,
info: this.schemaTypes.staticTypes.createInfo,
},
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ describe("@default on array fields", () => {
equals: Boolean
}
type CreateInfo {
nodesCreated: Int!
relationshipsCreated: Int!
}
\\"\\"\\"A date and time, represented as an ISO-8601 string\\"\\"\\"
scalar DateTime
Expand Down Expand Up @@ -84,11 +89,6 @@ describe("@default on array fields", () => {
pageInfo: PageInfo
}
type MovieCreateInfo {
nodesCreated: Int!
relationshipsCreated: Int!
}
input MovieCreateInput {
node: MovieCreateNode!
}
Expand All @@ -103,7 +103,7 @@ describe("@default on array fields", () => {
}
type MovieCreateResponse {
info: MovieCreateInfo
info: CreateInfo
movies: [Movie!]!
}
Expand Down
12 changes: 6 additions & 6 deletions packages/graphql/tests/api-v6/schema/directives/default.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ describe("@default on fields", () => {
equals: Boolean
}
type CreateInfo {
nodesCreated: Int!
relationshipsCreated: Int!
}
\\"\\"\\"A date and time, represented as an ISO-8601 string\\"\\"\\"
scalar DateTime
Expand Down Expand Up @@ -119,11 +124,6 @@ describe("@default on fields", () => {
node: MovieSort
}
type MovieCreateInfo {
nodesCreated: Int!
relationshipsCreated: Int!
}
input MovieCreateInput {
node: MovieCreateNode!
}
Expand All @@ -138,7 +138,7 @@ describe("@default on fields", () => {
}
type MovieCreateResponse {
info: MovieCreateInfo
info: CreateInfo
movies: [Movie!]!
}
Expand Down
12 changes: 6 additions & 6 deletions packages/graphql/tests/api-v6/schema/directives/relayId.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ describe("RelayId", () => {
mutation: Mutation
}
type CreateInfo {
nodesCreated: Int!
relationshipsCreated: Int!
}
input GlobalIdWhere {
equals: String
}
Expand Down Expand Up @@ -70,11 +75,6 @@ describe("RelayId", () => {
node: MovieSort
}
type MovieCreateInfo {
nodesCreated: Int!
relationshipsCreated: Int!
}
input MovieCreateInput {
node: MovieCreateNode!
}
Expand All @@ -85,7 +85,7 @@ describe("RelayId", () => {
}
type MovieCreateResponse {
info: MovieCreateInfo
info: CreateInfo
movies: [Movie!]!
}
Expand Down
38 changes: 14 additions & 24 deletions packages/graphql/tests/api-v6/schema/relationship.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ describe("Relationships", () => {
node: ActorSort
}
type ActorCreateInfo {
nodesCreated: Int!
relationshipsCreated: Int!
}
input ActorCreateInput {
node: ActorCreateNode!
}
Expand All @@ -74,7 +69,7 @@ describe("Relationships", () => {
type ActorCreateResponse {
actors: [Actor!]!
info: ActorCreateInfo
info: CreateInfo
}
type ActorEdge {
Expand Down Expand Up @@ -158,6 +153,11 @@ describe("Relationships", () => {
name: StringWhere
}
type CreateInfo {
nodesCreated: Int!
relationshipsCreated: Int!
}
type Movie {
actors(where: MovieActorsOperationWhere): MovieActorsOperation
title: String
Expand Down Expand Up @@ -225,11 +225,6 @@ describe("Relationships", () => {
node: MovieSort
}
type MovieCreateInfo {
nodesCreated: Int!
relationshipsCreated: Int!
}
input MovieCreateInput {
node: MovieCreateNode!
}
Expand All @@ -239,7 +234,7 @@ describe("Relationships", () => {
}
type MovieCreateResponse {
info: MovieCreateInfo
info: CreateInfo
movies: [Movie!]!
}
Expand Down Expand Up @@ -361,11 +356,6 @@ describe("Relationships", () => {
node: ActorSort
}
type ActorCreateInfo {
nodesCreated: Int!
relationshipsCreated: Int!
}
input ActorCreateInput {
node: ActorCreateNode!
}
Expand All @@ -376,7 +366,7 @@ describe("Relationships", () => {
type ActorCreateResponse {
actors: [Actor!]!
info: ActorCreateInfo
info: CreateInfo
}
type ActorEdge {
Expand Down Expand Up @@ -463,6 +453,11 @@ describe("Relationships", () => {
name: StringWhere
}
type CreateInfo {
nodesCreated: Int!
relationshipsCreated: Int!
}
input IntWhere {
AND: [IntWhere!]
NOT: IntWhere
Expand Down Expand Up @@ -545,11 +540,6 @@ describe("Relationships", () => {
node: MovieSort
}
type MovieCreateInfo {
nodesCreated: Int!
relationshipsCreated: Int!
}
input MovieCreateInput {
node: MovieCreateNode!
}
Expand All @@ -559,7 +549,7 @@ describe("Relationships", () => {
}
type MovieCreateResponse {
info: MovieCreateInfo
info: CreateInfo
movies: [Movie!]!
}
Expand Down
43 changes: 19 additions & 24 deletions packages/graphql/tests/api-v6/schema/simple.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ describe("Simple Aura-API", () => {
mutation: Mutation
}
type CreateInfo {
nodesCreated: Int!
relationshipsCreated: Int!
}
type Movie {
title: String
}
Expand All @@ -53,11 +58,6 @@ describe("Simple Aura-API", () => {
node: MovieSort
}
type MovieCreateInfo {
nodesCreated: Int!
relationshipsCreated: Int!
}
input MovieCreateInput {
node: MovieCreateNode!
}
Expand All @@ -67,7 +67,7 @@ describe("Simple Aura-API", () => {
}
type MovieCreateResponse {
info: MovieCreateInfo
info: CreateInfo
movies: [Movie!]!
}
Expand Down Expand Up @@ -164,11 +164,6 @@ describe("Simple Aura-API", () => {
node: ActorSort
}
type ActorCreateInfo {
nodesCreated: Int!
relationshipsCreated: Int!
}
input ActorCreateInput {
node: ActorCreateNode!
}
Expand All @@ -179,7 +174,7 @@ describe("Simple Aura-API", () => {
type ActorCreateResponse {
actors: [Actor!]!
info: ActorCreateInfo
info: CreateInfo
}
type ActorEdge {
Expand Down Expand Up @@ -209,6 +204,11 @@ describe("Simple Aura-API", () => {
name: StringWhere
}
type CreateInfo {
nodesCreated: Int!
relationshipsCreated: Int!
}
type Movie {
title: String
}
Expand All @@ -222,11 +222,6 @@ describe("Simple Aura-API", () => {
node: MovieSort
}
type MovieCreateInfo {
nodesCreated: Int!
relationshipsCreated: Int!
}
input MovieCreateInput {
node: MovieCreateNode!
}
Expand All @@ -236,7 +231,7 @@ describe("Simple Aura-API", () => {
}
type MovieCreateResponse {
info: MovieCreateInfo
info: CreateInfo
movies: [Movie!]!
}
Expand Down Expand Up @@ -322,6 +317,11 @@ describe("Simple Aura-API", () => {
mutation: Mutation
}
type CreateInfo {
nodesCreated: Int!
relationshipsCreated: Int!
}
type Movie {
title: String
}
Expand All @@ -335,11 +335,6 @@ describe("Simple Aura-API", () => {
node: MovieSort
}
type MovieCreateInfo {
nodesCreated: Int!
relationshipsCreated: Int!
}
input MovieCreateInput {
node: MovieCreateNode!
}
Expand All @@ -349,7 +344,7 @@ describe("Simple Aura-API", () => {
}
type MovieCreateResponse {
info: MovieCreateInfo
info: CreateInfo
movies: [Movie!]!
}
Expand Down
Loading

0 comments on commit ae9ab22

Please sign in to comment.