cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Error when mapping enum to internal values in resolver

Hi guys,

I have an enum in my schema that I need to map with internal values. I followed the Apollo Server documentation to do this: Custom scalars and enums - Apollo Server - Apollo GraphQL Docs. But I'm getting the error Cannot read property 'name' of undefined when I try to get any relationship in any type, even if it is not related at all with the problematic enum.
This is the enum:

//schema.graphql
enum MIMEType {
	IMAGE_PNG
	IMAGE_GIF
	IMAGE_JPEG
	AUDIO_MPEG
	AUDIO_WEBM
	AUDIO_OGG
	AUDIO_WAV
	TEXT_PLAIN
	TEXT_CSV
}
//used in this query
type Query {
	awsS3PreSignedUploadUrl(
		fileName: String!
		contentType: MIMEType!
	): PreSignedUploadUrl!
}

This is the internal value mapping in resolvers.js:

//resolvers.js
export const resolvers = {
    MIMEType: {	
		IMAGE_PNG: "image/png",	
		IMAGE_GIF: "image/gif",	
		IMAGE_JPEG: "image/jpeg",	
		AUDIO_MPEG: "audio/mpeg",	
		AUDIO_WEBM: "audio/webm",	
		AUDIO_OGG: "audio/ogg",	
		AUDIO_WAV: "audio/wav",	
		TEXT_PLAIN: "text/plain",	
		TEXT_CSV: "text/csv",	
	},
}

This seems to make sense, given the Apollo Server documentation. But when I try to access a relationship in any type (not related at all with the enum), I get the following error.

2X_9_932acb6b44f91af2d91d70c56529cf13cb22bb21.png

This is breaking my entire app. Am I doing something wrong?

0 REPLIES 0