Skip to content

Seed database with relational fields #2247

Answered by Rizialdi
kurt-hardy asked this question in Q&A
Discussion options

You must be logged in to vote

Hi,
the error is basically saying that you're trying to connect to a field which is not found.
You cannot connect to canada, instead, you should connect to a reference to canada in your database.
Try to change:

const on = await prisma.region.create({ data: { name: 'on', country: { connect: canada } } });

to

const on = await prisma.region.create({ data: { name: 'on', country: { connect: { id: 's4f5d45sd45sd' } } });
// with s4f5d45sd45sd is a Unique Identifier for a field in Country type
// namely *id* in your case 
Unknown arg name in data.country.connect.name for type CountryWhereUniqueInput. Did you mean id? Available args:
type CountryWhereUniqueInput {
id?: String // <- the only avail…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by kurt-hardy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants