Skip to content

Commit 8be81d2

Browse files
feat(@graphql-mesh/include): Library for importing and transpiling TypeScript and JavaScript module during runtime (#7427)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent 4aa256b commit 8be81d2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+547
-128
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@graphql-mesh/cli": patch
3+
---
4+
dependencies updates:
5+
- Added dependency [`@graphql-mesh/include@^0.0.0` ↗︎](https://www.npmjs.com/package/@graphql-mesh/include/v/0.0.0) (to `dependencies`)
6+
- Removed dependency [`jiti@^1.21.6` ↗︎](https://www.npmjs.com/package/jiti/v/1.21.6) (from `dependencies`)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@graphql-mesh/compose-cli": patch
3+
---
4+
dependencies updates:
5+
- Added dependency [`@graphql-mesh/include@^0.0.0` ↗︎](https://www.npmjs.com/package/@graphql-mesh/include/v/0.0.0) (to `dependencies`)
6+
- Removed dependency [`jiti@^1.21.6` ↗︎](https://www.npmjs.com/package/jiti/v/1.21.6) (from `dependencies`)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"@graphql-mesh/serve-cli": patch
3+
---
4+
dependencies updates:
5+
- Added dependency [`@graphql-mesh/include@^0.0.0` ↗︎](https://www.npmjs.com/package/@graphql-mesh/include/v/0.0.0) (to `dependencies`)
6+
- Removed dependency [`jiti@^1.21.6` ↗︎](https://www.npmjs.com/package/jiti/v/1.21.6) (from `dependencies`)

.changeset/shiny-ways-crash.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@graphql-mesh/compose-cli': patch
3+
'@graphql-mesh/serve-cli': patch
4+
'@graphql-mesh/cli': patch
5+
---
6+
7+
Resolve tsconfig paths when importing config files

.changeset/tall-years-film.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-mesh/include': patch
3+
---
4+
5+
Library for importing and transpiling TypeScript and JavaScript module during runtime
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`should compose 1`] = `
4+
"
5+
schema
6+
@link(url: "https://specs.apollo.dev/link/v1.0")
7+
@link(url: "https://specs.apollo.dev/join/v0.3", for: EXECUTION)
8+
9+
10+
11+
12+
13+
14+
{
15+
query: Query
16+
17+
18+
}
19+
20+
21+
directive @join__enumValue(graph: join__Graph!) repeatable on ENUM_VALUE
22+
23+
directive @join__field(
24+
graph: join__Graph
25+
requires: join__FieldSet
26+
provides: join__FieldSet
27+
type: String
28+
external: Boolean
29+
override: String
30+
usedOverridden: Boolean
31+
) repeatable on FIELD_DEFINITION | INPUT_FIELD_DEFINITION
32+
33+
directive @join__graph(name: String!, url: String!) on ENUM_VALUE
34+
35+
directive @join__implements(
36+
graph: join__Graph!
37+
interface: String!
38+
) repeatable on OBJECT | INTERFACE
39+
40+
directive @join__type(
41+
graph: join__Graph!
42+
key: join__FieldSet
43+
extension: Boolean! = false
44+
resolvable: Boolean! = true
45+
isInterfaceObject: Boolean! = false
46+
) repeatable on OBJECT | INTERFACE | UNION | ENUM | INPUT_OBJECT | SCALAR
47+
48+
directive @join__unionMember(graph: join__Graph!, member: String!) repeatable on UNION
49+
50+
scalar join__FieldSet
51+
52+
53+
directive @link(
54+
url: String
55+
as: String
56+
for: link__Purpose
57+
import: [link__Import]
58+
) repeatable on SCHEMA
59+
60+
scalar link__Import
61+
62+
enum link__Purpose {
63+
"""
64+
\`SECURITY\` features provide metadata necessary to securely resolve fields.
65+
"""
66+
SECURITY
67+
68+
"""
69+
\`EXECUTION\` features provide metadata necessary for operation execution.
70+
"""
71+
EXECUTION
72+
}
73+
74+
75+
76+
77+
78+
79+
80+
enum join__Graph {
81+
HELLOWORLD @join__graph(name: "helloworld", url: "")
82+
}
83+
84+
type Query @join__type(graph: HELLOWORLD) {
85+
hello: String
86+
}
87+
88+
"
89+
`;
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { GraphQLObjectType, GraphQLSchema, GraphQLString } from 'graphql';
2+
3+
export const schema = new GraphQLSchema({
4+
query: new GraphQLObjectType({
5+
name: 'Query',
6+
fields: {
7+
hello: {
8+
type: GraphQLString,
9+
resolve: () => 'world',
10+
},
11+
},
12+
}),
13+
});

e2e/tsconfig-paths/mesh.config.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// @ts-expect-error
2+
import { schema } from '@e2e/tsconfig-paths/schema';
3+
import { defineConfig } from '@graphql-mesh/compose-cli';
4+
5+
export const composeConfig = defineConfig({
6+
subgraphs: [
7+
{
8+
sourceHandler: () => ({
9+
name: 'helloworld',
10+
schema$: schema,
11+
}),
12+
},
13+
],
14+
});
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { createTenv } from '@e2e/tenv';
2+
3+
const { compose, serve } = createTenv(__dirname);
4+
5+
it('should compose', async () => {
6+
const proc = await compose({
7+
env: {
8+
MESH_INCLUDE_TSCONFIG_NAME: 'tsconfig-paths.tsconfig.json',
9+
},
10+
});
11+
expect(proc.result).toMatchSnapshot();
12+
});
13+
14+
it('should serve', async () => {
15+
const proc = await serve({
16+
env: {
17+
MESH_INCLUDE_TSCONFIG_NAME: 'tsconfig-paths.tsconfig.json',
18+
},
19+
runner: {
20+
docker: {
21+
volumes: [
22+
{
23+
host: './tsconfig-paths.tsconfig.json',
24+
container: '/serve/tsconfig-paths.tsconfig.json',
25+
},
26+
{
27+
host: './mesh.config.ts',
28+
container: '/serve/mesh.config.ts',
29+
},
30+
{
31+
host: './folder',
32+
container: '/serve/folder',
33+
},
34+
],
35+
},
36+
},
37+
});
38+
const res = await fetch(`http://0.0.0.0:${proc.port}/healthcheck`);
39+
expect(res.ok).toBeTruthy();
40+
});
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// we use jsconfig.json because tsx picks up tsconfig.json and we want to make sure Mesh runtime does it instead
2+
{
3+
"compilerOptions": {
4+
"paths": {
5+
"@e2e/tsconfig-paths/*": ["./folder/*"]
6+
}
7+
}
8+
}

0 commit comments

Comments
 (0)