decaporg / decaporg/decap-cms

Delete image from CMS admin breaks GraphQL queries

Open
#7,186 3 comments 0 reactions 0 assignees View on GitHub
graphql type: bug
Dominant language
JavaScript
Stars
19.4k
Forks
3.1k
Avg merge
1d 14h
Merged PRs (30d)
9

Description

Hello
i created a simple image field at cms
when i deleted the image from cms admin
its sets to empty on my json file
{ image:"} and start to got this error message
Field "image" must not have a selection since type "String" has no subfields Please replace with a clear and descriptive title
from graphql queries at page
there is a way to tell the widget to remove the field from json file

i already have the custom type defined
gastby-node.js

at exports.createSchemaCustomization
like this
```
type MemberCompanyNode {
id: String
big_logo: String
name: String
}

type CompanyNode {
image: File @fileByRelativePath
paragraph1: String
paragraph2: String
link: String
memberCompany: MemberCompanyNode
}

type OSFMemberNode {
osfMember: CompanyNode
}

type MemberSpotLiteSectionJson implements Node {
companies: [OSFMemberNode]
}
```
and graphql query at page is

```
memberSpotliteSectionJson {
companies {
osfMember {
image {
publicURL
}
link
memberCompany {
big_logo
}
paragraph1
paragraph2
}
}
}
```
also i tried to create a custom resolver
at gastby node.js
exports.createResolvers
```

createResolvers({

MemberSpotliteSectionJsonCompaniesOsfMember: {
image: {
type: "File",
resolve: (source) => {
console.log(`MemberSpotliteSectionJsonCompaniesOsfMember`,source.image)
(source?.image?.publicURL ? source.image : {publicURL:null})
},
},
},
});

but i got warn `createResolvers` passed resolvers for field `MemberSpotliteSectionJsonCompaniesOsfMember.image` with type `File`. Such a field with type `String` already exists on the type. Use `createTypes` to override type
fields.

really i am stuck at this
there is no simple way to delete an image at CMS and keep it working ?
much thanks

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.