Skip to content

Delete image from CMS admin breaks GraphQL queries #7186

@smarcet

Description

@smarcet

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugcode to address defects in shipped code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions