jamiehalvorson
01/10/2019, 9:36 PMconst recommended: Class[] = await prisma
.classes({
// checks
})
.$fragment(`
fragment Example on Class {
id
heroImage { // This is the relation
public_id
}
}
`);
However, when I then loop through recommended
and try to access heroImage
I get Property 'heroImage' does not exist on type 'Class'
.
When I try to access a single class
it works fine, e.g:
const example = await prisma.class({ id: "123" }).heroImage();
const exampleHeroID = example.public_id
Any help or pointers to the right docs would be greatly appreciatedbrentsoles
01/10/2019, 9:46 PMbrentsoles
01/10/2019, 9:46 PMbrentsoles
01/10/2019, 9:47 PMjamiehalvorson
01/10/2019, 9:51 PM{ title: 'Class Two Example', heroImage: null, duration: 1900 }
Yeah the interface for Class
doesn’t include `heroImage`:
export interface Class {
id: ID_Output;
title: String;
lowerTitle?: String;
createdAt: DateTimeOutput;
updatedAt: DateTimeOutput;
description?: String;
active: Boolean;
focus?: String;
duration?: Int;
videoURL?: String;
featured?: Boolean;
image?: String;
difficulty?: DIFFICULTY;
}
In my schema it looks a little like:
type Class {
id: ID!
heroImage: File
}
type File {
id: ID
public_id: String
}
brentsoles
01/11/2019, 3:42 PM{...
heroImage: object,
...}
to the interface definition. Also, make sure that you have not defined heroImage as a function. In you example that works, you are calling heroImage as a function, which as far as I know is not support in the graphql spec/primsa, but I could be wrong. Does that help?jamiehalvorson
01/11/2019, 4:40 PMconst example = await prisma
.$graphql(`
query recommendedClasses {
classes {
id
title
duration
heroImage {
public_id
}
}
}`
)
When I look at what’s generated from prisma-client I can see that heroImage is a function, previously this didn’t matter and I could access it. Not sure if I’ve done something wrong as now I need to update a lot of my code.brentsoles
01/11/2019, 5:03 PMjamiehalvorson
01/12/2019, 4:35 PM