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

Add mocks for a basic set of operations to work with GraphOS demo #94

Merged
merged 43 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e473af0
Create mock datasource for subscriptions
michael-watson Jul 18, 2023
738a2b3
Remove flat mocks file from playback
michael-watson Jul 18, 2023
9a26660
Fix error when no operation name
michael-watson Jul 18, 2023
f7dd75d
Change mocks to use referrer for user id
michael-watson Jul 19, 2023
3402560
Use origin to identify the identifier
michael-watson Jul 19, 2023
324d9f0
Definitely use referrer
michael-watson Jul 19, 2023
e3c4881
Update mocks.ts
michael-watson Jul 19, 2023
9a1bbc9
Implement mock framework
michael-watson Jul 19, 2023
0954d73
Add local development onConnect catch
michael-watson Jul 20, 2023
b0080d7
log context
michael-watson Jul 20, 2023
94db36c
Update mocks.ts
michael-watson Jul 20, 2023
758c7ab
Use x-graphos-id to identify users
michael-watson Jul 20, 2023
9ca88cf
Add tests to cover mocks for demo
michael-watson Jul 20, 2023
cb0c58a
Merge branch 'main' into mock-subscriptions
michael-watson Jul 20, 2023
84c3137
Fix prefix
michael-watson Jul 20, 2023
6d6e704
Implement sentry in subgraphs
michael-watson Jul 20, 2023
d5e01c5
Use spotify types as much as possible for user state
jerelmiller Jul 20, 2023
d80a2b3
Extract playback state to separate interface type
jerelmiller Jul 20, 2023
d39cb3f
Ensure new user playback state is instantiated when missing vs sharin…
jerelmiller Jul 20, 2023
8bff48f
Remove console log
jerelmiller Jul 20, 2023
968007b
Ensure resolve is called for getDevices
jerelmiller Jul 20, 2023
43a73c8
Add helper findOrCreatePlaybackState and call in constructor of mock …
jerelmiller Jul 20, 2023
39bf59c
Use Promise.resolve shorthand in mocks
jerelmiller Jul 20, 2023
258123b
Add braces around all if conditions
jerelmiller Jul 20, 2023
1eba379
Use early returns to make some conditionals easier
jerelmiller Jul 20, 2023
c46e7e5
Use async keyword on all mocks functions and return simple primitives
jerelmiller Jul 20, 2023
4b2cc4e
Remove addUser function now that state is instantiated in constructor
jerelmiller Jul 20, 2023
dc7252d
Remove need to store "default" user playback state
jerelmiller Jul 20, 2023
400307b
Remove unused import
jerelmiller Jul 20, 2023
3a002ca
Add spaces between methods
jerelmiller Jul 20, 2023
609ef9a
Make all mock functions async in spotify subgraph
jerelmiller Jul 20, 2023
9ac8554
Add braces around if statement
jerelmiller Jul 21, 2023
6f8d91b
Add constant for max progress
jerelmiller Jul 21, 2023
7021ae3
Add demo markdown
michael-watson Jul 24, 2023
337a6d7
Merge branch 'mock-subscriptions' of https://github.com/apollographql…
michael-watson Jul 24, 2023
ab0f90f
Update .apollo/router-config.yaml
michael-watson Jul 25, 2023
1e4920a
Update docs/serverless-demo.md
michael-watson Jul 25, 2023
0cf89bf
Update docs/serverless-demo.md
michael-watson Jul 25, 2023
e346be0
Update subgraphs/spotify/src/index.ts
michael-watson Jul 25, 2023
7f58980
Update docs/serverless-demo.md
michael-watson Jul 25, 2023
410242b
remove client id from client
michael-watson Jul 25, 2023
8259a99
Use graph ref
michael-watson Jul 25, 2023
1e628b2
Update serverless-demo.md
michael-watson Jul 25, 2023
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
26 changes: 16 additions & 10 deletions .apollo/router-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,20 @@ apq:
# enabled: true

#####################
# Uncomment the following to enable local subscriptions. You must have an
# enterprise account or enterprise trial to use this.
# Uncomment the following to enable local subscriptions.
michael-watson marked this conversation as resolved.
Show resolved Hide resolved
# You must have an enterprise account or enterprise trial to run the Apollo Router locally.
michael-watson marked this conversation as resolved.
Show resolved Hide resolved
#####################
# subscription:
# mode:
# preview_callback:
# public_url: http://0.0.0.0:4000/callback # The router's public URL
# listen: 0.0.0.0:${env.PORT:-4000} # The IP address and port the router will listen on for subscription callbacks
# path: /callback # The path of the router's callback endpoint
# subgraphs: # The list of subgraphs that use the HTTP callback protocol
# - playback
subscription:
mode:
## Uncomment 'passthrough' to try Websockets at the /ws route using graphql-ws
# passthrough:
# all:
# path: /ws
## Uncomment 'preview_callback' to try HTTP callback protocal at the /graphql
michael-watson marked this conversation as resolved.
Show resolved Hide resolved
## https://www.apollographql.com/docs/router/executing-operations/subscription-callback-protocol
preview_callback:
public_url: http://0.0.0.0:4000/callback # The router's public URL
listen: 0.0.0.0:${env.PORT:-4000} # The IP address and port the router will listen on for subscription callbacks
path: /callback # The path of the router's callback endpoint
subgraphs: # The list of subgraphs that use the HTTP callback protocol
- playback
6 changes: 5 additions & 1 deletion .github/workflows/playback_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ jobs:
echo "$HOME/.rover/bin" >> $GITHUB_PATH
- if: env.APOLLO_KEY != ''
run: rover subgraph check Spotify-tb7du2@prod --schema ./subgraphs/playback/schema.graphql --name playback
env:
APOLLO_VCS_COMMIT: ${{ github.event.pull_request.head.sha }}
check_playback_builds:
name: Check server compiles
name: Build and Unit Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -32,6 +34,8 @@ jobs:
run: npm install --prefix=subgraphs/playback
- name: Check server compiles
run: npm run build --prefix=subgraphs/playback
- name: Run unit tests
run: npm run test --prefix=subgraphs/playback
check_playback_typescript:
name: Check TypeScript
runs-on: ubuntu-latest
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/spotify_checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ jobs:
echo "$HOME/.rover/bin" >> $GITHUB_PATH
- if: env.APOLLO_KEY != ''
run: rover subgraph check Spotify-tb7du2@prod --schema ./subgraphs/spotify/schema.graphql --name spotify
env:
APOLLO_VCS_COMMIT: ${{ github.event.pull_request.head.sha }}
check_spotify_builds:
name: Check server compiles
name: Build and Unit Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -32,6 +34,8 @@ jobs:
run: npm install --prefix=subgraphs/spotify
- name: Check server compiles
run: npm run build --prefix=subgraphs/spotify
- name: Run unit tests
run: npm run test --prefix=subgraphs/spotify
check_spotify_typescript:
name: Check TypeScript
runs-on: ubuntu-latest
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ dist
.netlify

router/router
router/*.graphql
router/*.graphql

**/pnpm-lock.yaml
2 changes: 2 additions & 0 deletions client/.env.development
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
VITE_SERVER_HOST=https://spotify-showcase-production-d157.up.railway.app/
# You will need to add your client_id from the Spotify Developer Portal if you don't want mocked data
michael-watson marked this conversation as resolved.
Show resolved Hide resolved
# https://developer.spotify.com/dashboard
VITE_SPOTIFY_CLIENT_ID=f29edb16e8cc4dd1ba897ad146750fa2
Loading