Skip to content

Commit

Permalink
Merge pull request #6 from apollosolutions/progressive-override
Browse files Browse the repository at this point in the history
Progressive override
  • Loading branch information
brh55 authored Sep 5, 2024
2 parents 97a3ec3 + 0058fca commit b4c44ce
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 11 deletions.
83 changes: 83 additions & 0 deletions customers-schema.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.8", import:
[
"@key",
"@requires",
"@external",
"@tag",
"@shareable"
]
)

type Query {
users: [User]
user(id: ID!): User
}

"""
An user account in our system
"""
type User @key(fields: "id") {
id: ID!

firstName: String @tag(name: "private")
lastName: String @tag(name: "private")
address: String @tag(name: "private")
phone: String
@tag(name: "private")
@shareable
email: String!
@tag(name: "private")
@shareable

"""
The user's active cart session. Once the cart items have been purchases, they transition to an Order
"""
activeCart: Cart

"""
The users previous purchases
"""
orders(filters: OrderFilters): [Order]

paymentMethods: [PaymentMethod]
}

"""
Search filters for when showing an users previous purchases
"""
input OrderFilters {
orderId: ID!
priceHigh: Float
priceLow: Float
itemsInOrder: Int
}

"""
An user's saved cart session. Only one cart can be active at a time
"""
type Cart @key(fields: "owner { id }") {
"""
Owner of the cart session
"""
owner: User!
"""
Items saved in the cart session
"""
items: [ProductVariant]
subtotal: Float! @requires(fields: "items { price }")
}

type Order @key(fields: "id", resolvable: false) {
id: ID!
}

type ProductVariant @key(fields: "id", resolvable: false) {
id: ID!
price: Float! @external
}

type PaymentMethod {
id: ID!
cardNumber: String!
}
18 changes: 15 additions & 3 deletions final/customers-schema.graphql
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.5", import: ["@key", "@requires", "@external", "@tag"])
@link(url: "https://specs.apollo.dev/federation/v2.8", import:
[
"@key",
"@requires",
"@external",
"@tag",
"@override"
]
)

type Query {
users: [User]
Expand All @@ -15,8 +23,12 @@ type User @key(fields: "id") {
firstName: String @tag(name: "private")
lastName: String @tag(name: "private")
address: String @tag(name: "private")
phone: String @tag(name: "private")
email: String! @tag(name: "private")
phone: String
@tag(name: "private")
@override(from: "orders", label: "percent(50)")
email: String!
@tag(name: "private")
@override(from: "orders", label: "percent(50)")

"""
The user's active cart session. Once the cart items have been purchases, they transition to an Order
Expand Down
18 changes: 16 additions & 2 deletions final/orders-schema.graphql
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.5", import: ["@key", "@authenticated", "@requiresScopes"])
@link(url: "https://specs.apollo.dev/federation/v2.8", import:
[
"@key",
"@tag",
"@shareable",
"@authenticated",
"@requiresScopes",
]
)

type Query {
"""
Expand Down Expand Up @@ -29,8 +37,14 @@ type Order @key(fields: "id") {
items: [ProductVariant!]! @requiresScopes(scopes: [["order:items"]])
}

type User @key(fields: "id", resolvable: false) {
type User @key(fields: "id") {
id: ID!
phone: String
@tag(name: "private")
@shareable
email: String!
@tag(name: "private")
@shareable
}

type ProductVariant @key(fields: "id", resolvable: false) {
Expand Down
2 changes: 1 addition & 1 deletion final/products-schema.graphql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.0", import: ["@key"])
@link(url: "https://specs.apollo.dev/federation/v2.8", import: ["@key"])

type Query {
"""
Expand Down
20 changes: 16 additions & 4 deletions orders-schema.graphql
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.5", import: ["@key"])
@link(url: "https://specs.apollo.dev/federation/v2.8", import:
[
"@key",
"@tag",
"@shareable"
]
)

type Query {
"""
Get a specific order by id. Meant to be used for a detailed view of an order
"""
order(id: ID!): Order
order(id: ID!): Order
}

"""
Expand All @@ -20,7 +26,7 @@ type Order @key(fields: "id") {
"""
The user who made the purchase
"""
buyer: User!
buyer: User!

"""
A list of all the items they purchased. This is the Variants, not the Products so we know exactly which
Expand All @@ -29,8 +35,14 @@ type Order @key(fields: "id") {
items: [ProductVariant!]!
}

type User @key(fields: "id", resolvable: false) {
type User @key(fields: "id") {
id: ID!
phone: String
@tag(name: "private")
@shareable
email: String!
@tag(name: "private")
@shareable
}

type ProductVariant @key(fields: "id", resolvable: false) {
Expand Down
2 changes: 1 addition & 1 deletion products-schema.graphql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.5", import: ["@key"])
@link(url: "https://specs.apollo.dev/federation/v2.8", import: ["@key"])

type Query {
"""
Expand Down

0 comments on commit b4c44ce

Please sign in to comment.