Skip to content

Commit 9990ac2

Browse files
authored
fix(api-server): handle path names with 'graphql' (#12055)
When this repo changed name from 'redwood' to 'graphql' GitHub also changed the path for the project on its runners. With the new repo name the paths look like this: ```js serverFunctions: [ '/home/runner/work/graphql/graphql/packages/api-server/src/__tests__/fixtures/redwood-app/api/dist/functions/env.js', '/home/runner/work/graphql/graphql/packages/api-server/src/__tests__/fixtures/redwood-app/api/dist/functions/graphql.js', '/home/runner/work/graphql/graphql/packages/api-server/src/__tests__/fixtures/redwood-app/api/dist/functions/health.js', '/home/runner/work/graphql/graphql/packages/api-server/src/__tests__/fixtures/redwood-app/api/dist/functions/hello.js', '/home/runner/work/graphql/graphql/packages/api-server/src/__tests__/fixtures/redwood-app/api/dist/functions/noHandler.js', '/home/runner/work/graphql/graphql/packages/api-server/src/__tests__/fixtures/redwood-app/api/dist/functions/nested/nested.js' ] ``` Previously the code was looking for paths that included `'graphql'` to find the graphql function. The problem is that the paths now all include `'graphql'`. So this PR changes the code to look for paths that ends with `'graphql.js'` to find the graphql function
1 parent 48b7472 commit 9990ac2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/api-server/src/plugins/lambdaLoader.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,12 @@ export const loadFunctionsFromDist = async (
6666
)
6767

6868
// Place `GraphQL` serverless function at the start.
69-
const i = serverFunctions.findIndex((x) => x.includes('graphql'))
69+
const i = serverFunctions.findIndex((x) => x.endsWith('graphql.js'))
7070
if (i >= 0) {
7171
const graphQLFn = serverFunctions.splice(i, 1)[0]
7272
serverFunctions.unshift(graphQLFn)
7373
}
74+
7475
await setLambdaFunctions(serverFunctions)
7576
}
7677

0 commit comments

Comments
 (0)