-
Notifications
You must be signed in to change notification settings - Fork 25
@graphql-hive/importer and point to exact syntax error while parsing config #462
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
Merged
Merged
Changes from all commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
a5e0d9a
repro error improvement
enisdenjo 2ca6847
introduce importer
enisdenjo 8dde1bf
move stuff around
enisdenjo 8832d62
test stuff and export filepath
enisdenjo dd85cb2
use importer
enisdenjo 580a0d6
path to importer
enisdenjo b46be27
changeset
enisdenjo 4ccb135
expect fail
enisdenjo 3a664da
changeset
enisdenjo abf0a96
leftover stack added twice
enisdenjo 4849d17
chore(dependencies): updated changesets for modified dependencies
github-actions[bot] e342262
exclude synax error files
enisdenjo 8ca68f2
skip formatting files with syntax errors
enisdenjo cd5022b
bun unit and e2e test and transpile
enisdenjo 953bd9c
no dispose if no exit
enisdenjo 3945fa6
also bun-docker
enisdenjo 59730d6
mount file to docker for e2es
enisdenjo 5bddd48
skip transpile tests when leaktest
enisdenjo 331a8ac
support windows paths
enisdenjo ce7b131
add container to stack if started
enisdenjo 79c68a0
terminate and kill - no leftover processes
enisdenjo b321b9b
throw docker errors always
enisdenjo d10e9b7
debug...
enisdenjo aafa3f0
debug
enisdenjo a22fe56
correct message
enisdenjo 8aefe13
Revert "debug"
enisdenjo 9371dc0
Revert "debug..."
enisdenjo 9119b23
retry a few times docker start
enisdenjo e3e8fac
three docker start retries is enough
enisdenjo 585ab90
break if inspect ok
enisdenjo 74a4400
check string
enisdenjo 81dd34b
debug please tell me where it's throwing
enisdenjo fa44de3
get stack
enisdenjo aaeb350
some changes
enisdenjo e06f4e2
dockererror cause
enisdenjo cb2ddae
abort ctrl if container died during healtcheck
enisdenjo 4118d9d
try ci now
enisdenjo b14f00c
terminate if pid
enisdenjo 4b845a2
skip in ci
enisdenjo 244af41
waitforexit ignore whatever exit code
enisdenjo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed because the same process was added twice to the stack.