-
Notifications
You must be signed in to change notification settings - Fork 583
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api-headless-cms): enable skipping validator by name (#3582)
- Loading branch information
1 parent
7f45c6e
commit e83640f
Showing
15 changed files
with
1,087 additions
and
97 deletions.
There are no files selected for viewing
810 changes: 810 additions & 0 deletions
810
...dless-cms/__tests__/contentAPI/cmsEntryValidation/contentEntry.optionalValidation.test.ts
Large diffs are not rendered by default.
Oops, something went wrong.
105 changes: 105 additions & 0 deletions
105
packages/api-headless-cms/__tests__/contentAPI/cmsEntryValidation/handler.graphql.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
import { CmsApiModel } from "~/plugins"; | ||
|
||
const fields = /* GraphQL */ ` | ||
id | ||
entryId | ||
savedOn | ||
createdOn | ||
createdBy { | ||
id | ||
displayName | ||
type | ||
} | ||
meta { | ||
title | ||
version | ||
} | ||
`; | ||
|
||
const ERROR = ` | ||
error { | ||
message | ||
data | ||
code | ||
stack | ||
} | ||
`; | ||
|
||
export const validateMutation = (model: Pick<CmsApiModel, "singularApiName">) => { | ||
return /* GraphQL */ ` | ||
mutation ValidateProduct($revision: ID, $data: ${model.singularApiName}Input!) { | ||
validate: validate${model.singularApiName}(revision: $revision, data: $data) { | ||
data { | ||
id | ||
fieldId | ||
error | ||
parents | ||
} | ||
${ERROR} | ||
} | ||
} | ||
`; | ||
}; | ||
|
||
export const createMutation = (model: Pick<CmsApiModel, "singularApiName">) => { | ||
return /* GraphQL */ ` | ||
mutation CreateProduct($data: ${model.singularApiName}Input!, $options: CreateCmsEntryOptionsInput) { | ||
create: create${model.singularApiName}(data: $data, options: $options) { | ||
data { | ||
${fields} | ||
} | ||
${ERROR} | ||
} | ||
} | ||
`; | ||
}; | ||
|
||
export const createRevisionMutation = (model: Pick<CmsApiModel, "singularApiName">) => { | ||
return /* GraphQL */ ` | ||
mutation CreateProductFrom($revision: ID!, $options: CreateRevisionCmsEntryOptionsInput) { | ||
createRevision: create${model.singularApiName}From(revision: $revision, options: $options) { | ||
data { | ||
${fields} | ||
} | ||
${ERROR} | ||
} | ||
} | ||
`; | ||
}; | ||
|
||
export const updateMutation = (model: Pick<CmsApiModel, "singularApiName">) => { | ||
return /* GraphQL */ ` | ||
mutation UpdateProduct($revision: ID!, $data: ${model.singularApiName}Input!, $options: UpdateCmsEntryOptionsInput) { | ||
update: update${model.singularApiName}(revision: $revision, data: $data, options: $options) { | ||
data { | ||
${fields} | ||
} | ||
${ERROR} | ||
} | ||
} | ||
`; | ||
}; | ||
|
||
export const deleteMutation = (model: Pick<CmsApiModel, "singularApiName">) => { | ||
return /* GraphQL */ ` | ||
mutation DeleteProduct($revision: ID!) { | ||
delete: delete${model.singularApiName}(revision: $revision) { | ||
data | ||
${ERROR} | ||
} | ||
} | ||
`; | ||
}; | ||
|
||
export const publishMutation = (model: Pick<CmsApiModel, "singularApiName">) => { | ||
return /* GraphQL */ ` | ||
mutation UpdateProduct($revision: ID!) { | ||
publish: publish${model.singularApiName}(revision: $revision) { | ||
data { | ||
${fields} | ||
} | ||
${ERROR} | ||
} | ||
} | ||
`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.