or do i have something completely wrong because i ...
# prisma-whats-new
s
or do i have something completely wrong because i think too restlike?
m
@Simon I don't quite follow what you are trying to do. So the gameSession object already exists in the db and you want to connect it to MrX's user profile?
s
well, actually no, i want to create anew mrx and connect him to the gamesession
m
oh so you want to run
Copy code
ctx.db.mutation.updateUser({ 
where: { id: userId},
data: { gameSession: { connect: { id: gameSessionId}}})
or something like that
s
ah ok, did not know about the connect, i will try this one out
see the docs in the link
I'm not sure if my syntax is 100% correct
@Simon in the docs they have the following
Copy code
mutation {
  createUser(
    data: {
      email: "<mailto:zeus@example.com|zeus@example.com>"
      name: "Zeus"
      age: 42
      posts: {
        create: [{
          published: true
          title: "First blog post"
        }, {
          published: true
          title: "Second blog post"
        }]
        connect: [{
          id: "cjcdi63j80adw0146z7r59bn5"
        }, {
          id: "cjcdi63l80ady014658ud1u02"
        }]
      }
    }
  ) {
    id
    posts {
      id
    }
  }
}
So you could do:
Copy code
ctx.db.mutation.createUser(
data: { 
name: name
gameSession: { connect: { id: gameSessionId}
})
s
way easiert than expected 😉
m
great
s
thanks so far!
quick follow up question:
i now have a
createMrXInGameSession(parent, {gameSessionId, name}, context: Context, info) {
signature and call it with
createMrXInGameSession(gameSessionId: ID!, name: String!): MrX
i use it in the schema like this
but it does not resolve the signature
is the signature wrong somehow_
m
what do you mean by signature?
are you using graphql-yoga?
s
no
i mean the signature of my resolver
the resolver somehow does not “connect” to the schema
m
so when you call
createMrXInGameSession(gameSessionId: ID!, name: String!): MrX
it's not call your resolver function?
createMrXInGameSession(parent, {gameSessionId, name}, context: Context, info) {
I would recommend starting with this tutorial https://www.howtographql.com/graphql-js/1-getting-started/
s
hmmm, nevermind, it worked but the autocomplete did not
thanks!