Skip to content

Commit

Permalink
Migrate transforms to v1 (#7009)
Browse files Browse the repository at this point in the history
* Migrate transforms to v1

* enhance(compose): respect existing transforms
  • Loading branch information
ardatan authored Jun 13, 2024
1 parent 276bd84 commit b5bf97c
Show file tree
Hide file tree
Showing 54 changed files with 12,767 additions and 8,529 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@graphql-mesh/fusion-composition": patch
---
dependencies updates:
- Added dependency [`@graphql-mesh/utils@^0.98.6` ↗︎](https://www.npmjs.com/package/@graphql-mesh/utils/v/0.98.6) (to `dependencies`)
- Added dependency [`graphql-scalars@^1.23.0` ↗︎](https://www.npmjs.com/package/graphql-scalars/v/1.23.0) (to `dependencies`)
- Added dependency [`minimatch@^9.0.0` ↗︎](https://www.npmjs.com/package/minimatch/v/9.0.0) (to `dependencies`)
6 changes: 6 additions & 0 deletions .changeset/@graphql-mesh_fusion-runtime-7009-dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@graphql-mesh/fusion-runtime": patch
---
dependencies updates:
- Added dependency [`@envelop/core@^5.0.1` ↗︎](https://www.npmjs.com/package/@envelop/core/v/5.0.1) (to `dependencies`)
- Added dependency [`@graphql-tools/executor@^1.2.6` ↗︎](https://www.npmjs.com/package/@graphql-tools/executor/v/1.2.6) (to `dependencies`)
7 changes: 7 additions & 0 deletions .changeset/clean-knives-agree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@graphql-mesh/fusion-composition': patch
'@graphql-mesh/fusion-runtime': patch
'@graphql-mesh/utils': patch
---

Implement declarative transforms
18 changes: 18 additions & 0 deletions .changeset/small-fireants-obey.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
'@graphql-mesh/fusion-composition': patch
---

Respect existing transformation done in the given subgraph schema

If the given subgraph has the transformed elements with `@source` directive, then the composition should respect it;

```graphql
type Query {
user: User @source(type: "MyUser") # This means `User` is actually `MyUser` in the actual subgraph
}

type User @source(name: "MyUser") {
id: ID
name: String
}
```
258 changes: 129 additions & 129 deletions e2e/auto-type-merging/__snapshots__/auto-type-merging.test.ts.snap

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion e2e/cjs-project/cjs-project.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ it('should compose', async () => {
}
type Query {
hello: String @source(subgraph: "helloworld", name: "hello", type: "String")
hello: String @source(name: "hello", type: "String", subgraph: "helloworld")
}
"
`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ exports[`should write compose output to fusiongraph.graphql 1`] = `
}
type Query {
hello: String @source(subgraph: "helloworld", name: "hello", type: "String")
hello: String @source(name: "hello", type: "String", subgraph: "helloworld")
}"
`;

exports[`should write compose output to fusiongraph.js 1`] = `"export default "schema @transport(subgraph: \\"helloworld\\") {\\n query: Query\\n}\\n\\ntype Query {\\n hello: String @source(subgraph: \\"helloworld\\", name: \\"hello\\", type: \\"String\\")\\n}""`;
exports[`should write compose output to fusiongraph.js 1`] = `"export default "schema @transport(subgraph: \\"helloworld\\") {\\n query: Query\\n}\\n\\ntype Query {\\n hello: String @source(name: \\"hello\\", type: \\"String\\", subgraph: \\"helloworld\\")\\n}""`;

exports[`should write compose output to fusiongraph.json 1`] = `
"{
Expand Down Expand Up @@ -90,35 +90,35 @@ exports[`should write compose output to fusiongraph.json 1`] = `
"kind": "Argument",
"name": {
"kind": "Name",
"value": "subgraph"
"value": "name"
},
"value": {
"kind": "StringValue",
"value": "helloworld",
"value": "hello",
"block": false
}
},
{
"kind": "Argument",
"name": {
"kind": "Name",
"value": "name"
"value": "type"
},
"value": {
"kind": "StringValue",
"value": "hello",
"value": "String",
"block": false
}
},
{
"kind": "Argument",
"name": {
"kind": "Name",
"value": "type"
"value": "subgraph"
},
"value": {
"kind": "StringValue",
"value": "String",
"value": "helloworld",
"block": false
}
}
Expand All @@ -132,4 +132,4 @@ exports[`should write compose output to fusiongraph.json 1`] = `
}"
`;

exports[`should write compose output to fusiongraph.ts 1`] = `"export default "schema @transport(subgraph: \\"helloworld\\") {\\n query: Query\\n}\\n\\ntype Query {\\n hello: String @source(subgraph: \\"helloworld\\", name: \\"hello\\", type: \\"String\\")\\n}""`;
exports[`should write compose output to fusiongraph.ts 1`] = `"export default "schema @transport(subgraph: \\"helloworld\\") {\\n query: Query\\n}\\n\\ntype Query {\\n hello: String @source(name: \\"hello\\", type: \\"String\\", subgraph: \\"helloworld\\")\\n}""`;
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ it('should compose', async () => {
}
type Query {
hello: String @source(subgraph: "helloworld", name: "hello", type: "String")
hello: String @source(name: "hello", type: "String", subgraph: "helloworld")
}
"
`);
Expand Down
2 changes: 1 addition & 1 deletion e2e/esm-project/esm-project.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ it('should compose', async () => {
}
type Query {
hello: String @source(subgraph: "helloworld", name: "hello", type: "String")
hello: String @source(name: "hello", type: "String", subgraph: "helloworld")
}
"
`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,53 +18,53 @@ directive @transport(subgraph: String, kind: String, location: String, headers:
directive @live on QUERY
type Query {
todos: [query_todos_items] @httpOperation(subgraph: "API", path: "/todos", httpMethod: GET) @source(subgraph: "API", name: "todos", type: "[query_todos_items]")
todos: [query_todos_items] @httpOperation(subgraph: "API", path: "/todos", httpMethod: GET) @source(name: "todos", type: "[query_todos_items]", subgraph: "API")
}
type query_todos_items @source(subgraph: "API", name: "query_todos_items") {
id: Int @source(subgraph: "API", name: "id", type: "Int")
name: String @source(subgraph: "API", name: "name", type: "String")
content: String @source(subgraph: "API", name: "content", type: "String")
type query_todos_items @source(name: "query_todos_items", subgraph: "API") {
id: Int @source(name: "id", type: "Int", subgraph: "API")
name: String @source(name: "name", type: "String", subgraph: "API")
content: String @source(name: "content", type: "String", subgraph: "API")
}
type Mutation {
addTodo(input: mutationInput_addTodo_input_Input): mutation_addTodo @httpOperation(subgraph: "API", path: "/todo", httpMethod: POST) @source(subgraph: "API", name: "addTodo", type: "mutation_addTodo")
addTodo(input: mutationInput_addTodo_input_Input @source(name: "input", type: "mutationInput_addTodo_input_Input", subgraph: "API")): mutation_addTodo @httpOperation(subgraph: "API", path: "/todo", httpMethod: POST) @source(name: "addTodo", type: "mutation_addTodo", subgraph: "API")
}
type mutation_addTodo @example(subgraph: "API", value: "\\"{\\\\\\"id\\\\\\":0,\\\\\\"name\\\\\\":\\\\\\"TodoName\\\\\\",\\\\\\"content\\\\\\":\\\\\\"TodoContent\\\\\\"}\\"") @source(subgraph: "API", name: "mutation_addTodo") {
id: Int @source(subgraph: "API", name: "id", type: "Int")
name: String @source(subgraph: "API", name: "name", type: "String")
content: String @source(subgraph: "API", name: "content", type: "String")
type mutation_addTodo @example(subgraph: "API", value: "\\"{\\\\\\"id\\\\\\":0,\\\\\\"name\\\\\\":\\\\\\"TodoName\\\\\\",\\\\\\"content\\\\\\":\\\\\\"TodoContent\\\\\\"}\\"") @source(name: "mutation_addTodo", subgraph: "API") {
id: Int @source(name: "id", type: "Int", subgraph: "API")
name: String @source(name: "name", type: "String", subgraph: "API")
content: String @source(name: "content", type: "String", subgraph: "API")
}
input mutationInput_addTodo_input_Input @example(subgraph: "API", value: "\\"{\\\\\\"name\\\\\\":\\\\\\"TodoName\\\\\\",\\\\\\"content\\\\\\":\\\\\\"TodoContent\\\\\\"}\\"") @source(subgraph: "API", name: "mutationInput_addTodo_input_Input") {
name: String @source(subgraph: "API", name: "name", type: "String")
content: String @source(subgraph: "API", name: "content", type: "String")
input mutationInput_addTodo_input_Input @example(subgraph: "API", value: "\\"{\\\\\\"name\\\\\\":\\\\\\"TodoName\\\\\\",\\\\\\"content\\\\\\":\\\\\\"TodoContent\\\\\\"}\\"") @source(name: "mutationInput_addTodo_input_Input", subgraph: "API") {
name: String @source(name: "name", type: "String", subgraph: "API")
content: String @source(name: "content", type: "String", subgraph: "API")
}
type Subscription {
"""PubSub Topic: webhook:post:/webhooks/todo_added"""
todoAdded: subscription_todoAdded @pubsubOperation(subgraph: "API", pubsubTopic: "webhook:post:/webhooks/todo_added") @source(subgraph: "API", name: "todoAdded", type: "subscription_todoAdded")
todoAdded: subscription_todoAdded @pubsubOperation(subgraph: "API", pubsubTopic: "webhook:post:/webhooks/todo_added") @source(name: "todoAdded", type: "subscription_todoAdded", subgraph: "API")
}
type subscription_todoAdded @example(subgraph: "API", value: "\\"{\\\\\\"id\\\\\\":0,\\\\\\"name\\\\\\":\\\\\\"TodoName\\\\\\",\\\\\\"content\\\\\\":\\\\\\"TodoContent\\\\\\"}\\"") @source(subgraph: "API", name: "subscription_todoAdded") {
id: Int @source(subgraph: "API", name: "id", type: "Int")
name: String @source(subgraph: "API", name: "name", type: "String")
content: String @source(subgraph: "API", name: "content", type: "String")
type subscription_todoAdded @example(subgraph: "API", value: "\\"{\\\\\\"id\\\\\\":0,\\\\\\"name\\\\\\":\\\\\\"TodoName\\\\\\",\\\\\\"content\\\\\\":\\\\\\"TodoContent\\\\\\"}\\"") @source(name: "subscription_todoAdded", subgraph: "API") {
id: Int @source(name: "id", type: "Int", subgraph: "API")
name: String @source(name: "name", type: "String", subgraph: "API")
content: String @source(name: "content", type: "String", subgraph: "API")
}
scalar ObjMap @source(subgraph: "API", name: "ObjMap") @source(subgraph: "API", name: "ObjMap")
scalar ObjMap @source(name: "ObjMap", subgraph: "API") @source(name: "ObjMap", subgraph: "API")
enum HTTPMethod @source(subgraph: "API", name: "HTTPMethod") {
GET @source(subgraph: "API", name: "GET")
HEAD @source(subgraph: "API", name: "HEAD")
POST @source(subgraph: "API", name: "POST")
PUT @source(subgraph: "API", name: "PUT")
DELETE @source(subgraph: "API", name: "DELETE")
CONNECT @source(subgraph: "API", name: "CONNECT")
OPTIONS @source(subgraph: "API", name: "OPTIONS")
TRACE @source(subgraph: "API", name: "TRACE")
PATCH @source(subgraph: "API", name: "PATCH")
enum HTTPMethod @source(name: "HTTPMethod", subgraph: "API") {
GET @source(name: "GET", subgraph: "API")
HEAD @source(name: "HEAD", subgraph: "API")
POST @source(name: "POST", subgraph: "API")
PUT @source(name: "PUT", subgraph: "API")
DELETE @source(name: "DELETE", subgraph: "API")
CONNECT @source(name: "CONNECT", subgraph: "API")
OPTIONS @source(name: "OPTIONS", subgraph: "API")
TRACE @source(name: "TRACE", subgraph: "API")
PATCH @source(name: "PATCH", subgraph: "API")
}
"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ exports[`should write compose output to stdout and logs to stderr 1`] = `
}
type Query {
hello: String @source(subgraph: "helloworld", name: "hello", type: "String")
hello: String @source(name: "hello", type: "String", subgraph: "helloworld")
}
"
`;
Loading

0 comments on commit b5bf97c

Please sign in to comment.