diff --git a/.github/workflows/run-commands-e2e.yml b/.github/workflows/run-commands-e2e.yml new file mode 100644 index 000000000..3612a5f77 --- /dev/null +++ b/.github/workflows/run-commands-e2e.yml @@ -0,0 +1,50 @@ +on: + push: + branches: + - main + pull_request: + merge_group: + +jobs: + introspection_e2e: + name: introspection E2E + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + - name: Install stable@stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2 + - name: Install rover + run: cargo build -r --bin rover + - name: Check rover + run: | + export PATH="$PATH:./target/release" + rover -V + - name: Build Services + run: cargo build -r -p regressions --example is_deprecated + - name: Run Tests + run: | + ./target/release/examples/is_deprecated & + echo $! > is_deprecated_service.pid + cargo build + cargo test --locked --package regressions --test cli_tests -- introspection_cli_tests + kill $(cat is_deprecated_service.pid) + + connectors_e2e: + name: connectors E2E + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0 + - name: Install stable@stable toolchain + uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2 + - name: Install rover + run: cargo build -r --bin rover + - name: Check rover + run: | + export PATH="$PATH:./target/release" + rover -V + - name: Run Tests + run: | + cargo build + cargo test --locked --package regressions --test cli_tests -- connectors_cli_tests + + diff --git a/Cargo.lock b/Cargo.lock index 5fad1d7fe..c16a15144 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,16 @@ # It is not intended for manual editing. version = 4 +[[package]] +name = "Inflector" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe438c63458706e03479442743baae6c88256498e6431708f6dfc520a26515d3" +dependencies = [ + "lazy_static", + "regex", +] + [[package]] name = "addr2line" version = "0.25.1" @@ -227,8 +237,8 @@ dependencies = [ "serde_json", "serde_json_bytes", "shape", - "strum", - "strum_macros", + "strum 0.27.2", + "strum_macros 0.27.2", "thiserror 2.0.17", "time", "tracing", @@ -338,6 +348,12 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" +[[package]] +name = "ascii_utils" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71938f30533e4d95a6d17aa530939da3842c2ab6f4f84b9dae68447e4129f74a" + [[package]] name = "assert-json-diff" version = "2.0.2" @@ -392,6 +408,97 @@ dependencies = [ "tokio", ] +[[package]] +name = "async-graphql" +version = "7.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "036618f842229ba0b89652ffe425f96c7c16a49f7e3cb23b56fca7f61fd74980" +dependencies = [ + "async-graphql-derive", + "async-graphql-parser", + "async-graphql-value", + "async-stream", + "async-trait", + "base64", + "bytes", + "fast_chemail", + "fnv", + "futures-timer", + "futures-util", + "handlebars", + "http", + "indexmap 2.12.0", + "mime", + "multer", + "num-traits 0.2.19", + "pin-project-lite", + "regex", + "serde", + "serde_json", + "serde_urlencoded", + "static_assertions_next", + "tempfile", + "thiserror 1.0.69", +] + +[[package]] +name = "async-graphql-axum" +version = "7.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8725874ecfbf399e071150b8619c4071d7b2b7a2f117e173dddef53c6bdb6bb1" +dependencies = [ + "async-graphql", + "axum", + "bytes", + "futures-util", + "serde_json", + "tokio", + "tokio-stream", + "tokio-util", + "tower-service", +] + +[[package]] +name = "async-graphql-derive" +version = "7.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd45deb3dbe5da5cdb8d6a670a7736d735ba65b455328440f236dfb113727a3d" +dependencies = [ + "Inflector", + "async-graphql-parser", + "darling 0.20.11", + "proc-macro-crate", + "proc-macro2", + "quote", + "strum 0.26.3", + "syn 2.0.108", + "thiserror 1.0.69", +] + +[[package]] +name = "async-graphql-parser" +version = "7.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b7607e59424a35dadbc085b0d513aa54ec28160ee640cf79ec3b634eba66d3" +dependencies = [ + "async-graphql-value", + "pest", + "serde", + "serde_json", +] + +[[package]] +name = "async-graphql-value" +version = "7.0.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34ecdaff7c9cffa3614a9f9999bf9ee4c3078fe3ce4d6a6e161736b56febf2de" +dependencies = [ + "bytes", + "indexmap 2.12.0", + "serde", + "serde_json", +] + [[package]] name = "async-lock" version = "3.4.1" @@ -469,6 +576,72 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" +[[package]] +name = "automod" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ebb4bd301db2e2ca1f5be131c24eb8ebf2d9559bc3744419e93baf8ddea7e670" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.108", +] + +[[package]] +name = "axum" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b098575ebe77cb6d14fc7f32749631a6e44edbef6b796f89b020e99ba20d425" +dependencies = [ + "axum-core", + "base64", + "bytes", + "form_urlencoded", + "futures-util", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-util", + "itoa", + "matchit", + "memchr", + "mime", + "percent-encoding", + "pin-project-lite", + "serde_core", + "serde_json", + "serde_path_to_error", + "serde_urlencoded", + "sha1", + "sync_wrapper", + "tokio", + "tokio-tungstenite", + "tower 0.5.2", + "tower-layer", + "tower-service", + "tracing", +] + +[[package]] +name = "axum-core" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "59446ce19cd142f8833f856eb31f3eb097812d1479ab224f54d72428ca21ea22" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "http-body-util", + "mime", + "pin-project-lite", + "sync_wrapper", + "tower-layer", + "tower-service", + "tracing", +] + [[package]] name = "backon" version = "1.6.0" @@ -924,6 +1097,15 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c74b8349d32d297c9134b8c88677813a227df8f779daa29bfc29c183fe3dca6" +[[package]] +name = "content_inspector" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7bda66e858c683005a53a9a60c69a4aca7eeaa45d124526e389f7aec8e62f38" +dependencies = [ + "memchr", +] + [[package]] name = "convert_case" version = "0.7.1" @@ -1126,14 +1308,38 @@ dependencies = [ "logos", ] +[[package]] +name = "darling" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7f46116c46ff9ab3eb1597a45688b6715c6e628b5c133e288e709a29bcb4ee" +dependencies = [ + "darling_core 0.20.11", + "darling_macro 0.20.11", +] + [[package]] name = "darling" version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9cdf337090841a411e2a7f3deb9187445851f91b309c0c0a29e05f74a00a48c0" dependencies = [ - "darling_core", - "darling_macro", + "darling_core 0.21.3", + "darling_macro 0.21.3", +] + +[[package]] +name = "darling_core" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d00b9596d185e565c2207a0b01f8bd1a135483d02d9b7b0a54b11da8d53412e" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim", + "syn 2.0.108", ] [[package]] @@ -1150,13 +1356,24 @@ dependencies = [ "syn 2.0.108", ] +[[package]] +name = "darling_macro" +version = "0.20.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc34b93ccb385b40dc71c6fceac4b2ad23662c7eeb248cf10d529b7e055b6ead" +dependencies = [ + "darling_core 0.20.11", + "quote", + "syn 2.0.108", +] + [[package]] name = "darling_macro" version = "0.21.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d38308df82d1080de0afee5d069fa14b0326a88c14f15c5ccda35b4a6c414c81" dependencies = [ - "darling_core", + "darling_core 0.21.3", "quote", "syn 2.0.108", ] @@ -1504,6 +1721,15 @@ dependencies = [ "regex-syntax", ] +[[package]] +name = "fast_chemail" +version = "0.9.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "495a39d30d624c2caabe6312bfead73e7717692b44e0b32df168c275a2e8e9e4" +dependencies = [ + "ascii_utils", +] + [[package]] name = "fastrand" version = "2.3.0" @@ -1939,6 +2165,20 @@ dependencies = [ "tracing", ] +[[package]] +name = "handlebars" +version = "5.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d08485b96a0e6393e9e4d1b8d48cf74ad6c063cd905eb33f42c1ce3f0377539b" +dependencies = [ + "log", + "pest", + "pest_derive", + "serde", + "serde_json", + "thiserror 1.0.69", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -2134,6 +2374,16 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "135b12329e5e3ce057a9f972339ea52bc954fe1e9358ef27f95e89716fbc5424" +[[package]] +name = "humantime-serde" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57a3db5ea5923d99402c94e9feb261dc5ee9b4efa158b0315f788cf549cc200c" +dependencies = [ + "humantime", + "serde", +] + [[package]] name = "hyper" version = "1.8.1" @@ -2796,6 +3046,12 @@ dependencies = [ "regex-automata", ] +[[package]] +name = "matchit" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3" + [[package]] name = "memchr" version = "2.7.6" @@ -2903,6 +3159,23 @@ dependencies = [ "syn 2.0.108", ] +[[package]] +name = "multer" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83e87776546dc87511aa5ee218730c92b666d7264ab6ed41f9d215af9cd5224b" +dependencies = [ + "bytes", + "encoding_rs", + "futures-util", + "http", + "httparse", + "memchr", + "mime", + "spin", + "version_check", +] + [[package]] name = "multi_try" version = "0.3.0" @@ -3870,6 +4143,17 @@ version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58" +[[package]] +name = "regressions" +version = "0.1.0" +dependencies = [ + "async-graphql", + "async-graphql-axum", + "axum", + "tokio", + "trycmd", +] + [[package]] name = "relative-path" version = "1.9.3" @@ -4026,8 +4310,8 @@ dependencies = [ "speculoos", "sputnik", "strsim", - "strum", - "strum_macros", + "strum 0.27.2", + "strum_macros 0.27.2", "tap", "tar", "temp-env", @@ -4474,6 +4758,17 @@ dependencies = [ "serde_json", ] +[[package]] +name = "serde_path_to_error" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10a9ff822e371bb5403e391ecd83e182e0e77ba7f6fe0160b795797109d1b457" +dependencies = [ + "itoa", + "serde", + "serde_core", +] + [[package]] name = "serde_regex" version = "1.1.0" @@ -4532,7 +4827,7 @@ version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08a72d8216842fdd57820dc78d840bef99248e35fb2554ff923319e60f2d686b" dependencies = [ - "darling", + "darling 0.21.3", "proc-macro2", "quote", "syn 2.0.108", @@ -4746,6 +5041,37 @@ version = "1.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" +[[package]] +name = "snapbox" +version = "0.6.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96fa1ce81be900d083b30ec2d481e6658c2acfaa2cfc7be45ccc2cc1b820edb3" +dependencies = [ + "anstream", + "anstyle", + "content_inspector", + "dunce", + "filetime", + "libc", + "normalize-line-endings", + "os_pipe", + "similar", + "snapbox-macros", + "tempfile", + "wait-timeout", + "walkdir", + "windows-sys 0.60.2", +] + +[[package]] +name = "snapbox-macros" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b750c344002d7cc69afb9da00ebd9b5c0f8ac2eb7d115d9d45d5b5f47718d74" +dependencies = [ + "anstream", +] + [[package]] name = "socket2" version = "0.6.1" @@ -4766,6 +5092,12 @@ dependencies = [ "serde_json", ] +[[package]] +name = "spin" +version = "0.9.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67" + [[package]] name = "sputnik" version = "0.0.0" @@ -4798,6 +5130,12 @@ version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" +[[package]] +name = "static_assertions_next" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7beae5182595e9a8b683fa98c4317f956c9a2dec3b9716990d20023cc60c766" + [[package]] name = "str_indices" version = "0.4.4" @@ -4841,12 +5179,34 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "strum" +version = "0.26.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8fec0f0aef304996cf250b31b5a10dee7980c85da9d759361292b8bca5a18f06" +dependencies = [ + "strum_macros 0.26.4", +] + [[package]] name = "strum" version = "0.27.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "af23d6f6c1a224baef9d3f61e287d2761385a5b88fdab4eb4c6f11aeb54c4bcf" +[[package]] +name = "strum_macros" +version = "0.26.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c6bee85a5a24955dc440386795aa378cd9cf82acd5f764469152d2270e581be" +dependencies = [ + "heck 0.5.0", + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.108", +] + [[package]] name = "strum_macros" version = "0.27.2" @@ -5169,6 +5529,18 @@ dependencies = [ "tokio-stream", ] +[[package]] +name = "tokio-tungstenite" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d25a406cddcc431a75d3d9afc6a7c0f7428d4891dd973e4d54c56b46127bf857" +dependencies = [ + "futures-util", + "log", + "tokio", + "tungstenite", +] + [[package]] name = "tokio-util" version = "0.7.17" @@ -5177,6 +5549,7 @@ checksum = "2efa149fe76073d6e8fd97ef4f4eca7b67f599660115591483572e406e165594" dependencies = [ "bytes", "futures-core", + "futures-io", "futures-sink", "pin-project-lite", "tokio", @@ -5213,8 +5586,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6485ef6d0d9b5d0ec17244ff7eb05310113c3f316f2d14200d4de56b3cb98f8d" dependencies = [ "indexmap 2.12.0", + "serde_core", + "serde_spanned", "toml_datetime", "toml_parser", + "toml_writer", "winnow", ] @@ -5260,6 +5636,7 @@ dependencies = [ "tokio", "tower-layer", "tower-service", + "tracing", ] [[package]] @@ -5460,6 +5837,41 @@ dependencies = [ "syn 2.0.108", ] +[[package]] +name = "trycmd" +version = "0.15.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a81ea3136ddc88e19c2cc2eb3176b72abee4e831367cd8949f2a88ac5497e64e" +dependencies = [ + "anstream", + "automod", + "glob", + "humantime", + "humantime-serde", + "rayon", + "serde", + "shlex", + "snapbox", + "toml_edit", +] + +[[package]] +name = "tungstenite" +version = "0.28.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8628dcc84e5a09eb3d8423d6cb682965dea9133204e8fb3efee74c2a0c259442" +dependencies = [ + "bytes", + "data-encoding", + "http", + "httparse", + "log", + "rand 0.9.2", + "sha1", + "thiserror 2.0.17", + "utf-8", +] + [[package]] name = "typed-arena" version = "2.0.2" @@ -5538,6 +5950,12 @@ dependencies = [ "serde", ] +[[package]] +name = "utf-8" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9" + [[package]] name = "utf8_iter" version = "1.0.4" diff --git a/Cargo.toml b/Cargo.toml index 97f7b144f..6dc7f22f9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,6 +36,7 @@ members = [ "crates/sputnik", "crates/timber", "installers/binstall", + "regressions" ] [workspace.lints.clippy] diff --git a/mise.toml b/mise.toml index 971286889..4c48ac5cd 100644 --- a/mise.toml +++ b/mise.toml @@ -14,7 +14,7 @@ run = "cargo +nightly fmt --all -- --check" run = "cargo clippy --locked --workspace --all-features --all-targets" [tasks.test] -run = "cargo test --locked --workspace" +run = "cargo test --locked --workspace --exclude regressions" [tasks.install_npm] run = "bash .mise/scripts/install_npm.sh" diff --git a/regressions/Cargo.toml b/regressions/Cargo.toml new file mode 100644 index 000000000..4e303cfd8 --- /dev/null +++ b/regressions/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "regressions" +version = "0.1.0" +edition = "2024" + +[dependencies] +async-graphql = "*" +async-graphql-axum = "*" +tokio = { version = "1.37", features = ["macros", "rt-multi-thread"] } +axum = { version = "0.8.1" } +trycmd = "0.15" \ No newline at end of file diff --git a/regressions/e2e/connectors/list.md b/regressions/e2e/connectors/list.md new file mode 100644 index 000000000..228093e2e --- /dev/null +++ b/regressions/e2e/connectors/list.md @@ -0,0 +1,83 @@ +# Lists the Connectors in a GraphQL schema file + +## List_Connectors on fields + +```console +$ rover connector --elv2-license accept list --schema fixtures/body.graphql +merging supergraph schema files +downloading the 'supergraph' plugin from https://rover.apollo.dev/tar/supergraph/x86_64-unknown-linux-gnu/latest-2 +the 'supergraph' plugin was successfully installed to /home/runner/.rover/bin/supergraph-v2.12.1 +{ + "connectors": [ + { + "id": "query_helloWorld" + } + ] +} + + +``` + +## List_Connectors on types + +```console +$ rover connector --elv2-license accept list --schema fixtures/single_entity.graphql +merging supergraph schema files +{ + "connectors": [ + { + "id": "Product[0]" + } + ] +} + + +``` + +## Multiple Connectors + +```console +$ rover connector --elv2-license accept list --schema fixtures/multiple_connectors.graphql +merging supergraph schema files +{ + "connectors": [ + { + "id": "Query.helloWorld[0]" + }, + { + "id": "Query.helloWorld[1]" + } + ] +} + + +``` + +## List_Connectors with ID + +```console +$ rover connector --elv2-license accept list --schema fixtures/schema.graphql +merging supergraph schema files +{ + "connectors": [ + { + "id": "helloworld" + } + ] +} + + +``` + + +## No Connectors Found + +```console +$ rover connector --elv2-license accept list --schema fixtures/missing_type.graphql +merging supergraph schema files +{ + "connectors": [] +} + + +``` \ No newline at end of file diff --git a/regressions/e2e/introspection/is_deprecated.md b/regressions/e2e/introspection/is_deprecated.md new file mode 100644 index 000000000..043b27984 --- /dev/null +++ b/regressions/e2e/introspection/is_deprecated.md @@ -0,0 +1,27 @@ +# Is Deprecated + +## Introspection tests + +```console +$ rover graph introspect http://localhost:8000 +schema { + query: QueryRoot +} +type QueryRoot { + recipe(id: String!): Recipe! + bogus(id: String!, title: String @deprecated(reason: "bar")): Int! +} +type Recipe { + creation: String! + title: String! @deprecated(reason: "foo") +} +"Indicates that an Input Object is a OneOf Input Object (and thus requires exactly one of its field be provided)" +directive @oneOf on INPUT_OBJECT +"Provides a scalar specification URL for specifying the behavior of custom scalar types." +directive @specifiedBy( + "URL that specifies the behavior of this scalar." + url: String! + ) on SCALAR + + +``` \ No newline at end of file diff --git a/regressions/examples/is_deprecated.rs b/regressions/examples/is_deprecated.rs new file mode 100644 index 000000000..8019730ef --- /dev/null +++ b/regressions/examples/is_deprecated.rs @@ -0,0 +1,60 @@ +#![allow(clippy::needless_lifetimes)] +use async_graphql::{Context, EmptyMutation, EmptySubscription, Object, Schema}; +use async_graphql_axum::GraphQL; +use axum::{Router, routing::post_service}; +use tokio::net::TcpListener; + +pub struct StarWars; + +struct Recipe { + creation: String, + title: String, +} + +#[Object] +impl Recipe { + async fn creation(&self) -> String { + self.creation.to_string() + } + + #[graphql(deprecation = "foo")] + async fn title(&self) -> String { + self.title.to_string() + } +} + +pub struct QueryRoot; + +#[Object] +impl QueryRoot { + async fn recipe<'a>(&self, _ctx: &Context<'a>, id: String) -> Recipe { + Recipe { + creation: "date".to_string(), + title: id, + } + } + + async fn bogus<'a>( + &self, + _ctx: &Context<'a>, + _id: String, + #[graphql(deprecation = "bar")] _title: Option, + ) -> i32 { + 0i32 + } +} + +#[tokio::main] +async fn main() { + let schema = Schema::build(QueryRoot, EmptyMutation, EmptySubscription) + .data(StarWars) + .finish(); + + let app = Router::new().route("/", post_service(GraphQL::new(schema))); + + println!("GraphiQL IDE: http://0.0.0.0:8000"); + + axum::serve(TcpListener::bind("0.0.0.0:8000").await.unwrap(), app) + .await + .unwrap(); +} diff --git a/regressions/fixtures/body.graphql b/regressions/fixtures/body.graphql new file mode 100644 index 000000000..3af762032 --- /dev/null +++ b/regressions/fixtures/body.graphql @@ -0,0 +1,20 @@ +extend schema + @link(url: "https://specs.apollo.dev/federation/v2.11", import: ["@key"]) + @link(url: "https://specs.apollo.dev/connect/v0.2", import: ["@connect", "@source"]) + @source(name: "myApi", http: { baseURL: "https://jsonplaceholder.typicode.com" } ) + +type Query { + helloWorld(name: String): String + @connect( + id: "query_helloWorld" + source: "myApi" + http: { POST: "/greeting?name={$args.name}" body: """ + $({ + hello: $args.arg_1 + }) + """ } + selection: """ + greeting + """ + ) +} \ No newline at end of file diff --git a/regressions/fixtures/missing_type.graphql b/regressions/fixtures/missing_type.graphql new file mode 100644 index 000000000..bbabd7f81 --- /dev/null +++ b/regressions/fixtures/missing_type.graphql @@ -0,0 +1,3 @@ +type Query { + hero: Character +} \ No newline at end of file diff --git a/regressions/fixtures/multiple_connectors.graphql b/regressions/fixtures/multiple_connectors.graphql new file mode 100644 index 000000000..5553731b8 --- /dev/null +++ b/regressions/fixtures/multiple_connectors.graphql @@ -0,0 +1,22 @@ +extend schema + @link(url: "https://specs.apollo.dev/federation/v2.11", import: ["@key"]) + @link(url: "https://specs.apollo.dev/connect/v0.2", import: ["@connect", "@source"]) + @source(name: "myApi", http: { baseURL: "https://jsonplaceholder.typicode.com" } ) + +type Query { + helloWorld(name: String): String + @connect( + source: "myApi" + http: { GET: "/greeting?name={$args.name}"} + selection: """ + greeting + """ + ) + @connect( + source: "myApi" + http: { GET: "/greeting?name={$args.name}"} + selection: """ + greeting + """ + ) +} \ No newline at end of file diff --git a/regressions/fixtures/schema.graphql b/regressions/fixtures/schema.graphql new file mode 100644 index 000000000..65b8cf4a1 --- /dev/null +++ b/regressions/fixtures/schema.graphql @@ -0,0 +1,19 @@ +extend schema + @link(url: "https://specs.apollo.dev/federation/v2.11", import: ["@key"]) + @link(url: "https://specs.apollo.dev/connect/v0.2", import: ["@connect", "@source"]) + @source(name: "myApi", http: { baseURL: "https://jsonplaceholder.typicode.com" } ) + +type Query { + helloWorld(name: String): String + @connect( + id: "helloworld" + source: "myApi" + errors: { + message: """$("a custom error message")""" + } + http: { GET: "/greeting?name={$args.name}"} + selection: """ + greeting + """ + ) +} \ No newline at end of file diff --git a/regressions/fixtures/single_entity.graphql b/regressions/fixtures/single_entity.graphql new file mode 100644 index 000000000..c81568911 --- /dev/null +++ b/regressions/fixtures/single_entity.graphql @@ -0,0 +1,22 @@ +extend schema + @link(url: "https://specs.apollo.dev/federation/v2.11", import: ["@key"]) + @link(url: "https://specs.apollo.dev/connect/v0.3", import: ["@connect", "@source"]) + @source(name: "myApi", http: { baseURL: "https://myApi.com" } ) + +type Product @connect( + source: "myApi", + http: { GET: "/products/{$this.id}" } + selection: """ + id + name + description + """ +) { + id: ID!, + name: String, + description: String +} + +type Query { + products(id: ID!): Product +} \ No newline at end of file diff --git a/regressions/tests/cli_tests.rs b/regressions/tests/cli_tests.rs new file mode 100644 index 000000000..d9db37058 --- /dev/null +++ b/regressions/tests/cli_tests.rs @@ -0,0 +1,9 @@ +#[test] +fn introspection_cli_tests() { + trycmd::TestCases::new().case("e2e/introspection/*.md"); +} + +#[test] +fn connectors_cli_tests() { + trycmd::TestCases::new().case("e2e/connectors/*.md"); +} diff --git a/src/command/connector/list.rs b/src/command/connector/list.rs index baa3d5c52..8339b6640 100644 --- a/src/command/connector/list.rs +++ b/src/command/connector/list.rs @@ -15,7 +15,7 @@ pub struct ListConnector { /// /// Optional if there is a `supergraph.yaml` containing only a single subgraph #[arg(long = "schema", value_name = "SCHEMA_FILE_PATH")] - schema_path: Option, + schema: Option, } impl ListConnector { @@ -25,9 +25,10 @@ impl ListConnector { default_subgraph: Option, ) -> RoverResult { let exec_command_impl = TokioCommand::default(); - let schema_path = self.schema_path.clone().or(default_subgraph).ok_or_else(|| anyhow!( + let schema_path = self.schema.clone().or(default_subgraph).ok_or_else(|| anyhow!( "A schema path must be provided either via --schema or a `supergraph.yaml` containing a single subgraph" ))?; + let result = supergraph_binary .list_connector( &exec_command_impl, diff --git a/src/command/connector/run.rs b/src/command/connector/run.rs index f30aeed36..823749671 100644 --- a/src/command/connector/run.rs +++ b/src/command/connector/run.rs @@ -18,7 +18,7 @@ pub struct RunConnector { /// /// Optional if there is a `supergraph.yaml` containing only a single subgraph #[arg(long = "schema", value_name = "SCHEMA_FILE_PATH")] - schema_path: Option, + schema: Option, /// The ID of the connector to run, which can be: /// /// 1. The name of a type, like `MyType`, if the connector is on the type @@ -74,7 +74,7 @@ impl RunConnector { default_subgraph: Option, ) -> RoverResult { let exec_command_impl = TokioCommand::default(); - let schema_path = self.schema_path.clone().or(default_subgraph).ok_or_else(|| anyhow!( + let schema_path = self.schema.clone().or(default_subgraph).ok_or_else(|| anyhow!( "A schema path must be provided either via --schema or a `supergraph.yaml` containing a single subgraph" ))?; let result = supergraph_binary