Skip to content

Commit

Permalink
Load app management API schema from branch (#4857)
Browse files Browse the repository at this point in the history
### WHY are these changes introduced?

Adds support for fetching GraphQL schemas from different branches and loads the App Management API from it's branch.

### WHAT is this pull request doing?

- Adds branch configuration option for schema fetching
- Improves logging during schema fetching to show branch information

### How to test your changes?

Run `dev up` and see how the branched schema is pulled in.

### Measuring impact

- [x] n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix

### Checklist

- [x] I've considered possible cross-platform impacts (Mac, Linux, Windows)
- [x] I've considered possible [documentation](https://shopify.dev) changes
  • Loading branch information
shauns authored Nov 14, 2024
1 parent 79f78cc commit 1523815
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion bin/get-graphql-schemas.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const schemas = [
repo: 'shopify',
pathToFile: 'areas/core/shopify/db/graphql/app_management_schema_unstable_public.graphql',
localPath: './packages/app/src/cli/api/graphql/app-management/app_management_schema.graphql',
branch: 'dd',
},
{
repo: 'shopify',
Expand Down Expand Up @@ -79,12 +80,14 @@ function extractPassword(output) {
async function fetchFileForSchema(schema, octokit) {
try {
// Fetch the file content from the repository
const branch = schema.branch ?? BRANCH
console.log(`\nFetching ${OWNER}/${schema.repo}#${branch}: ${schema.pathToFile} ...`)
const {data} = await octokit.repos.getContent({
mediaType: { format: "raw" },
owner: OWNER,
repo: schema.repo,
path: schema.pathToFile,
ref: BRANCH,
ref: branch,
})

const content = Buffer.from(data).toString('utf-8')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ export type AppSourceInput = {

/** Possible error codes that can be returned by AppManagement. */
export type Code =
/** Access denied. */
| 'ACCESS_DENIED'
/** An event error. */
| 'EVENT'
/** An internal error. */
Expand Down

0 comments on commit 1523815

Please sign in to comment.