From 6ef3c151df22558f5f7bdc17299d4fe53b9ec9ad Mon Sep 17 00:00:00 2001 From: Sandipsinh Rathod Date: Tue, 24 Sep 2024 23:44:28 -0400 Subject: [PATCH] add tests --- .../test-invalid-add-field.md_error.snap | 15 +++++++++ tests/execution/test-invalid-add-field.md | 31 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 tests/core/snapshots/test-invalid-add-field.md_error.snap create mode 100644 tests/execution/test-invalid-add-field.md diff --git a/tests/core/snapshots/test-invalid-add-field.md_error.snap b/tests/core/snapshots/test-invalid-add-field.md_error.snap new file mode 100644 index 0000000000..89c8031f06 --- /dev/null +++ b/tests/core/snapshots/test-invalid-add-field.md_error.snap @@ -0,0 +1,15 @@ +--- +source: tests/core/spec.rs +expression: errors +--- +[ + { + "message": "Parsing failed because of invalid type: string \"{{.value.user.username}}\", expected a sequence", + "trace": [ + "PostUser", + "@addField", + "path" + ], + "description": null + } +] diff --git a/tests/execution/test-invalid-add-field.md b/tests/execution/test-invalid-add-field.md new file mode 100644 index 0000000000..cba10bd145 --- /dev/null +++ b/tests/execution/test-invalid-add-field.md @@ -0,0 +1,31 @@ +--- +error: true +--- + +# Test invalid add fields + +```graphql @config +schema @server(port: 8000) @upstream(baseURL: "http://jsonplaceholder.typicode.com") { + query: Query +} + +type Query { + postuser: [PostUser] @http(path: "/posts") +} + +type PostUser @addField(name: "username", path: "{{.value.user.username}}") { + id: Int! @modify(name: "postId") + title: String! + userId: Int! + user: User @http(baseURL: "https://jsonplaceholder.typicode.com", path: "/users/{{.value.userId}}") +} + +type User { + id: Int! + name: String! + username: String! + email: String! + phone: String + website: String +} +```