Skip to content

Commit

Permalink
fix: types across multiple configs (#2234)
Browse files Browse the repository at this point in the history
Co-authored-by: Tushar Mathur <[email protected]>
  • Loading branch information
shashitnak and tusharmath authored Jun 23, 2024
1 parent 2606a1f commit ff14331
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/core/config/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@ impl ConfigReader {
}
}

Ok(config_module)
// Recreating the ConfigModule in order to recompute the values of
// `input_types`, `output_types` and `interface_types`
let mut final_config_module = ConfigModule::from(config_module.config);
final_config_module.extensions = config_module.extensions;
Ok(final_config_module)
}

/// Reads the certificate from a given file
Expand Down
18 changes: 18 additions & 0 deletions tests/core/snapshots/test-multiple-config-types.md_0.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
source: tests/core/spec.rs
expression: response
---
{
"status": 200,
"headers": {
"content-type": "application/json"
},
"body": {
"data": {
"bar": {
"name": "name",
"id": 1
}
}
}
}
55 changes: 55 additions & 0 deletions tests/core/snapshots/test-multiple-config-types.md_client.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
source: tests/core/spec.rs
expression: formatted
---
scalar Bytes

scalar Date

scalar Email

scalar Empty

input Input {
id: Int
name: String
}

scalar Int128

scalar Int16

scalar Int32

scalar Int64

scalar Int8

scalar JSON

type Output {
id: Int
name: String
}

scalar PhoneNumber

type Query {
bar(input: Input): Output
}

scalar UInt128

scalar UInt16

scalar UInt32

scalar UInt64

scalar UInt8

scalar Url

schema {
query: Query
}
11 changes: 11 additions & 0 deletions tests/core/snapshots/test-multiple-config-types.md_merged.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
source: tests/core/spec.rs
expression: formatter
---
schema @server @upstream @link(id: "types", src: "types.graphql", type: Config) {
query: Query
}

type Query {
bar(input: Input): Output @expr(body: {id: "{{.args.input.id}}", name: "{{.args.input.name}}"})
}
30 changes: 30 additions & 0 deletions tests/execution/test-multiple-config-types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Multiple Configs

```graphql @config
schema @server @link(id: "types", type: Config, src: "types.graphql") {
query: Query
}

type Query {
bar(input: Input): Output @expr(body: {id: "{{.args.input.id}}", name: "{{.args.input.name}}"})
}
```

```graphql @file:types.graphql
input Input {
id: Int
name: String
}

type Output {
id: Int
name: String
}
```

```yml @test
- method: POST
url: http://localhost:8080/graphql
body:
query: 'query { bar(input: {id: 1, name: "name"}) { name id } }'
```

1 comment on commit ff14331

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running 30s test @ http://localhost:8000/graphql

4 threads and 100 connections

Thread Stats Avg Stdev Max +/- Stdev
Latency 6.63ms 3.01ms 88.62ms 72.69%
Req/Sec 3.82k 175.13 4.13k 91.83%

455715 requests in 30.01s, 2.28GB read

Requests/sec: 15185.38

Transfer/sec: 77.94MB

Please sign in to comment.