-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
@graphql-hive/importer and point to exact syntax error while parsing …
…config (#462) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
5b69bdd
commit 9a6ae85
Showing
30 changed files
with
587 additions
and
34 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,8 @@ | ||
--- | ||
'@graphql-hive/gateway': patch | ||
--- | ||
|
||
dependencies updates: | ||
|
||
- Added dependency [`@graphql-hive/importer@workspace:^` ↗︎](https://www.npmjs.com/package/@graphql-hive/importer/v/workspace:^) (to `dependencies`) | ||
- Removed dependency [`@graphql-mesh/include@^0.2.3` ↗︎](https://www.npmjs.com/package/@graphql-mesh/include/v/0.2.3) (from `dependencies`) |
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,5 @@ | ||
--- | ||
'@graphql-hive/gateway': patch | ||
--- | ||
|
||
Use `@graphql-hive/importer` for importing configs and transpiling TypeScript files |
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,5 @@ | ||
--- | ||
'@graphql-hive/gateway': minor | ||
--- | ||
|
||
Point to exact location of syntax error when parsing malformed config files |
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,5 @@ | ||
--- | ||
'@graphql-hive/importer': major | ||
--- | ||
|
||
Improving Hive's importing capabilities allowing it to parse TypeScript files |
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,38 @@ | ||
import { createTenv } from '@internal/e2e'; | ||
import { isCI } from '@internal/testing'; | ||
import { expect, it } from 'vitest'; | ||
|
||
const { gateway, service, gatewayRunner } = createTenv(__dirname); | ||
|
||
it.skipIf( | ||
// for whatever reason docker in CI sometimes (sometimes is the keyword, more than less) | ||
// doesnt provide all the logs and throws errors with weird messages and I dont know where from or why | ||
// see https://github.com/graphql-hive/gateway/actions/runs/12830196184/job/35777821364 | ||
isCI() && gatewayRunner === 'docker', | ||
)( | ||
'should point to exact location of syntax error when parsing a malformed config', | ||
async () => { | ||
await expect( | ||
gateway({ | ||
supergraph: { | ||
with: 'mesh', | ||
services: [await service('hello')], | ||
}, | ||
runner: { | ||
docker: { | ||
volumes: [ | ||
{ | ||
host: 'custom-resolvers.ts', | ||
container: '/gateway/custom-resolvers.ts', | ||
}, | ||
], | ||
}, | ||
}, | ||
}), | ||
).rejects.toThrowError( | ||
gatewayRunner === 'bun' || gatewayRunner === 'bun-docker' | ||
? /error: Expected "{" but found "hello"(.|\n)*\/custom-resolvers.ts:8:11/ | ||
: /SyntaxError \[Error\]: Error transforming .*(\/|\\)custom-resolvers.ts: Unexpected token, expected "{" \(8:11\)/, | ||
); | ||
}, | ||
); |
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,12 @@ | ||
// @ts-nocheck -- syntax error intentionally | ||
|
||
import { GatewayContext } from '@graphql-hive/gateway'; | ||
import { IResolvers } from '@graphql-tools/utils'; | ||
|
||
export const customResolvers: IResolvers<unknown, GatewayContext> = { | ||
Query: { | ||
bye() hello { | ||
return 'world'; | ||
}, | ||
}, | ||
}; |
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,6 @@ | ||
import { defineConfig } from '@graphql-hive/gateway'; | ||
import { customResolvers } from './custom-resolvers'; | ||
|
||
export const gatewayConfig = defineConfig({ | ||
additionalResolvers: [customResolvers], | ||
}); |
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,22 @@ | ||
import { | ||
defineConfig, | ||
loadGraphQLHTTPSubgraph, | ||
} from '@graphql-mesh/compose-cli'; | ||
import { Opts } from '@internal/testing'; | ||
|
||
const opts = Opts(process.argv); | ||
|
||
export const composeConfig = defineConfig({ | ||
subgraphs: [ | ||
{ | ||
sourceHandler: loadGraphQLHTTPSubgraph('hello', { | ||
endpoint: `http://localhost:${opts.getServicePort('hello')}/graphql`, | ||
}), | ||
}, | ||
], | ||
additionalTypeDefs: /* GraphQL */ ` | ||
extend type Query { | ||
bye: String! | ||
} | ||
`, | ||
}); |
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,10 @@ | ||
{ | ||
"name": "@e2e/config-syntax-error", | ||
"private": true, | ||
"dependencies": { | ||
"@graphql-mesh/compose-cli": "^1.2.13", | ||
"@graphql-tools/utils": "^10.7.2", | ||
"graphql": "^16.9.0", | ||
"tslib": "^2.8.1" | ||
} | ||
} |
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,23 @@ | ||
import { createServer } from 'http'; | ||
import { Opts } from '@internal/testing'; | ||
import { createSchema, createYoga } from 'graphql-yoga'; | ||
|
||
const opts = Opts(process.argv); | ||
|
||
createServer( | ||
createYoga({ | ||
maskedErrors: false, | ||
schema: createSchema<any>({ | ||
typeDefs: /* GraphQL */ ` | ||
type Query { | ||
hello: String! | ||
} | ||
`, | ||
resolvers: { | ||
Query: { | ||
hello: () => 'world', | ||
}, | ||
}, | ||
}), | ||
}), | ||
).listen(opts.getServicePort('hello')); |
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
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
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
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,7 @@ | ||
# @graphql-hive/importer | ||
|
||
Used to improve Hive's importing capabilities allowing it to parse TypeScript files. | ||
|
||
Please note that `get-tsconfig` and `sucrase` are **intentionally** inside devDependencies at the [package.json](/packages/mporter/package.json) because we want to bundle them in. | ||
|
||
[pkgroll will bundle all devDependencies that are used in the source code.](https://github.com/privatenumber/pkgroll?tab=readme-ov-file#dependency-bundling--externalization) |
Oops, something went wrong.