Skip to content

Commit

Permalink
feat(api-headless-cms): optional validation (#3562)
Browse files Browse the repository at this point in the history
  • Loading branch information
brunozoric committed Oct 23, 2023
1 parent ed3ef6a commit 26edf52
Show file tree
Hide file tree
Showing 20 changed files with 570 additions and 129 deletions.
403 changes: 403 additions & 0 deletions apps/api/graphql/src/test.ts

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions packages/api-aco/__tests__/snapshots/customAppsSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const createCustomAppsSchemaSnapshot = () => {
}
input AcoSearchRecordCustomTestingApp_LocationInput {
folderId: String!
folderId: String
}
input AcoSearchRecordCustomTestingApp_Data_IdentityInput {
Expand All @@ -155,11 +155,11 @@ export const createCustomAppsSchemaSnapshot = () => {
input AcoSearchRecordCustomTestingAppCreateInput {
id: ID
type: String!
title: String!
type: String
title: String
content: String
location: AcoSearchRecordCustomTestingApp_LocationInput!
data: AcoSearchRecordCustomTestingApp_DataInput!
location: AcoSearchRecordCustomTestingApp_LocationInput
data: AcoSearchRecordCustomTestingApp_DataInput
tags: [String!]
}
Expand Down
10 changes: 5 additions & 5 deletions packages/api-aco/__tests__/snapshots/defaultAppsSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const createDefaultAppsSchemaSnapshot = () => {
}
input AcoSearchRecordWebiny_LocationInput {
folderId: String!
folderId: String
}
input AcoSearchRecordWebiny_Data_IdentityInput {
Expand All @@ -129,11 +129,11 @@ export const createDefaultAppsSchemaSnapshot = () => {
input AcoSearchRecordWebinyCreateInput {
id: ID
type: String!
title: String!
type: String
title: String
content: String
location: AcoSearchRecordWebiny_LocationInput!
data: AcoSearchRecordWebiny_DataInput!
location: AcoSearchRecordWebiny_LocationInput
data: AcoSearchRecordWebiny_DataInput
tags: [String!]
}
Expand Down
8 changes: 4 additions & 4 deletions packages/api-file-manager/__tests__/mocks/file.sdl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ export default /* GraphQL */ `
input FmFileCreateInput {
id: ID!
location: FmFile_LocationInput
name: String!
key: String!
type: String!
size: Number!
name: String
key: String
type: String
size: Number
meta: FmFile_MetaInput
tags: [String!]
aliases: [String!]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,30 +140,6 @@ describe("fieldValidations", () => {
}
}
});

/**
* GraphQL response must break when not sending required value.
*/
const [requiredResponse] = await createFruit({
data: {
...defaultFruitData,
name: undefined
}
});

expect(requiredResponse).toEqual({
errors: [
{
message: expect.any(String),
locations: [
{
column: expect.any(Number),
line: expect.any(Number)
}
]
}
]
});
});
/**
* testing minLength and maxLength of the array
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,10 @@ describe("Republish entries", () => {
category: {
entryId: applePublished.id,
modelId: categoryModel.modelId
}
},
price: 1,
color: "red",
image: "https://webiny.com/gala.png"
});
const { entry: goldenEntry } = createEntry(
productModel,
Expand All @@ -305,7 +308,10 @@ describe("Republish entries", () => {
category: {
entryId: bananaPublished.id,
modelId: categoryModel.modelId
}
},
price: 1,
color: "white",
image: "https://webiny.com/golden.png"
},
5
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export default /* GraphQL */ `
input CategoryApiNameWhichIsABitDifferentThanModelIdInput {
id: ID
wbyAco_location: WbyAcoLocationInput
title: String!
slug: String!
title: String
slug: String
}
input CategoryApiNameWhichIsABitDifferentThanModelIdGetWhereInput {
Expand Down Expand Up @@ -158,11 +158,11 @@ export default /* GraphQL */ `
}
extend type Mutation {
createCategoryApiNameWhichIsABitDifferentThanModelId(data: CategoryApiNameWhichIsABitDifferentThanModelIdInput!): CategoryApiNameWhichIsABitDifferentThanModelIdResponse
createCategoryApiNameWhichIsABitDifferentThanModelId(data: CategoryApiNameWhichIsABitDifferentThanModelIdInput!, options: CreateCmsEntryOptionsInput): CategoryApiNameWhichIsABitDifferentThanModelIdResponse
createCategoryApiNameWhichIsABitDifferentThanModelIdFrom(revision: ID!, data: CategoryApiNameWhichIsABitDifferentThanModelIdInput): CategoryApiNameWhichIsABitDifferentThanModelIdResponse
createCategoryApiNameWhichIsABitDifferentThanModelIdFrom(revision: ID!, data: CategoryApiNameWhichIsABitDifferentThanModelIdInput, options: CreateRevisionCmsEntryOptionsInput): CategoryApiNameWhichIsABitDifferentThanModelIdResponse
updateCategoryApiNameWhichIsABitDifferentThanModelId(revision: ID!, data: CategoryApiNameWhichIsABitDifferentThanModelIdInput!): CategoryApiNameWhichIsABitDifferentThanModelIdResponse
updateCategoryApiNameWhichIsABitDifferentThanModelId(revision: ID!, data: CategoryApiNameWhichIsABitDifferentThanModelIdInput!, options: UpdateCmsEntryOptionsInput): CategoryApiNameWhichIsABitDifferentThanModelIdResponse
moveCategoryApiNameWhichIsABitDifferentThanModelId(revision: ID!, folderId: ID!): CategoryApiNameWhichIsABitDifferentThanModelIdMoveResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export default /* GraphQL */ `
}
input PageModelApiName_Content_HeroInput {
title: String!
title: String
}
input PageModelApiName_Content_SimpleTextInput {
Expand Down Expand Up @@ -257,7 +257,7 @@ export default /* GraphQL */ `
}
input PageModelApiName_Content_AuthorInput {
author: RefFieldInput!
author: RefFieldInput
authors: [RefFieldInput!]
}
Expand Down Expand Up @@ -437,16 +437,18 @@ export default /* GraphQL */ `
}
extend type Mutation {
createPageModelApiName(data: PageModelApiNameInput!): PageModelApiNameResponse
createPageModelApiName(data: PageModelApiNameInput!, options: CreateCmsEntryOptionsInput): PageModelApiNameResponse
createPageModelApiNameFrom(
revision: ID!
data: PageModelApiNameInput
options: CreateRevisionCmsEntryOptionsInput
): PageModelApiNameResponse
updatePageModelApiName(
revision: ID!
data: PageModelApiNameInput!
options: UpdateCmsEntryOptionsInput
): PageModelApiNameResponse
movePageModelApiName(revision: ID!, folderId: ID!): PageModelApiNameMoveResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export default /* GraphQL */ `
name: String
price: Number
image: String
category: RefFieldInput!
category: RefFieldInput
categories: [RefFieldInput]
longText: [String]
}
Expand All @@ -149,27 +149,27 @@ export default /* GraphQL */ `
name: String
price: Number
images: [String]
category: RefFieldInput!
category: RefFieldInput
options: [ProductApiSingular_Variant_OptionsInput!]
}
input ProductApiSingular_FieldsObjectInput {
text: String!
text: String
}
input ProductApiSingularInput {
id: ID
wbyAco_location: WbyAcoLocationInput
title: String!
category: RefFieldInput!
price: Number!
title: String
category: RefFieldInput
price: Number
inStock: Boolean
itemsInStock: Number
availableOn: Date
color: String!
color: String
availableSizes: [String!]
image: String!
image: String
richText: JSON
variant: ProductApiSingular_VariantInput
fieldsObject: ProductApiSingular_FieldsObjectInput
Expand Down Expand Up @@ -360,11 +360,11 @@ export default /* GraphQL */ `
}
extend type Mutation {
createProductApiSingular(data: ProductApiSingularInput!): ProductApiSingularResponse
createProductApiSingular(data: ProductApiSingularInput!, options: CreateCmsEntryOptionsInput): ProductApiSingularResponse
createProductApiSingularFrom(revision: ID!, data: ProductApiSingularInput): ProductApiSingularResponse
createProductApiSingularFrom(revision: ID!, data: ProductApiSingularInput, options: CreateRevisionCmsEntryOptionsInput): ProductApiSingularResponse
updateProductApiSingular(revision: ID!, data: ProductApiSingularInput!): ProductApiSingularResponse
updateProductApiSingular(revision: ID!, data: ProductApiSingularInput!, options: UpdateCmsEntryOptionsInput): ProductApiSingularResponse
moveProductApiSingular(revision: ID!, folderId: ID!): ProductApiSingularMoveResponse
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default /* GraphQL */ `
input ReviewApiModelInput {
id: ID
wbyAco_location: WbyAcoLocationInput
text: String!
text: String
product: RefFieldInput
rating: Number
author: RefFieldInput
Expand Down Expand Up @@ -170,11 +170,11 @@ export default /* GraphQL */ `
}
extend type Mutation {
createReviewApiModel(data: ReviewApiModelInput!): ReviewApiModelResponse
createReviewApiModel(data: ReviewApiModelInput!, options: CreateCmsEntryOptionsInput): ReviewApiModelResponse
createReviewApiModelFrom(revision: ID!, data: ReviewApiModelInput): ReviewApiModelResponse
createReviewApiModelFrom(revision: ID!, data: ReviewApiModelInput, options: CreateRevisionCmsEntryOptionsInput): ReviewApiModelResponse
updateReviewApiModel(revision: ID!, data: ReviewApiModelInput!): ReviewApiModelResponse
updateReviewApiModel(revision: ID!, data: ReviewApiModelInput!, options: UpdateCmsEntryOptionsInput): ReviewApiModelResponse
moveReviewApiModel(revision: ID!, folderId: ID!): ReviewApiModelMoveResponse
Expand Down

0 comments on commit 26edf52

Please sign in to comment.