Could somebody help me with this? I'm trying to so...
# orm-help
g
Could somebody help me with this? I'm trying to solve this problem for a few days but I cannot find the solution :(( https://www.prisma.io/forum/t/i-get-wrong-result-after-mutation/3850
j
You're never passing
info
to the prisma mutation, so any subquery is omitted. return await context.prisma.mutation.createActionMember( { data: { person: { connect: { id: member.personId, }, }, side: member.side, }, }, info );
g
@Jenkins now it returns just ID
well, at least this ID is this just created action's ID
j
Riiiiight. Mb. You have to pass a custom info to it then. You can write it within backticks.
Copy code
{
    id
    person { ... }
    ...
}
Like that or something 🙂 This goes where you would normally put info.
g
But I need to pass this type:
Copy code
type ActionMember {
  id: ID! @unique
  person: Person!
  side: String!
}
not just id
j
Because
info
for you is just
id
and
title
, where ActionMember only has
id
. I didn't look well enough at your query.
Luckily prisma allows you to specify your desired data back in backticks 🙂 prisma cool
g
Could u, pleeease, explain better? 🙂 I don't really understand it 😞
u mean try to do like this?
Copy code
mutation {
  createAction(
    title: "title"
    date: "date"
    description: "description"
    karma: "positive"
    executors: "left"
    members: [
      {
        personId: "cjizku6oowzhj0b17phm2yd6z"
        side: "left"
      }
    ]
  ) {
    id
    title
    members {
      person {
        id
      }
      side
    }
  }
}
j
I'll show you. Give me a lil time to fix a paste.
g
sure, take ur time, please
j
Unsure if you need the
{ }
inside the
g
yea, it works, but a little bit different that it should
I don't really understand how I can return this:
Copy code
ActionMember {
  id: ID! @unique
  person: Person!
  side: String!
}
because this doesn't works 😞
Copy code
`{
            id
            person
            side
          }`
I tried to do this but it didn't work either:
Copy code
`{
            id
            person {
              id
              name
              position
              karma
              description
              author {
                id
                email
                password
                nickname
                name
                createdAt
                updatedAt
              }
            }
            side
          }`
j
You need to specify which fields you want on person...
Copy code
person {
    some
    fields
}
Ok.
Try taking the initial
{
and
}
away. I.e.
Copy code
id
person {}
side
g
Syntax Error: Expected Name, found }
j
Give me 2 min.
Just checked, you do need the {} pair around.
Do you get anything when using the query you posted 1 message back?
g
Copy code
`{
            id
            person {
              id
              name
              position
              karma
              description
              author {
                id
                email
                password
                nickname
                name
                createdAt
                updatedAt
              }
            }
            side
          }`
this one?
j
Mm.
Well, afaik you did get the data from the first query... Let me check your second.
g
which one exactly?
j
I can see from your last screenshot that the mutation did go through as it has been logged to your screen (after the Promise.all). Does it look like the data you were expecting?
g
I guess, but I still have this error:
Field "0" is not defined by type ActionMemberCreateManyInput at value.members.
I guess output should be like this http://prntscr.com/k0oxbu
j
I believe that error with "Field 0", might be from the second mutation you run. Let me have a look again.
g
but it says
ActionMemberCreateManyInput at value.members.
. I guess it means that error in
members
j
Yes. Can I see the schema for Action?
g
and if i try to pass, for example, 3 members, i will have such erros for each field
sure
Copy code
type Action {
  id: ID! @unique
  title: String!
  date: String!
  description: String
  karma: String!
  executors: String!
  members: [ActionMember!]!
  author: User!
}
Copy code
type ActionMember {
  id: ID! @unique
  person: Person!
  side: String!
}
Copy code
type User {
  id: ID! @unique
  email: String! @unique
  password: String!
  nickname: String! @unique
  name: String
  createdAt: DateTime!
  updatedAt: DateTime!
}

type Person {
  id: ID! @unique
  name: String!
  position: String!
  karma: Int!
  description: String
  author: User!
}
j
Yeah. You're passing the ActionMember model instead of connecting the ID. So where you do
Copy code
{
    members: resolvedMembers
}
you should connect the IDs instead.
g
But I need to connect to all IDs, it should be something like this, right?
Copy code
members: resolvedMembers.map((member) => {
              return {
                connect: {
                  id: member.id,
                },
              };
            }),
j
Yes!
I think you might have it there.
g
aw, still the same 😞
i guess i need to do it in another way
j
Ait! Sorry I can't be of more help mate.
I'm fairly new to GraphQL myself. Only really started a couple months back.
g
okay, thank u so much! U helped me a lot, I need only to finish it a little bit 🙂
j
Ait, glhf!
❤️ 1
g
@Jenkins omg, it works!!!! thank u so much again, bro :)))
j
Woooop! GZ! And no problem - anytime!
g
everything I needed is to connect like this:
Copy code
members: {
              connect: resolvedMembersIds,
            },
haha, u cannot imagine how happy I'm 😄
j
I'm glad you are! Happy hacking!
g
thanks, u too! 🙂
n
Can you please write an answer to the Forum post, @Gorodov Maksim? 🙂
This will help others facing a similar problem.
g
@nilan sure 🙂