Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to Fed 2.8 #31

Merged
merged 2 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
700 changes: 434 additions & 266 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
"test:compile": "tsc"
},
"dependencies": {
"@apollo/server": "^4.9.4",
"@apollo/subgraph": "^2.5.6",
"@apollo/server": "^4.11.0",
"@apollo/subgraph": "^2.9.0",
"@apollosolutions/simple-auth-directive": "github:apollosolutions/simple-auth-directive",
"body-parser": "^1.20.2",
"cors": "^2.8.5",
"express": "^4.18.2",
"graphql": "^16.8.1"
"express": "^4.21.0",
"graphql": "^16.9.0"
},
"devDependencies": {
"nodemon": "^2.0.22",
Expand Down
2 changes: 2 additions & 0 deletions subgraphs/accounts/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# noinspection GraphQLTypeRedefinition
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.8", import: ["@key", "@tag"])

"""
Require that the user is authenticated and verified as a real user in our system.
Expand Down
20 changes: 2 additions & 18 deletions subgraphs/credit/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
# noinspection GraphQLTypeRedefinition
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.8", import: ["@key"])

enum CreditApplicationStatus {
PENDING
APPROVED
DECLINED
}

enum BankAccountTier {
BASIC
PREMIUM
VIP
}

enum BankAccountType {
CREDIT_CARD
}

type User @key(fields: "id", resolvable: false) {
id: ID!
}
Expand All @@ -29,14 +21,6 @@ type CreditCardApplication @key(fields: "id"){
status: CreditApplicationStatus
}

type BankAccount @key(fields: "id") {
id: ID!
type: BankAccountType
tier: BankAccountTier
balance: Int
availableCredit: Int
}

type CreditCardApplicationResponse {
message: String
success: Boolean
Expand Down
2 changes: 2 additions & 0 deletions subgraphs/risk/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# noinspection GraphQLTypeRedefinition
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.8", import: ["@key"])

type User @key(fields: "id") {
id: ID!
Expand Down
17 changes: 7 additions & 10 deletions subgraphs/transactions/schema.graphql
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# noinspection GraphQLTypeRedefinition
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.8", import: ["@key"])

enum TransactionType {
DEBIT
CREDIT
type Mutation {
debitFromAccount(account: ID!, amount: Int!): TransactionResult
creditToAccount(account: ID!, amount: Int!): TransactionResult
withdrawFromAccount(account: ID!, amount: Int!): TransactionResult
transferFundsBetweenAccounts(fromAccount: ID!, toAccount: ID!, amount: Int!): TransactionResult
}

type Transaction @key(fields: "id") {
Expand Down Expand Up @@ -31,10 +35,3 @@ type InsufficientFundsError {
}

union TransactionResult = InsufficientFundsError | TransactionApproved | TransactionDeclined

type Mutation {
debitFromAccount(account: ID!, amount: Int!): TransactionResult
creditToAccount(account: ID!, amount: Int!): TransactionResult
withdrawFromAccount(account: ID!, amount: Int!): TransactionResult
transferFundsBetweenAccounts(fromAccount: ID!, toAccount: ID!, amount: Int!): TransactionResult
}
2 changes: 1 addition & 1 deletion supergraph-config-dev.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
federation_version: =2.5.0
federation_version: =2.9.0
subgraphs:
accounts:
routing_url: http://localhost:4001/accounts/graphql
Expand Down
41 changes: 22 additions & 19 deletions supergraph.graphql
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
schema
@link(url: "https://specs.apollo.dev/link/v1.0")
@link(url: "https://specs.apollo.dev/join/v0.3", for: EXECUTION)
@link(url: "https://specs.apollo.dev/tag/v0.3")
@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) repeatable on FIELD_DEFINITION | INPUT_FIELD_DEFINITION
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

Expand Down Expand Up @@ -39,30 +41,27 @@ type BankAccount
{
id: ID!
name: String @join__field(graph: ACCOUNTS)
type: BankAccountType @join__field(graph: ACCOUNTS) @join__field(graph: CREDIT)
tier: BankAccountTier @join__field(graph: ACCOUNTS) @join__field(graph: CREDIT)
type: BankAccountType @join__field(graph: ACCOUNTS)
tier: BankAccountTier @join__field(graph: ACCOUNTS)
user: User @join__field(graph: ACCOUNTS)
balance: Int @join__field(graph: CREDIT) @join__field(graph: TRANSACTIONS)
availableCredit: Int @join__field(graph: CREDIT)
transactions: [Transaction] @join__field(graph: TRANSACTIONS)
balance: Int @join__field(graph: TRANSACTIONS)
}

enum BankAccountTier
@join__type(graph: ACCOUNTS)
@join__type(graph: CREDIT)
{
BASIC @join__enumValue(graph: ACCOUNTS) @join__enumValue(graph: CREDIT)
PREMIUM @join__enumValue(graph: ACCOUNTS) @join__enumValue(graph: CREDIT)
VIP @join__enumValue(graph: ACCOUNTS) @join__enumValue(graph: CREDIT)
BASIC @join__enumValue(graph: ACCOUNTS)
PREMIUM @join__enumValue(graph: ACCOUNTS)
VIP @join__enumValue(graph: ACCOUNTS)
}

enum BankAccountType
@join__type(graph: ACCOUNTS)
@join__type(graph: CREDIT)
{
CHECKING @join__enumValue(graph: ACCOUNTS)
SAVINGS @join__enumValue(graph: ACCOUNTS)
CREDIT_CARD @join__enumValue(graph: CREDIT)
}

enum CreditApplicationStatus
Expand Down Expand Up @@ -98,8 +97,19 @@ type InsufficientFundsError
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")
Expand Down Expand Up @@ -201,13 +211,6 @@ union TransactionResult
@join__unionMember(graph: TRANSACTIONS, member: "TransactionDeclined")
= InsufficientFundsError | TransactionApproved | TransactionDeclined

enum TransactionType
@join__type(graph: TRANSACTIONS)
{
DEBIT @join__enumValue(graph: TRANSACTIONS)
CREDIT @join__enumValue(graph: TRANSACTIONS)
}

type User
@join__type(graph: ACCOUNTS, key: "id")
@join__type(graph: CREDIT, key: "id", resolvable: false)
Expand Down
Loading