-
Notifications
You must be signed in to change notification settings - Fork 0
GraphQL learning
DUONG Phu-Hiep edited this page May 26, 2022
·
3 revisions
type Wallet {
alias: String! @id
balance: Float!
ins: [P2P!] @hasInverse(field: "to")
outs: [P2P!] @hasInverse(field: "from")
}
type P2P {
id: ID!
from: Wallet!
to: Wallet!
amount: Float!
}
/* *************************** */
mutation Create2Wallets {
walletA: addWallet(input: {alias: "a", balance: 100}) {
numUids
wallet {
alias
balance
}
}
walletB: addWallet(input: {alias: "b", balance: 100}) {
numUids
wallet {
alias
balance
}
}
}
mutation CreateP2P($sender, ) {
addP2P(input: {from: {alias: "a"}, to: {alias: "b"}, amount: 3}) {
p2P {
id
from {
alias
balance
}
to {
alias
balance
}
}
}
sender: updateWallet(input: {filter: {alias: {eq: "a"}}, set: {balance: 97}}) {
wallet {
balance
}
}
receiver: updateWallet(input: {filter: {alias: {eq: "a"}}, set: {balance: 103}}) {
wallet {
balance
}
}
}
/****/
fragment infoWalletBalance on Wallet {
alias
balance
}
query getBalances($walletA: String!, $walletB: String!) {
walletA: getWallet(alias: $walletA) {
...infoWalletBalance
}
walletB: getWallet(alias: $walletB) {
...infoWalletBalance
}
}
type Product {
productID: ID!
name: String @search(by:[term])
reviews: [Review] @hasInverse(field:about)
}
type Customer {
username: String! @search(by:[hash,regexp]) @id
reviews: [Review] @hasInverse(field:by)
}
type Review {
id: ID!
about: Product!
by: Customer!
comment: String @search(by:[fulltext])
rating: Int @search
}
type Person {
username: String!
likedPost: [Post]
likesComments: [Comment]
authoredPosts: [Post]
authoredComments: [Comment]
}
type Post {
id: ID
title: String!
date: DateTime!
author: Person!
comments: [Comment]
likedBy: [Person]
}
type Comment {
id: ID
text: String!
datetime: DateTime!
author: Person!
onPost: Post
replyTo: Comment
hasReplies: [Comment]
likedBy: [Person]
}