Is there a way to define a relation when you're cr...
# prisma-whats-new
m
Is there a way to define a relation when you're creating a node? Or do you always have to create first, then do a mutation to add a relation later?
ex:
Copy code
const storyRes = await _mutate(` {
				createStory(
					title: "${yourName} & ${theirName}"
					email: "${email}"
					location: "${location}"
					canShare: ${canShare}
				) {
					id
				}
			} `);

			const storyId = storyRes.createStory.id;

			_mutate(`{
				addToStoryOnFile(storyStoryId: "${storyId}", filesFileId: "${fileId}") {
					storyStory {
						id
					}
					filesFile {
						id
					}
				}
			}`);
It'd be nice to do this all in one call
n
in this case you can just include the
filesIds
fields as an argument to
createStory
from the name, it sounds like a story can be related to many
files
, so you need to put in a list of ids
createStory(title: "${yourName}" filesIds: ["some-id"]) { id }
m
ok, i thought so, but I saw some docs somewhere that did separate mutations
I'll give that a try, thanks!
🙌 2