Skip to content

Commit

Permalink
Don't make redirect query nullable, instead make the implementation fail
Browse files Browse the repository at this point in the history
  • Loading branch information
nsams committed Oct 17, 2024
1 parent 41442c3 commit ac13d48
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion demo/api/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ type Query {
sitePreviewJwt(scope: JSONObject!, path: String!, includeInvisible: Boolean!): String!
redirects(scope: RedirectScopeInput!, query: String, type: RedirectGenerationType, active: Boolean, sortColumnName: String, sortDirection: SortDirection! = ASC): [Redirect!]! @deprecated(reason: "Use paginatedRedirects instead. Will be removed in the next version.")
paginatedRedirects(scope: RedirectScopeInput!, search: String, filter: RedirectFilter, sort: [RedirectSort!], offset: Int! = 0, limit: Int! = 25): PaginatedRedirects!
redirect(id: ID!): Redirect
redirect(id: ID!): Redirect!
redirectBySource(scope: RedirectScopeInput!, source: String!, sourceType: RedirectSourceTypeValues!): Redirect
redirectSourceAvailable(scope: RedirectScopeInput!, source: String!): Boolean!
damItemsList(offset: Int! = 0, limit: Int! = 25, sortColumnName: String, sortDirection: SortDirection! = ASC, scope: DamScopeInput!, folderId: ID, includeArchived: Boolean, filter: DamItemFilterInput): PaginatedDamItems!
Expand Down
2 changes: 1 addition & 1 deletion packages/api/cms-api/schema.gql
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ type Query {
buildTemplates: [BuildTemplate!]!
redirects(scope: RedirectScopeInput! = {}, query: String, type: RedirectGenerationType, active: Boolean, sortColumnName: String, sortDirection: SortDirection! = ASC): [Redirect!]! @deprecated(reason: "Use paginatedRedirects instead. Will be removed in the next version.")
paginatedRedirects(scope: RedirectScopeInput! = {}, search: String, filter: RedirectFilter, sort: [RedirectSort!], offset: Int! = 0, limit: Int! = 25): PaginatedRedirects!
redirect(id: ID!): Redirect
redirect(id: ID!): Redirect!
redirectBySource(scope: RedirectScopeInput! = {}, source: String!, sourceType: RedirectSourceTypeValues!): Redirect
redirectSourceAvailable(scope: RedirectScopeInput! = {}, source: String!): Boolean!
damItemsList(offset: Int! = 0, limit: Int! = 25, sortColumnName: String, sortDirection: SortDirection! = ASC, scope: DamScopeInput! = {}, folderId: ID, includeArchived: Boolean, filter: DamItemFilterInput): PaginatedDamItems!
Expand Down
8 changes: 4 additions & 4 deletions packages/api/cms-api/src/redirects/redirects.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,11 @@ export function createRedirectsResolver({
return new PaginatedRedirects(entities, totalCount);
}

@Query(() => Redirect, { nullable: true })
@Query(() => Redirect)
@AffectedEntity(Redirect)
async redirect(@Args("id", { type: () => ID }) id: string): Promise<RedirectInterface | null> {
const redirect = await this.repository.findOne(id);
return redirect ?? null;
async redirect(@Args("id", { type: () => ID }) id: string): Promise<RedirectInterface> {
const redirect = await this.repository.findOneOrFail(id);
return redirect;
}

@Query(() => Redirect, { nullable: true })
Expand Down

0 comments on commit ac13d48

Please sign in to comment.