-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into progressive-override
- Loading branch information
Showing
11 changed files
with
336 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Run Subgraph Check and Publish | ||
|
||
on: | ||
push: | ||
paths: | ||
- '**.graphql' | ||
workflow_dispatch: | ||
workflow_call: | ||
|
||
env: | ||
GEN: ${{ secrets.GEN || 'ws1' }} | ||
APOLLO_KEY: ${{ vars.TOKEN }} | ||
|
||
jobs: | ||
checks: | ||
uses: ./.github/workflows/subgraph-check.yml | ||
secrets: inherit | ||
publish: | ||
needs: checks | ||
uses: ./.github/workflows/publish-subgraph.yml | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,79 +1,89 @@ | ||
name: Create Studio Account | ||
name: Setup Studio Account | ||
|
||
on: | ||
create: | ||
push: | ||
workflow_run: | ||
workflows: ["Initial Setup"] | ||
types: | ||
- completed | ||
|
||
env: | ||
GEN: ${{ secrets.GEN || 'ws1' }} | ||
APOLLO_KEY: ${{ secrets.APOLLO_USER_KEY }} | ||
|
||
jobs: | ||
create: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Create Graph in Apollo Studio | ||
run: | | ||
echo "GITHUB_ACTOR: $GITHUB_ACTOR" | ||
curl --request POST 'https://graphql.api.apollographql.com' \ | ||
--header 'content-type: application/json' \ | ||
--header 'X-API-Key: user:fp.d88ba77d-487c-4b97-9780-f1e4c5352a22:_60kU_wi1yLH1zt60UhxGg' \ | ||
--data '{"query":"mutation Mutation($accountId: ID!, $graphType: GraphType!, $hiddenFromUninvitedNonAdmin: Boolean!, $createGraphId: ID!, $title: String!, $variantCreationConfig: VariantCreationConfig) {\n account(id: $accountId) {\n createGraph(graphType: $graphType, hiddenFromUninvitedNonAdmin: $hiddenFromUninvitedNonAdmin, id: $createGraphId, title: $title, variantCreationConfig: $variantCreationConfig) {\n __typename\n ... on Service {\n __typename\n id\n }\n ... on GraphCreationError {\n __typename\n message\n }\n }\n }\n}","variables":{"accountId":"summit-2023-enterprise-workshop","graphType":"SELF_HOSTED_SUPERGRAPH","hiddenFromUninvitedNonAdmin":false,"createGraphId":"${{github.actor}}-2023","title":"${{github.actor}}","variantCreationConfig":{"variantName":"current","buildConfigInput":{"apiDirectivePassThrough":[],"buildPipelineTrack":null,"composition":{"subgraphs":[]}}}}}' | ||
keys: | ||
publish: | ||
uses: ./.github/workflows/publish-subgraph.yml | ||
secrets: inherit | ||
|
||
pqs: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Create Apollo Key | ||
run: | | ||
curl --request POST 'https://graphql.api.apollographql.com' \ | ||
--header 'content-type: application/json' \ | ||
--header 'X-API-Key: ${{ secrets.APOLLO_USER_KEY }}' \ | ||
--data '{"query":"mutation Mutation($graphId: ID!, $keyName: String, $role: UserPermission!) {\n graph(id: $graphId) {\n newKey(keyName: $keyName, role: $role) {\n token\n }\n }\n}","variables":{"graphId":"${{github.actor}}-2023","keyName":"my-first-key","role":"CONTRIBUTOR"}}' -o token.json | ||
cat token.json | ||
- name: Retrieve Apollo Key | ||
run: | | ||
echo "Add code to extract token and save as a github secret" | ||
- name: Create PQ List | ||
run: | | ||
curl --request POST \ | ||
--header 'content-type: application/json' \ | ||
--header 'X-API-Key: ${{ secrets.APOLLO_USER_KEY }}' \ | ||
--url 'https://graphql.api.apollographql.com/api/graphql' \ | ||
--data '{"query":"mutation Mutation($graphId: ID!, $name: String!, $description: String, $linkedVariants: [String!]) {\n graph(id: $graphId) {\n createPersistedQueryList(name: $name, description: $description, linkedVariants: $linkedVariants) {\n ... on CreatePersistedQueryListResult {\n persistedQueryList {\n id\n createdAt\n }\n }\n }\n }\n}","variables":{"graphId":"${{vars.ACTOR}}${{ env.GEN }}","name":"pq_list","description":"Our PQ List","linkedVariants":["current"]}}' -o pq.json | ||
cat pq.json | ||
publish: | ||
runs-on: ubuntu-latest | ||
- name: Set Env | ||
run: echo "PQ_ID=$(cat pq.json | jq .data.graph.createPersistedQueryList.persistedQueryList.id)" >> $GITHUB_ENV | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Install Rover | ||
run: | | ||
curl -sSL https://rover.apollo.dev/nix/v0.19.0 | sh | ||
echo "$HOME/.rover/bin" >> $GITHUB_PATH | ||
- name: Install Rover | ||
run: | | ||
curl -sSL https://rover.apollo.dev/nix/v0.8.1 | sh | ||
echo "$HOME/.rover/bin" >> $GITHUB_PATH | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Rover Subgraph Publish Products | ||
run: | | ||
rover subgraph publish ${{secrets.APOLLO_GRAPH_REF }} \ | ||
--name products \ | ||
--routing-url https://https://subgraph-products-j3nprurqka-ue.a.run.app \ | ||
--schema ./products-schema.graphql | ||
- name: Publish PQ List | ||
run: | | ||
rover persisted-queries publish --graph-id ${{vars.ACTOR}}${{env.GEN}} --list-id ${{env.PQ_ID}} \ | ||
--manifest ./final/workshop-pq-manifest.json | ||
- name: Rover Subgraph Publish Orders | ||
run: | | ||
rover subgraph publish ${{secrets.APOLLO_GRAPH_REF}} \ | ||
--name orders | ||
--routing-url https://subgraph-orders-j3nprurqka-ue.a.run.app \ | ||
--schema ./orders-schema.graphql | ||
deploy: | ||
needs: publish | ||
uses: ./.github/workflows/deploy-router.yml | ||
secrets: inherit | ||
|
||
- name: Rover Subgraph Publish Customers | ||
run: | | ||
rover subgraph publish ${{secrets.APOLLO_GRAPH_REF}} \ | ||
--name customers | ||
--routing-url https://subgraph-customers-j3nprurqka-ue.a.run.app \ | ||
--schema ./final/customers-schema.graphql | ||
install-url: | ||
needs: deploy | ||
runs-on: ubuntu-latest | ||
steps: | ||
- id: "auth" | ||
uses: "google-github-actions/auth@v0" | ||
with: | ||
credentials_json: ${{ secrets.GCP_CREDENTIALS }} | ||
- name: Get URL | ||
run: | | ||
gcloud run services describe ${{vars.ACTOR}}-router --region us-central1 --format 'value(status.url)' > url.json | ||
echo "URL=$(cat url.json)" >> $GITHUB_ENV | ||
- name: Set URL | ||
run: | | ||
curl --request POST \ | ||
--header 'content-type: application/json' \ | ||
--header 'X-API-Key: ${{ secrets.APOLLO_USER_KEY }}' \ | ||
--url 'https://graphql.api.apollographql.com/api/graphql' \ | ||
--data '{"query":"mutation UpdateURL($name: String!, $graphId: ID!, $url: String) {\n graph(id: $graphId) {\n variant(name: $name) {\n updateURL(url: $url) {\n createdAt\n }\n }\n }\n}","variables":{"name":"current","graphId":"${{vars.ACTOR}}${{ env.GEN }}","url":"${{ env.URL }}"}}' | ||
pqs: | ||
- name: Set Subscription URL | ||
run: | | ||
curl --request POST \ | ||
--header 'content-type: application/json' \ | ||
--header 'X-API-Key: ${{ secrets.APOLLO_USER_KEY }}' \ | ||
--url 'https://graphql.api.apollographql.com/api/graphql' \ | ||
--data '{"query":"mutation Mutation($graphId: ID!, $name: String!, $subscriptionUrl: String) {\n graph(id: $graphId) {\n variant(name: $name) {\n updateSubscriptionURL(subscriptionUrl: $subscriptionUrl) {\n createdAt\n }\n }\n }\n}","variables":{"graphId":"${{vars.ACTOR}}${{ env.GEN }}","name":"current","subscriptionUrl":"${{ env.URL }}"}}' | ||
preflightScript: | ||
needs: publish | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Create PQ List | ||
- name: Create PreFlight Script | ||
run: | | ||
echo "Add Curl Command to create PQ List" | ||
- name: Publish PQ List | ||
run: | | ||
rover persisted-queries publish Summit-SE-Workshop@current \ | ||
--manifest ./workshop-pq-manifest.json | ||
curl --request POST \ | ||
--header 'content-type: application/json' \ | ||
--header 'X-API-Key: ${{ secrets.APOLLO_USER_KEY }}' \ | ||
--url 'https://graphql.api.apollographql.com/api/graphql' \ | ||
--data '{"query":"mutation Mutation($graphId: ID!, $name: String!, $preflightScript: String) {\n graph(id: $graphId) {\n variant(name: $name) {\n updatePreflightScript(preflightScript: $preflightScript) {\n createdAt\n }\n }\n }\n}","variables":{"graphId":"${{vars.ACTOR}}${{ env.GEN }}","name":"current","preflightScript":"console.log(\"fetching new token.....\");const getToken=async e=>{let o=await explorer.fetch(\"https:\/\/proxy-j3nprurqka-uc.a.run.app/authn\",{method:\"POST\",header:{\"Content-Type\":\"application\/json\"},body:JSON.stringify({email:e,password:\"apolloworkshop\",returnSecureToken:!0})});return o.json()},authorizedCredentials=await getToken(\"[email protected]\"),{idToken:authorizedToken}=authorizedCredentials;explorer.environment.set(\"authorizedToken\",authorizedToken),console.log(\"successfully set authorized token\");const unauthorizedCredentials=await getToken(\"[email protected]\"),{idToken:unauthorizedToken}=unauthorizedCredentials;explorer.environment.set(\"unauthorizedToken\",unauthorizedToken),console.log(\"successfully set token unauthorized token\");"}}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Publish subgraphs to Apollo Studio | ||
|
||
on: | ||
workflow_dispatch: | ||
workflow_call: | ||
|
||
env: | ||
GEN: ${{ secrets.GEN || 'ws1' }} | ||
APOLLO_KEY: ${{ vars.TOKEN }} | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Rover | ||
run: | | ||
curl -sSL https://rover.apollo.dev/nix/v0.19.0 | sh | ||
echo "$HOME/.rover/bin" >> $GITHUB_PATH | ||
- name: Rover Subgraph Publish Products | ||
run: | | ||
rover subgraph publish ${{vars.ACTOR}}${{ env.GEN }}@current \ | ||
--name products \ | ||
--convert \ | ||
--routing-url https://subgraph-products-j3nprurqka-ue.a.run.app \ | ||
--schema ./products-schema.graphql | ||
- name: Rover Subgraph Publish Orders | ||
run: | | ||
rover subgraph publish ${{vars.ACTOR}}${{ env.GEN }}@current \ | ||
--name orders \ | ||
--routing-url https://subgraph-orders-j3nprurqka-ue.a.run.app \ | ||
--schema ./orders-schema.graphql | ||
- name: Rover Subgraph Publish Customers | ||
run: | | ||
rover subgraph publish ${{vars.ACTOR}}${{ env.GEN }}@current \ | ||
--name customers \ | ||
--routing-url https://subgraph-customers-j3nprurqka-ue.a.run.app \ | ||
--schema ./final/customers-schema.graphql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
|
||
name: Initial Setup | ||
|
||
on: | ||
push: | ||
paths: | ||
- '**.yml' | ||
|
||
env: | ||
GEN: ${{ secrets.GEN || 'ws1' }} | ||
|
||
jobs: | ||
create: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- id: string | ||
uses: ASzc/change-string-case-action@v5 | ||
with: | ||
string: gh-${{github.actor}} | ||
- id: step2 | ||
run: echo "ACTOR=${{ steps.string.outputs.lowercase }}" | cut -c -23 >> $GITHUB_ENV | ||
- name : lowercase github actor | ||
run: | | ||
curl -L \ | ||
-X POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer ${{ secrets.GH_KEY }}" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
https://api.github.com/repos/${{github.repository}}/actions/variables \ | ||
-d '{"name":"actor","value":"${{ env.ACTOR }}" }' | ||
- name: Create Graph in Apollo Studio | ||
run: | | ||
echo "ACTOR: ${{ env.ACTOR }}" | ||
curl --request POST 'https://graphql.api.apollographql.com' \ | ||
--header 'content-type: application/json' \ | ||
--header 'X-API-Key: ${{ secrets.APOLLO_USER_KEY }}' \ | ||
--data '{"query":"mutation Mutation($accountId: ID!, $graphType: GraphType!, $hiddenFromUninvitedNonAdmin: Boolean!, $createGraphId: ID!, $title: String!, $variantCreationConfig: VariantCreationConfig) {\n account(id: $accountId) {\n createGraph(graphType: $graphType, hiddenFromUninvitedNonAdmin: $hiddenFromUninvitedNonAdmin, id: $createGraphId, title: $title, variantCreationConfig: $variantCreationConfig) {\n __typename\n ... on Service {\n __typename\n id\n }\n ... on GraphCreationError {\n __typename\n message\n }\n }\n }\n}","variables":{"accountId":"${{ secrets.APOLLO_ACCOUNT }}","graphType":"SELF_HOSTED_SUPERGRAPH","hiddenFromUninvitedNonAdmin":false,"createGraphId":"${{env.ACTOR}}${{ env.GEN }}","title":"${{github.actor}} - ${{ env.GEN }}","variantCreationConfig":{"variantName":"current","buildConfigInput":{"apiDirectivePassThrough":[],"buildPipelineTrack":null,"composition":{"subgraphs":[]}}}}}' | ||
keys: | ||
needs: create | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Sleep | ||
run: sleep 10s | ||
shell: bash | ||
- id: string | ||
uses: ASzc/change-string-case-action@v5 | ||
with: | ||
string: gh-${{github.actor}} | ||
- id: step2 | ||
run: echo "ACTOR=${{ steps.string.outputs.lowercase }}" | cut -c -23 >> $GITHUB_ENV | ||
|
||
- name: Create Apollo Key | ||
run: | | ||
curl --request POST 'https://graphql.api.apollographql.com' \ | ||
--header 'content-type: application/json' \ | ||
--header 'X-API-Key: ${{ secrets.APOLLO_USER_KEY }}' \ | ||
--data '{"query":"mutation Mutation($graphId: ID!, $keyName: String, $role: UserPermission!) {\n graph(id: $graphId) {\n newKey(keyName: $keyName, role: $role) {\n token\n }\n }\n}","variables":{"graphId":"${{env.ACTOR}}${{ env.GEN }}","keyName":"my-first-key","role":"CONTRIBUTOR"}}' -o token.json | ||
cat token.json | ||
- name: Set Env | ||
run: echo "TOKEN=$(cat token.json | jq .data.graph.newKey.token)" >> $GITHUB_ENV | ||
|
||
- name: Retrieve Apollo Key | ||
run: | | ||
echo "Add code to extract token and save as a github secret" | ||
curl -L \ | ||
-X POST \ | ||
-H "Accept: application/vnd.github+json" \ | ||
-H "Authorization: Bearer ${{ secrets.GH_KEY }}" \ | ||
-H "X-GitHub-Api-Version: 2022-11-28" \ | ||
https://api.github.com/repos/${{github.repository}}/actions/variables \ | ||
-d '{"name":"token","value":${{ env.TOKEN }} }' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Perform subgraph check via Apollo Studio | ||
|
||
on: | ||
workflow_dispatch: | ||
workflow_call: | ||
|
||
env: | ||
GEN: ${{ secrets.GEN || 'ws1' }} | ||
APOLLO_KEY: ${{ vars.TOKEN }} | ||
|
||
jobs: | ||
checks: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Install Rover | ||
run: | | ||
curl -sSL https://rover.apollo.dev/nix/v0.19.0 | sh | ||
echo "$HOME/.rover/bin" >> $GITHUB_PATH | ||
- name: Rover Subgraph Check Products | ||
run: | | ||
rover subgraph check ${{vars.ACTOR}}${{ env.GEN }}@current \ | ||
--name products \ | ||
--schema ./products-schema.graphql | ||
- name: Rover Subgraph Check Orders | ||
run: | | ||
rover subgraph check ${{vars.ACTOR}}${{ env.GEN }}@current \ | ||
--name orders \ | ||
--schema ./orders-schema.graphql | ||
- name: Rover Subgraph Check Customers | ||
run: | | ||
rover subgraph check ${{vars.ACTOR}}${{ env.GEN }}@current \ | ||
--name customers \ | ||
--schema ./final/customers-schema.graphql |
Oops, something went wrong.