-
Notifications
You must be signed in to change notification settings - Fork 332
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@graphql-mesh/include): Library for importing and transpiling Ty…
…peScript and JavaScript module during runtime (#7427) Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
4aa256b
commit 8be81d2
Showing
50 changed files
with
547 additions
and
128 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,6 @@ | ||
--- | ||
"@graphql-mesh/cli": patch | ||
--- | ||
dependencies updates: | ||
- Added dependency [`@graphql-mesh/include@^0.0.0` ↗︎](https://www.npmjs.com/package/@graphql-mesh/include/v/0.0.0) (to `dependencies`) | ||
- Removed dependency [`jiti@^1.21.6` ↗︎](https://www.npmjs.com/package/jiti/v/1.21.6) (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,6 @@ | ||
--- | ||
"@graphql-mesh/compose-cli": patch | ||
--- | ||
dependencies updates: | ||
- Added dependency [`@graphql-mesh/include@^0.0.0` ↗︎](https://www.npmjs.com/package/@graphql-mesh/include/v/0.0.0) (to `dependencies`) | ||
- Removed dependency [`jiti@^1.21.6` ↗︎](https://www.npmjs.com/package/jiti/v/1.21.6) (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,6 @@ | ||
--- | ||
"@graphql-mesh/serve-cli": patch | ||
--- | ||
dependencies updates: | ||
- Added dependency [`@graphql-mesh/include@^0.0.0` ↗︎](https://www.npmjs.com/package/@graphql-mesh/include/v/0.0.0) (to `dependencies`) | ||
- Removed dependency [`jiti@^1.21.6` ↗︎](https://www.npmjs.com/package/jiti/v/1.21.6) (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,7 @@ | ||
--- | ||
'@graphql-mesh/compose-cli': patch | ||
'@graphql-mesh/serve-cli': patch | ||
'@graphql-mesh/cli': patch | ||
--- | ||
|
||
Resolve tsconfig paths when importing 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-mesh/include': patch | ||
--- | ||
|
||
Library for importing and transpiling TypeScript and JavaScript module during runtime |
89 changes: 89 additions & 0 deletions
89
e2e/tsconfig-paths/__snapshots__/tsconfig-paths.test.ts.snap
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,89 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`should compose 1`] = ` | ||
" | ||
schema | ||
@link(url: "https://specs.apollo.dev/link/v1.0") | ||
@link(url: "https://specs.apollo.dev/join/v0.3", for: EXECUTION) | ||
{ | ||
query: Query | ||
} | ||
directive @join__enumValue(graph: join__Graph!) repeatable on ENUM_VALUE | ||
directive @join__field( | ||
graph: join__Graph | ||
requires: join__FieldSet | ||
provides: join__FieldSet | ||
type: String | ||
external: Boolean | ||
override: String | ||
usedOverridden: Boolean | ||
) repeatable on FIELD_DEFINITION | INPUT_FIELD_DEFINITION | ||
directive @join__graph(name: String!, url: String!) on ENUM_VALUE | ||
directive @join__implements( | ||
graph: join__Graph! | ||
interface: String! | ||
) repeatable on OBJECT | INTERFACE | ||
directive @join__type( | ||
graph: join__Graph! | ||
key: join__FieldSet | ||
extension: Boolean! = false | ||
resolvable: Boolean! = true | ||
isInterfaceObject: Boolean! = false | ||
) repeatable on OBJECT | INTERFACE | UNION | ENUM | INPUT_OBJECT | SCALAR | ||
directive @join__unionMember(graph: join__Graph!, member: String!) repeatable on UNION | ||
scalar join__FieldSet | ||
directive @link( | ||
url: String | ||
as: String | ||
for: link__Purpose | ||
import: [link__Import] | ||
) repeatable on SCHEMA | ||
scalar link__Import | ||
enum link__Purpose { | ||
""" | ||
\`SECURITY\` features provide metadata necessary to securely resolve fields. | ||
""" | ||
SECURITY | ||
""" | ||
\`EXECUTION\` features provide metadata necessary for operation execution. | ||
""" | ||
EXECUTION | ||
} | ||
enum join__Graph { | ||
HELLOWORLD @join__graph(name: "helloworld", url: "") | ||
} | ||
type Query @join__type(graph: HELLOWORLD) { | ||
hello: 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,13 @@ | ||
import { GraphQLObjectType, GraphQLSchema, GraphQLString } from 'graphql'; | ||
|
||
export const schema = new GraphQLSchema({ | ||
query: new GraphQLObjectType({ | ||
name: 'Query', | ||
fields: { | ||
hello: { | ||
type: GraphQLString, | ||
resolve: () => '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,14 @@ | ||
// @ts-expect-error | ||
import { schema } from '@e2e/tsconfig-paths/schema'; | ||
import { defineConfig } from '@graphql-mesh/compose-cli'; | ||
|
||
export const composeConfig = defineConfig({ | ||
subgraphs: [ | ||
{ | ||
sourceHandler: () => ({ | ||
name: 'helloworld', | ||
schema$: schema, | ||
}), | ||
}, | ||
], | ||
}); |
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,40 @@ | ||
import { createTenv } from '@e2e/tenv'; | ||
|
||
const { compose, serve } = createTenv(__dirname); | ||
|
||
it('should compose', async () => { | ||
const proc = await compose({ | ||
env: { | ||
MESH_INCLUDE_TSCONFIG_NAME: 'tsconfig-paths.tsconfig.json', | ||
}, | ||
}); | ||
expect(proc.result).toMatchSnapshot(); | ||
}); | ||
|
||
it('should serve', async () => { | ||
const proc = await serve({ | ||
env: { | ||
MESH_INCLUDE_TSCONFIG_NAME: 'tsconfig-paths.tsconfig.json', | ||
}, | ||
runner: { | ||
docker: { | ||
volumes: [ | ||
{ | ||
host: './tsconfig-paths.tsconfig.json', | ||
container: '/serve/tsconfig-paths.tsconfig.json', | ||
}, | ||
{ | ||
host: './mesh.config.ts', | ||
container: '/serve/mesh.config.ts', | ||
}, | ||
{ | ||
host: './folder', | ||
container: '/serve/folder', | ||
}, | ||
], | ||
}, | ||
}, | ||
}); | ||
const res = await fetch(`http://0.0.0.0:${proc.port}/healthcheck`); | ||
expect(res.ok).toBeTruthy(); | ||
}); |
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 @@ | ||
// we use jsconfig.json because tsx picks up tsconfig.json and we want to make sure Mesh runtime does it instead | ||
{ | ||
"compilerOptions": { | ||
"paths": { | ||
"@e2e/tsconfig-paths/*": ["./folder/*"] | ||
} | ||
} | ||
} |
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,72 @@ | ||
{ | ||
"name": "@graphql-mesh/include", | ||
"version": "0.0.0", | ||
"type": "module", | ||
"repository": { | ||
"type": "git", | ||
"url": "ardatan/graphql-mesh", | ||
"directory": "packages/include" | ||
}, | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">=16.0.0" | ||
}, | ||
"main": "dist/cjs/index.js", | ||
"module": "dist/esm/index.js", | ||
"exports": { | ||
".": { | ||
"require": { | ||
"types": "./dist/typings/index.d.cts", | ||
"default": "./dist/cjs/index.js" | ||
}, | ||
"import": { | ||
"types": "./dist/typings/index.d.ts", | ||
"default": "./dist/esm/index.js" | ||
}, | ||
"default": { | ||
"types": "./dist/typings/index.d.ts", | ||
"default": "./dist/esm/index.js" | ||
} | ||
}, | ||
"./register-tsconfig-paths": { | ||
"require": { | ||
"types": "./dist/typings/register-tsconfig-paths.d.cts", | ||
"default": "./dist/cjs/register-tsconfig-paths.js" | ||
}, | ||
"import": { | ||
"types": "./dist/typings/register-tsconfig-paths.d.ts", | ||
"default": "./dist/esm/register-tsconfig-paths.js" | ||
}, | ||
"default": { | ||
"types": "./dist/typings/register-tsconfig-paths.d.ts", | ||
"default": "./dist/esm/register-tsconfig-paths.js" | ||
} | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"typings": "dist/typings/index.d.ts", | ||
"dependencies": { | ||
"dotenv": "^16.3.1", | ||
"get-tsconfig": "^4.7.6", | ||
"jiti": "^1.21.6" | ||
}, | ||
"devDependencies": { | ||
"glob": "^11.0.0" | ||
}, | ||
"publishConfig": { | ||
"access": "public", | ||
"directory": "dist" | ||
}, | ||
"sideEffects": false, | ||
"buildOptions": { | ||
"bin": { | ||
"mesh-compose": { | ||
"input": "src/bin.ts" | ||
} | ||
}, | ||
"./package.json": "./package.json" | ||
}, | ||
"typescript": { | ||
"definition": "dist/typings/index.d.ts" | ||
} | ||
} |
Oops, something went wrong.