Skip to content

Commit

Permalink
Merge pull request #12 from fernando-apollo/main
Browse files Browse the repository at this point in the history
WIP connectors module and module reset
  • Loading branch information
ausimity authored Jan 24, 2025
2 parents 19908a9 + f3ab9d4 commit 9cdafea
Show file tree
Hide file tree
Showing 58 changed files with 3,087 additions and 357 deletions.
File renamed without changes.
59 changes: 59 additions & 0 deletions .github/post/apollo-connectors/orders-schema.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
extend schema
@link(
url: "https://specs.apollo.dev/federation/v2.10"
import: ["@key", "@tag", "@shareable"]
)
@link(
url: "https://specs.apollo.dev/connect/v0.1"
import: ["@connect", "@source"]
)
@source(
name: "api"
http: { baseURL: "https://rest-api-j3nprurqka-uc.a.run.app/api" }
)

type Query {
"""
Get a specific order by id. Meant to be used for a detailed view of an order
"""
order(id: ID!): Order
@connect(
source: "api"
http: { GET: "/orders/{$args.id}" }
selection: """
id
buyer: { id: $.customerId }
items: $.variantIds { id: $ }
"""
entity: true
)
}

"""
Returns information about a specific purchase
"""
type Order @key(fields: "id") {
"""
Each order has a unique id which is separate from the user or items they bought
"""
id: ID!

"""
The user who made the purchase
"""
buyer: User!

"""
A list of all the items they purchased. This is the Variants, not the Products so we know exactly which
product and which size/color/feature was bought
"""
items: [ProductVariant!]!
}

type User @key(fields: "id") {
id: ID!
}

type ProductVariant @key(fields: "id", resolvable: false) {
id: ID!
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ include_subgraph_errors:
all: true # Propagate errors from all subgraphs

subscription:
enabled: true
mode:
passthrough:
# docker setup, for local setup comment out the following section
subgraphs:
# docker setup, for local setup comment out the following section
subgraphs:
products:
path: /

## Enter Workshop Module Configs Below
path: /
## Enter Workshop Module Configs Below
File renamed without changes.
41 changes: 41 additions & 0 deletions .github/post/authn-and-authz/orders-schema.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
extend schema
@link(
url: "https://specs.apollo.dev/federation/v2.8"
import: ["@key", "@tag", "@shareable", "@authenticated", "@requiresScopes"]
)

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

"""
Returns information about a specific purchase
"""
type Order @key(fields: "id") {
"""
Each order has a unique id which is separate from the user or items they bought
"""
id: ID!

"""
The user who made the purchase
"""
buyer: User! @requiresScopes(scopes: [["order:buyer"]])

"""
A list of all the items they purchased. This is the Variants, not the Products so we know exactly which
product and which size/color/feature was bought
"""
items: [ProductVariant!]! @requiresScopes(scopes: [["order:items"]])
}

type User @key(fields: "id") {
id: ID!
}

type ProductVariant @key(fields: "id", resolvable: false) {
id: ID!
}
File renamed without changes.
45 changes: 45 additions & 0 deletions .github/post/authn-and-authz/router.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Configuration of the router's HTTP server
# Default configuration for container
supergraph:
# The socket address and port to listen on
listen: 0.0.0.0:${env.PORT:-4000}
introspection: true

# For demo purposes - can remove or enable homepage
sandbox:
enabled: true
homepage:
enabled: false

cors:
origins:
- https://studio.apollographql.com
allow_credentials: true

# This would make debugging easier, but should be a per subgraph basis for production
include_subgraph_errors:
all: true # Propagate errors from all subgraphs

subscription:
enabled: true
mode:
passthrough:
# docker setup, for local setup comment out the following section
subgraphs:
products:
path: /

## Enter Workshop Module Configs Below
## Authentication and Authorization Module
authentication:
router:
jwt:
header_name: Authorization
header_value_prefix: Bearer
jwks:
- url: https://www.googleapis.com/service_accounts/v1/jwk/[email protected]

authorization:
require_authentication: false
preview_directives:
enabled: true
83 changes: 83 additions & 0 deletions .github/post/coprocessor/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!
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
extend schema
@link(url: "https://specs.apollo.dev/federation/v2.8", import:
[
"@key",
"@tag"
]
@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 @@ -25,7 +23,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 Down
Loading

0 comments on commit 9cdafea

Please sign in to comment.