Last active
July 5, 2018 08:18
-
-
Save christianwish/e579769afc64260e8e5220f9e1fac2a7 to your computer and use it in GitHub Desktop.
graphql relation mutation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Step 1 | |
# To create a B you have to create a A first | |
mutation { | |
createA( | |
title: "first A!" | |
) { | |
id | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Step 2 | |
# Create a B with a relation to A | |
mutation makeBOrAnotherCoolFuncName ($aid: ID, $bTitle: String!) { | |
createB( | |
title: $bTitle | |
asId: $aid | |
) { | |
id | |
} | |
} | |
# Variables: | |
# { | |
# "aid": "ID_OF_AN_A", | |
# "bTitle": "My first B" | |
# } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type A @model { | |
id: ID! @isUnique | |
title: String | |
createdAt: DateTime! | |
bs: [B!]! @relation(name: "C") | |
} | |
type B @model { | |
id: ID! @isUnique | |
title: String! | |
createdAt: DateTime! | |
as: A! @relation(name: "C") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Login example:
https://github.com/graphcool-examples/react-graphql/blob/master/authentication-with-email-and-apollo/server/src/email-password/authenticate.js