-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsupergraph.graphql
More file actions
226 lines (190 loc) · 6.86 KB
/
supergraph.graphql
File metadata and controls
226 lines (190 loc) · 6.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
schema
@link(url: "https://specs.apollo.dev/link/v1.0")
@link(url: "https://specs.apollo.dev/join/v0.5", for: EXECUTION)
@link(url: "https://specs.apollo.dev/tag/v0.3", import: ["@tag"])
{
query: Query
mutation: Mutation
}
directive @join__directive(graphs: [join__Graph!], name: String!, args: join__DirectiveArguments) repeatable on SCHEMA | OBJECT | INTERFACE | FIELD_DEFINITION
directive @join__enumValue(graph: join__Graph!) repeatable on ENUM_VALUE
directive @join__field(graph: join__Graph, requires: join__FieldSet, provides: join__FieldSet, type: String, external: Boolean, override: String, usedOverridden: Boolean, overrideLabel: String, contextArguments: [join__ContextArgument!]) repeatable on FIELD_DEFINITION | INPUT_FIELD_DEFINITION
directive @join__graph(name: String!, url: String!) on ENUM_VALUE
directive @join__implements(graph: join__Graph!, interface: String!) repeatable on OBJECT | INTERFACE
directive @join__type(graph: join__Graph!, key: join__FieldSet, extension: Boolean! = false, resolvable: Boolean! = true, isInterfaceObject: Boolean! = false) repeatable on OBJECT | INTERFACE | UNION | ENUM | INPUT_OBJECT | SCALAR
directive @join__unionMember(graph: join__Graph!, member: String!) repeatable on UNION
directive @link(url: String, as: String, for: link__Purpose, import: [link__Import]) repeatable on SCHEMA
directive @tag(name: String!) repeatable on FIELD_DEFINITION | OBJECT | INTERFACE | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION | SCHEMA
type AllBankAccounts
@join__type(graph: ACCOUNTS)
@tag(name: "bankAccounts")
{
all: [BankAccount]
checking: [BankAccount]
savings: [BankAccount]
}
type BankAccount
@join__type(graph: ACCOUNTS, key: "id")
@join__type(graph: CREDIT, key: "id")
@join__type(graph: TRANSACTIONS, key: "id")
{
id: ID!
name: String @join__field(graph: ACCOUNTS)
type: BankAccountType @join__field(graph: ACCOUNTS)
tier: BankAccountTier @join__field(graph: ACCOUNTS)
user: User @join__field(graph: ACCOUNTS)
availableCredit: Int @join__field(graph: CREDIT)
transactions: [Transaction] @join__field(graph: TRANSACTIONS)
balance: Int @join__field(graph: TRANSACTIONS)
}
enum BankAccountTier
@join__type(graph: ACCOUNTS)
{
BASIC @join__enumValue(graph: ACCOUNTS)
PREMIUM @join__enumValue(graph: ACCOUNTS)
VIP @join__enumValue(graph: ACCOUNTS)
}
enum BankAccountType
@join__type(graph: ACCOUNTS)
{
CHECKING @join__enumValue(graph: ACCOUNTS)
SAVINGS @join__enumValue(graph: ACCOUNTS)
}
enum CreditApplicationStatus
@join__type(graph: CREDIT)
{
PENDING @join__enumValue(graph: CREDIT)
APPROVED @join__enumValue(graph: CREDIT)
DECLINED @join__enumValue(graph: CREDIT)
}
type CreditCardApplication
@join__type(graph: CREDIT, key: "id")
{
id: ID!
customer: User
yearlyEarnings: Int
totalDebt: Int
monthlyExpenses: Int
status: CreditApplicationStatus
}
type CreditCardApplicationResponse
@join__type(graph: CREDIT)
{
message: String
success: Boolean
application: CreditCardApplication
}
type InsufficientFundsError
@join__type(graph: TRANSACTIONS)
{
message: String
}
input join__ContextArgument {
name: String!
type: String!
context: String!
selection: join__FieldValue!
}
scalar join__DirectiveArguments
scalar join__FieldSet
scalar join__FieldValue
enum join__Graph {
ACCOUNTS @join__graph(name: "accounts", url: "http://localhost:4001/accounts/graphql")
CREDIT @join__graph(name: "credit", url: "http://localhost:4001/credit/graphql")
RISK @join__graph(name: "risk", url: "http://localhost:4001/risk/graphql")
TRANSACTIONS @join__graph(name: "transactions", url: "http://localhost:4001/transactions/graphql")
USERS @join__graph(name: "users", url: "http://localhost:4001/users/graphql")
}
scalar link__Import
enum link__Purpose {
"""
`SECURITY` features provide metadata necessary to securely resolve fields.
"""
SECURITY
"""
`EXECUTION` features provide metadata necessary for operation execution.
"""
EXECUTION
}
type Mutation
@join__type(graph: ACCOUNTS)
@join__type(graph: CREDIT)
@join__type(graph: TRANSACTIONS)
{
"""Mock opening a new checking account"""
openCheckingAccount(tier: BankAccountTier): OpenBankAccountResponse @join__field(graph: ACCOUNTS)
"""Mock opening a new savings account"""
openSavingsAccount(tier: BankAccountTier): OpenBankAccountResponse @join__field(graph: ACCOUNTS)
applyForCredit(yearlyEarnings: Int!, totalDebt: Int!, monthlyExpenses: Int!): CreditCardApplicationResponse @join__field(graph: CREDIT)
debitFromAccount(account: ID!, amount: Int!): TransactionResult @join__field(graph: TRANSACTIONS)
creditToAccount(account: ID!, amount: Int!): TransactionResult @join__field(graph: TRANSACTIONS)
withdrawFromAccount(account: ID!, amount: Int!): TransactionResult @join__field(graph: TRANSACTIONS)
transferFundsBetweenAccounts(fromAccount: ID!, toAccount: ID!, amount: Int!): TransactionResult @join__field(graph: TRANSACTIONS)
}
type OpenBankAccountResponse
@join__type(graph: ACCOUNTS)
{
message: String
success: Boolean
account: BankAccount
}
type Query
@join__type(graph: ACCOUNTS)
@join__type(graph: CREDIT)
@join__type(graph: RISK)
@join__type(graph: TRANSACTIONS)
@join__type(graph: USERS)
{
bankAccounts: AllBankAccounts @join__field(graph: ACCOUNTS)
users: [User] @join__field(graph: USERS)
user: User @join__field(graph: USERS)
}
"""
Used in the @hasRole directive to do directive-based authentication control.
See the docs for @hasRole for more info.
"""
enum Role
@join__type(graph: ACCOUNTS)
@join__type(graph: USERS)
{
ADMIN @join__enumValue(graph: ACCOUNTS) @join__enumValue(graph: USERS)
PARTNER @join__enumValue(graph: ACCOUNTS) @join__enumValue(graph: USERS)
USER @join__enumValue(graph: ACCOUNTS) @join__enumValue(graph: USERS)
UNKNOWN @join__enumValue(graph: ACCOUNTS) @join__enumValue(graph: USERS)
}
type Transaction
@join__type(graph: TRANSACTIONS, key: "id")
{
id: ID!
amount: Int
description: String
account: BankAccount
}
type TransactionApproved
@join__type(graph: TRANSACTIONS)
{
message: String
}
type TransactionDeclined
@join__type(graph: TRANSACTIONS)
{
message: String
}
union TransactionResult
@join__type(graph: TRANSACTIONS)
@join__unionMember(graph: TRANSACTIONS, member: "InsufficientFundsError")
@join__unionMember(graph: TRANSACTIONS, member: "TransactionApproved")
@join__unionMember(graph: TRANSACTIONS, member: "TransactionDeclined")
= InsufficientFundsError | TransactionApproved | TransactionDeclined
type User
@join__type(graph: ACCOUNTS, key: "id")
@join__type(graph: CREDIT, key: "id", resolvable: false)
@join__type(graph: RISK, key: "id")
@join__type(graph: USERS, key: "id")
{
id: ID!
accounts: [BankAccount] @join__field(graph: ACCOUNTS)
"""Generate a random risk rating for each user"""
riskRating: Int @join__field(graph: RISK)
name: String @join__field(graph: USERS)
}