-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[v1] JS config support and more defaults (#7257)
- Loading branch information
Showing
11 changed files
with
610 additions
and
69 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,7 @@ | ||
--- | ||
'@graphql-mesh/compose-cli': minor | ||
'@graphql-mesh/serve-cli': minor | ||
--- | ||
|
||
Support mesh.config.ts or mesh.config.mts or mesh.config.cts or mesh.config.js or mesh.config.mjs or | ||
mesh.config.cjs configuration 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,89 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`should compose and serve 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,15 @@ | ||
import { createTenv } from '@e2e/tenv'; | ||
|
||
const { serve, compose, fs } = createTenv(__dirname); | ||
|
||
it('should compose and serve', async () => { | ||
const { result: composedSchema } = await compose(); | ||
expect(composedSchema).toMatchSnapshot(); | ||
|
||
const supergraphPath = await fs.tempfile('supergraph.graphql'); | ||
await fs.write(supergraphPath, composedSchema); | ||
const { port } = await serve({ supergraph: supergraphPath }); | ||
const res = await fetch(`http://0.0.0.0:${port}/graphql?query={hello}`); | ||
expect(res.ok).toBeTruthy(); | ||
await expect(res.text()).resolves.toMatchInlineSnapshot(`"{"data":{"hello":"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,32 @@ | ||
import { GraphQLObjectType, GraphQLSchema, GraphQLString } from 'graphql'; | ||
|
||
export const composeConfig = { | ||
subgraphs: [ | ||
{ | ||
sourceHandler: () => ({ | ||
name: 'helloworld', | ||
schema$: new GraphQLSchema({ | ||
query: new GraphQLObjectType({ | ||
name: 'Query', | ||
fields: { | ||
hello: { | ||
type: GraphQLString, | ||
resolve: () => 'world', | ||
}, | ||
}, | ||
}), | ||
}), | ||
}), | ||
}, | ||
], | ||
}; | ||
|
||
export const serveConfig = { | ||
additionalResolvers: { | ||
Query: { | ||
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,10 @@ | ||
{ | ||
"name": "@e2e/js-config", | ||
"type": "module", | ||
"private": true, | ||
"dependencies": { | ||
"@graphql-mesh/compose-cli": "workspace:*", | ||
"@graphql-mesh/serve-cli": "workspace:*", | ||
"graphql": "16.9.0" | ||
} | ||
} |
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
Oops, something went wrong.