diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e65c2bcc58..ae3abbe988 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -427,7 +427,7 @@ jobs: env: APP_VERSION: ${{ needs.draft_release.outputs.create_release_name }} NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - run: cargo lambda build -p tailcall-aws-lambda --release + run: cargo lambda build -p tailcall-aws-lambda --release --target x86_64-unknown-linux-musl - name: Rename Binary with Target Name run: | diff --git a/Cargo.lock b/Cargo.lock index aa0a1ac3af..11fe58bb97 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -132,9 +132,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.83" +version = "1.0.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25bdb32cbbdce2b519a9cd7df3a678443100e265d5e25ca763b7572a5104f5f3" +checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da" [[package]] name = "anymap2" @@ -277,10 +277,10 @@ dependencies = [ "async-graphql-parser", "darling 0.20.9", "proc-macro-crate 3.1.0", - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", "strum", - "syn 2.0.64", + "syn 2.0.65", "thiserror", ] @@ -432,9 +432,9 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b43422f69d8ff38f95f1b2bb76517c91589a924d1559a0e935d7c8ce0274c11" dependencies = [ - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] @@ -500,9 +500,9 @@ version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "16e62a023e7c117e27523144c5d2459f4397fcc3cab0085af8e2224f643a0193" dependencies = [ - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] @@ -517,9 +517,9 @@ version = "0.1.80" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6fa2087f2753a7da8cc1c0dbfcf89579dd57458e36769de5ac750b4671737ca" dependencies = [ - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] @@ -808,9 +808,9 @@ checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" [[package]] name = "cc" -version = "1.0.97" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "099a5357d84c4c61eb35fc8eafa9a79a902c2f76911e5747ced4e032edd8d9b4" +checksum = "41c270e7540d725e65ac7f1b212ac8ce349719624d7bcff99f8e2e488e8cf03f" [[package]] name = "cfg-if" @@ -908,9 +908,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "528131438037fd55894f62d6e9f068b8f45ac57ffa77517819645d10aed04f64" dependencies = [ "heck 0.5.0", - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] @@ -1011,9 +1011,9 @@ dependencies = [ [[package]] name = "crc32fast" -version = "1.4.0" +version = "1.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b3855a8a784b474f333699ef2bbca9db2c4a1f6d9088a90a2d25b1eb53111eaa" +checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3" dependencies = [ "cfg-if", ] @@ -1056,9 +1056,9 @@ dependencies = [ [[package]] name = "crossbeam-channel" -version = "0.5.12" +version = "0.5.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab3db02a9c5b5121e1e42fbdb1aeb65f5e02624cc58c43f2884c6ccac0b82f95" +checksum = "33480d6946193aa8033910124896ca395333cae7e2d1113d1fef6c3272217df2" dependencies = [ "crossbeam-utils", ] @@ -1084,9 +1084,9 @@ dependencies = [ [[package]] name = "crossbeam-utils" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" [[package]] name = "crossterm" @@ -1167,7 +1167,7 @@ checksum = "109c1ca6e6b7f82cc233a97004ea8ed7ca123a9af07a8230878fcfda9b158bf0" dependencies = [ "fnv", "ident_case", - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", "strsim 0.10.0", "syn 1.0.109", @@ -1181,10 +1181,10 @@ checksum = "622687fe0bac72a04e5599029151f5796111b90f1baaa9b544d807a5e31cd120" dependencies = [ "fnv", "ident_case", - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", "strsim 0.11.1", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] @@ -1206,7 +1206,7 @@ checksum = "733cabb43482b1a1b53eee8583c2b9e8684d592215ea83efd305dd31bc2f0178" dependencies = [ "darling_core 0.20.9", "quote 1.0.36", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] @@ -1265,7 +1265,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4ec317cc3e7ef0928b0ca6e4a634a4d6c001672ae210438cf114a83e56b018d" dependencies = [ "darling 0.14.4", - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", "syn 1.0.109", ] @@ -1287,9 +1287,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e8ef033054e131169b8f0f9a7af8f5533a9436fadf3c500ed547f730f07090d" dependencies = [ "darling 0.20.9", - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] @@ -1674,9 +1674,9 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" dependencies = [ - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] @@ -1749,9 +1749,9 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.14" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94b22e06ecb0110981051723910cbf0b5f5e09a2062dd7663334ee79a9d1286c" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" dependencies = [ "cfg-if", "js-sys", @@ -2464,9 +2464,9 @@ dependencies = [ [[package]] name = "instant" -version = "0.1.12" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" dependencies = [ "cfg-if", ] @@ -2692,9 +2692,9 @@ checksum = "db13adb97ab515a3691f56e4dbab09283d0b86cb45abd991d8634a9d6f501760" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "libflate" @@ -2732,9 +2732,9 @@ dependencies = [ [[package]] name = "libmimalloc-sys" -version = "0.1.37" +version = "0.1.38" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81eb4061c0582dedea1cbc7aff2240300dd6982e0239d1c99e65c1dbf4a30ba7" +checksum = "0e7bb23d733dfcc8af652a78b7bf232f0e967710d044732185e561e47c0336b6" dependencies = [ "cc", "libc", @@ -2825,10 +2825,10 @@ checksum = "dc487311295e0002e452025d6b580b77bb17286de87b57138f3b5db711cded68" dependencies = [ "beef", "fnv", - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", "regex-syntax 0.6.29", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] @@ -2840,10 +2840,10 @@ dependencies = [ "beef", "fnv", "lazy_static", - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", "regex-syntax 0.8.3", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] @@ -2998,9 +2998,9 @@ version = "5.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] @@ -3009,16 +3009,16 @@ version = "7.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcf09caffaac8068c346b6df2a7fc27a177fd20b39421a39ce0a211bde679a6c" dependencies = [ - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] name = "mimalloc" -version = "0.1.41" +version = "0.1.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f41a2280ded0da56c8cf898babb86e8f10651a34adcfff190ae9a1159c6908d" +checksum = "e9186d86b79b52f4a77af65604b51225e8db1d6ee7e3f41aec1e40829c71a176" dependencies = [ "libmimalloc-sys", ] @@ -3047,9 +3047,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" [[package]] name = "miniz_oxide" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d811f3e15f28568be3407c8e7fdb6514c1cda3cb30683f15b6a1a1dc4ea14a7" +checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae" dependencies = [ "adler", ] @@ -3513,9 +3513,9 @@ checksum = "3ec22af7d3fb470a85dd2ca96b7c577a1eb4ef6f1683a9fe9a8c16e136c04687" dependencies = [ "pest", "pest_meta", - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] @@ -3618,9 +3618,9 @@ version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" dependencies = [ - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] @@ -3648,9 +3648,9 @@ dependencies = [ [[package]] name = "plotters" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2c224ba00d7cadd4d5c660deaf2098e5e80e07846537c51f9cfa4be50c1fd45" +checksum = "a15b6eccb8484002195a3e44fe65a4ce8e93a625797a063735536fd59cb01cf3" dependencies = [ "num-traits", "plotters-backend", @@ -3661,15 +3661,15 @@ dependencies = [ [[package]] name = "plotters-backend" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e76628b4d3a7581389a35d5b6e2139607ad7c75b17aed325f210aa91f4a9609" +checksum = "414cec62c6634ae900ea1c56128dfe87cf63e7caece0852ec76aba307cebadb7" [[package]] name = "plotters-svg" -version = "0.3.5" +version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38f6d39893cca0701371e3c27294f09797214b86f1fb951b89ade8ec04e2abab" +checksum = "81b30686a7d9c3e010b84284bdd26a29f2138574f52f5eb6f794fc0ad924e705" dependencies = [ "plotters-backend", ] @@ -3739,8 +3739,8 @@ version = "0.2.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" dependencies = [ - "proc-macro2 1.0.82", - "syn 2.0.64", + "proc-macro2 1.0.83", + "syn 2.0.65", ] [[package]] @@ -3769,7 +3769,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "da25490ff9892aab3fcf7c36f08cfb902dd3e71ca0f9f9517bea02a73a5ce38c" dependencies = [ "proc-macro-error-attr", - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", "syn 1.0.109", "version_check", @@ -3781,7 +3781,7 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1be40180e52ecc98ad80b184934baf3d0d29f979574e439af5a55274b35f869" dependencies = [ - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", "version_check", ] @@ -3797,9 +3797,9 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.82" +version = "1.0.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" +checksum = "0b33eb56c327dec362a9e55b3ad14f9d2f0904fb5a5b03b513ab5465399e9f43" dependencies = [ "unicode-ident", ] @@ -3821,9 +3821,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.12.4" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d0f5d036824e4761737860779c906171497f6d55681139d8312388f8fe398922" +checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" dependencies = [ "bytes", "prost-derive", @@ -3831,9 +3831,9 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.12.4" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80b776a1b2dc779f5ee0641f8ade0125bc1298dd41a9a0c16d8bd57b42d222b1" +checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" dependencies = [ "bytes", "heck 0.5.0", @@ -3846,21 +3846,21 @@ dependencies = [ "prost", "prost-types", "regex", - "syn 2.0.64", + "syn 2.0.65", "tempfile", ] [[package]] name = "prost-derive" -version = "0.12.4" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19de2de2a00075bf566bee3bd4db014b11587e84184d3f7a791bc17f1a8e9e48" +checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" dependencies = [ "anyhow", "itertools 0.12.1", - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] @@ -3881,9 +3881,9 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.12.4" +version = "0.12.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3235c33eb02c1f1e212abdbe34c78b264b038fb58ca612664343271e36e55ffe" +checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" dependencies = [ "prost", ] @@ -4087,7 +4087,7 @@ version = "1.0.36" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" dependencies = [ - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", ] [[package]] @@ -4376,10 +4376,10 @@ dependencies = [ "phf_shared 0.11.2", "proc-macro-crate 1.3.1", "proc-macro-error", - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", "rquickjs-core", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] @@ -4461,9 +4461,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.6" +version = "0.23.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94cf0812de1f0cee6b163ce35c2f57b90e1ef5a2bed57bcf07c16475bac8c852" +checksum = "ebbbdb961df0ad3f2652da8f3fdc4b36122f568f968f45ad3316f26c025c677b" dependencies = [ "once_cell", "rustls-pki-types", @@ -4563,9 +4563,9 @@ dependencies = [ [[package]] name = "schemars" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc6e7ed6919cb46507fb01ff1654309219f62b4d603822501b0b80d42f6f21ef" +checksum = "b0218ceea14babe24a4a5836f86ade86c1effbc198164e619194cb5069187e29" dependencies = [ "dyn-clone", "schemars_derive", @@ -4575,14 +4575,14 @@ dependencies = [ [[package]] name = "schemars_derive" -version = "0.8.19" +version = "0.8.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "185f2b7aa7e02d418e453790dde16890256bbd2bcd04b7dc5348811052b53f49" +checksum = "3ed5a1ccce8ff962e31a165d41f6e2a2dd1245099dc4d594f5574a86cd90f4d3" dependencies = [ - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", "serde_derive_internals", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] @@ -4692,9 +4692,9 @@ version = "1.0.202" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" dependencies = [ - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] @@ -4703,9 +4703,9 @@ version = "0.29.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" dependencies = [ - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] @@ -5025,10 +5025,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c6cf59daf282c0a494ba14fd21610a0325f9f90ec9d1231dea26bcb1d696c946" dependencies = [ "heck 0.4.1", - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", "rustversion", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] @@ -5054,18 +5054,18 @@ version = "1.0.109" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", "unicode-ident", ] [[package]] name = "syn" -version = "2.0.64" +version = "2.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ad3dee41f36859875573074334c200d1add8e4a87bb37113ebd31d926b7b11f" +checksum = "d2863d96a84c6439701d7a38f9de935ec562c8832cc55d1dde0f513b52fad106" dependencies = [ - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", "unicode-ident", ] @@ -5202,7 +5202,7 @@ dependencies = [ "reqwest-middleware", "resource", "rquickjs", - "rustls 0.23.6", + "rustls 0.23.7", "rustls-pemfile 1.0.4", "rustls-pki-types", "schemars", @@ -5303,6 +5303,7 @@ dependencies = [ "http-cache", "http-cache-reqwest", "http-cache-semantics", + "moka", "reqwest", "serde", "tokio", @@ -5313,9 +5314,9 @@ dependencies = [ name = "tailcall-macros" version = "0.1.0" dependencies = [ - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] @@ -5460,22 +5461,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.60" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "579e9083ca58dd9dcf91a9923bb9054071b9ebbd800b342194c9feb0ee89fc18" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.60" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2470041c06ec3ac1ab38d0356a6119054dedaea53e12fbefc0de730a1c08524" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] @@ -5597,9 +5598,9 @@ version = "2.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5b8a1e28f2deaa14e508979454cb3a223b10b938b45af148bc0986de36f1923b" dependencies = [ - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] @@ -5726,10 +5727,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9d021fc044c18582b9a2408cd0dd05b1596e3ecdb5c4df822bb0183545683889" dependencies = [ "prettyplease", - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "prost-build", "quote 1.0.36", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] @@ -5739,10 +5740,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "be4ef6dd70a610078cb4e338a0f79d06bc759ff1b22d2120c2ff02ae264ba9c2" dependencies = [ "prettyplease", - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "prost-build", "quote 1.0.36", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] @@ -5838,9 +5839,9 @@ version = "0.1.27" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7" dependencies = [ - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] @@ -6159,9 +6160,9 @@ dependencies = [ "bumpalo", "log", "once_cell", - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", - "syn 2.0.64", + "syn 2.0.65", "wasm-bindgen-shared", ] @@ -6193,9 +6194,9 @@ version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", - "syn 2.0.64", + "syn 2.0.65", "wasm-bindgen-backend", "wasm-bindgen-shared", ] @@ -6369,7 +6370,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5e2ee588991b9e7e6c8338edf3333fbe4da35dc72092643958ebb43f0ab2c49c" dependencies = [ - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", "syn 1.0.109", ] @@ -6380,9 +6381,9 @@ version = "0.56.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6fc35f58ecd95a9b71c4f2329b911016e6bec66b3f2e6a4aad86bd2e99e2f9b" dependencies = [ - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] @@ -6391,7 +6392,7 @@ version = "0.48.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e6fb8df20c9bcaa8ad6ab513f7b40104840c8867d5751126e4df3b08388d0cc7" dependencies = [ - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", "syn 1.0.109", ] @@ -6402,9 +6403,9 @@ version = "0.56.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "08990546bf4edef8f431fa6326e032865f27138718c587dc21bc0265bbcb57cc" dependencies = [ - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] @@ -6657,9 +6658,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6a0f7f15151a77dca96813d0eff10ab9b29114533fae0267d00c466c13081e69" dependencies = [ "async-trait", - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", - "syn 2.0.64", + "syn 2.0.65", "wasm-bindgen", "wasm-bindgen-futures", "wasm-bindgen-macro-support", @@ -6685,9 +6686,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a76ff259533532054cfbaefb115c613203c73707017459206380f03b3b3f266e" dependencies = [ "darling 0.20.9", - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] @@ -6717,9 +6718,9 @@ version = "0.7.34" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15e934569e47891f7d9411f1a451d947a60e000ab3bd24fbb970f000387d1b3b" dependencies = [ - "proc-macro2 1.0.82", + "proc-macro2 1.0.83", "quote 1.0.36", - "syn 2.0.64", + "syn 2.0.65", ] [[package]] diff --git a/README.md b/README.md index 6e2f24a8ba..ad31252335 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ The below file is a standard `.graphQL` file, with a few additions such as `@ser ```graphql schema @server(port: 8000, hostname: "0.0.0.0") - @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: true) { + @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42) { query: Query } diff --git a/benches/http_execute_bench.rs b/benches/http_execute_bench.rs index 468f9e07f0..4d30eff052 100644 --- a/benches/http_execute_bench.rs +++ b/benches/http_execute_bench.rs @@ -8,7 +8,7 @@ pub fn benchmark_http_execute_method(c: &mut Criterion) { let tokio_runtime = tokio::runtime::Runtime::new().unwrap(); let mut blueprint = Blueprint::default(); - blueprint.upstream.http_cache = true; // allow http caching for bench test. + blueprint.upstream.http_cache = 42; // allow http caching for bench test. let native_http = NativeHttp::init(&blueprint.upstream, &blueprint.telemetry); let request_url = String::from("http://jsonplaceholder.typicode.com/users"); diff --git a/benches/impl_path_string_for_evaluation_context.rs b/benches/impl_path_string_for_evaluation_context.rs index c5eb9ea971..490c1f85ab 100644 --- a/benches/impl_path_string_for_evaluation_context.rs +++ b/benches/impl_path_string_for_evaluation_context.rs @@ -57,10 +57,10 @@ impl Http { let mut client = ClientBuilder::new(builder.build().expect("Failed to build client")); - if upstream.http_cache { + if upstream.http_cache > 0 { client = client.with(Cache(HttpCache { mode: CacheMode::Default, - manager: HttpCacheManager::default(), + manager: HttpCacheManager::new(upstream.http_cache), options: HttpCacheOptions::default(), })) } diff --git a/examples/auth.graphql b/examples/auth.graphql index 07b69ea0a0..bb716dc7c4 100644 --- a/examples/auth.graphql +++ b/examples/auth.graphql @@ -1,6 +1,6 @@ schema @server(port: 8000) - @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: true) + @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42) @link(id: "auth-basic", type: Htpasswd, src: ".htpasswd") @link(id: "auth-jwt", type: Jwks, src: ".jwks") { query: Query diff --git a/examples/graphql-composition.graphql b/examples/graphql-composition.graphql index 4666a2af82..9eefcecefb 100644 --- a/examples/graphql-composition.graphql +++ b/examples/graphql-composition.graphql @@ -4,7 +4,7 @@ schema @server(port: 8001, queryValidation: false, hostname: "0.0.0.0") - @upstream(baseURL: "http://localhost:8000/graphql", httpCache: true, batch: {delay: 1}) { + @upstream(baseURL: "http://localhost:8000/graphql", httpCache: 42, batch: {delay: 1}) { query: Query } diff --git a/examples/grpc-reflection.graphql b/examples/grpc-reflection.graphql index b2099d7876..69b1f39023 100644 --- a/examples/grpc-reflection.graphql +++ b/examples/grpc-reflection.graphql @@ -1,7 +1,7 @@ # for test upstream server see [repo](https://github.com/tailcallhq/tailcall/tree/main/tailcall-upstream-grpc) schema @server(port: 8000) - @upstream(baseURL: "http://localhost:50051", httpCache: true, batch: {delay: 10}) + @upstream(baseURL: "http://localhost:50051", httpCache: 42, batch: {delay: 10}) @link(src: "http://localhost:50051", type: Grpc) { query: Query } diff --git a/examples/grpc.graphql b/examples/grpc.graphql index 2828b82d22..22d30411b3 100644 --- a/examples/grpc.graphql +++ b/examples/grpc.graphql @@ -1,7 +1,7 @@ # for test upstream server see [repo](https://github.com/tailcallhq/rust-grpc) schema @server(port: 8000) - @upstream(baseURL: "http://localhost:50051", httpCache: true, batch: {delay: 10}) + @upstream(baseURL: "http://localhost:50051", httpCache: 42, batch: {delay: 10}) @link(id: "news", src: "../tailcall-fixtures/fixtures/protobuf/news.proto", type: Protobuf) { query: Query } diff --git a/examples/jsonplaceholder.graphql b/examples/jsonplaceholder.graphql index 028bc1b047..54fb92a978 100644 --- a/examples/jsonplaceholder.graphql +++ b/examples/jsonplaceholder.graphql @@ -1,6 +1,6 @@ schema @server(port: 8000, headers: {cors: {allowOrigins: ["*"], allowHeaders: ["*"], allowMethods: [POST, GET, OPTIONS]}}) - @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: true, batch: {delay: 100}) { + @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42, batch: {delay: 100}) { query: Query } diff --git a/examples/jsonplaceholder.json b/examples/jsonplaceholder.json index f38a74e343..c3b1d96ae6 100644 --- a/examples/jsonplaceholder.json +++ b/examples/jsonplaceholder.json @@ -6,7 +6,7 @@ }, "upstream": { "baseURL": "http://jsonplaceholder.typicode.com", - "httpCache": true + "httpCache": 42 }, "schema": { "query": "Query" diff --git a/examples/jsonplaceholder.yml b/examples/jsonplaceholder.yml index 17bdbb7e8e..57f712130f 100644 --- a/examples/jsonplaceholder.yml +++ b/examples/jsonplaceholder.yml @@ -3,7 +3,7 @@ server: port: 8000 upstream: baseURL: http://jsonplaceholder.typicode.com - httpCache: true + httpCache: 42 schema: query: Query types: diff --git a/examples/jsonplaceholder_batch.graphql b/examples/jsonplaceholder_batch.graphql index bb54487aab..41d000b0cb 100644 --- a/examples/jsonplaceholder_batch.graphql +++ b/examples/jsonplaceholder_batch.graphql @@ -1,6 +1,6 @@ schema @server(port: 8000) - @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: true, batch: {delay: 1, maxSize: 1000}) { + @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42, batch: {delay: 1, maxSize: 1000}) { query: Query } diff --git a/examples/jsonplaceholder_batch.json b/examples/jsonplaceholder_batch.json index 9b46cafcf6..2c633c3ffb 100644 --- a/examples/jsonplaceholder_batch.json +++ b/examples/jsonplaceholder_batch.json @@ -4,7 +4,7 @@ }, "upstream": { "baseURL": "http://jsonplaceholder.typicode.com", - "httpCache": true, + "httpCache": 42, "batch": { "maxSize": 1000, "delay": 1, diff --git a/examples/jsonplaceholder_batch.yml b/examples/jsonplaceholder_batch.yml index 1a280b638e..8a28c8ebb1 100644 --- a/examples/jsonplaceholder_batch.yml +++ b/examples/jsonplaceholder_batch.yml @@ -2,7 +2,7 @@ server: port: 8000 upstream: baseURL: http://jsonplaceholder.typicode.com - httpCache: true + httpCache: 42 batch: maxSize: 1000 delay: 1 diff --git a/examples/jsonplaceholder_http_2.graphql b/examples/jsonplaceholder_http_2.graphql index f09c2d33d1..a2a931fdb6 100644 --- a/examples/jsonplaceholder_http_2.graphql +++ b/examples/jsonplaceholder_http_2.graphql @@ -2,7 +2,7 @@ schema @server(port: 3000, queryValidation: false, hostname: "0.0.0.0", version: HTTP2) @link(type: Cert, src: "./example.crt") @link(type: Key, src: "./example.key") - @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: true) { + @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42) { query: Query } diff --git a/examples/jsonplaceholder_script.graphql b/examples/jsonplaceholder_script.graphql index 0cfab82800..b141b92f0b 100644 --- a/examples/jsonplaceholder_script.graphql +++ b/examples/jsonplaceholder_script.graphql @@ -1,6 +1,6 @@ schema @server(port: 8000, hostname: "0.0.0.0") - @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: true) + @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42) @link(type: Script, src: "scripts/echo.js") { query: Query } diff --git a/examples/rest-api.graphql b/examples/rest-api.graphql index 59d39e8601..824bf1dcbb 100644 --- a/examples/rest-api.graphql +++ b/examples/rest-api.graphql @@ -1,6 +1,6 @@ schema @server(port: 8000, hostname: "0.0.0.0") - @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: true) + @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42) @link(type: Operation, src: "operations/routes.graphql") { query: Query } diff --git a/examples/telemetry-otlp.graphql b/examples/telemetry-otlp.graphql index a6775f6c5e..31a57e505d 100644 --- a/examples/telemetry-otlp.graphql +++ b/examples/telemetry-otlp.graphql @@ -1,6 +1,6 @@ schema @server(port: 8000, hostname: "0.0.0.0") - @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: true) + @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42) @link(type: Operation, src: "operations/routes.graphql") @link(id: "news", src: "../tailcall-fixtures/fixtures/protobuf/news.proto", type: Protobuf) @telemetry( diff --git a/examples/telemetry-prometheus.graphql b/examples/telemetry-prometheus.graphql index e0ff49f1fb..f1010e5d6b 100644 --- a/examples/telemetry-prometheus.graphql +++ b/examples/telemetry-prometheus.graphql @@ -1,6 +1,6 @@ schema @server(port: 8000, hostname: "0.0.0.0") - @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: true) + @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42) @telemetry(export: {prometheus: {path: "/metrics"}}) { query: Query } diff --git a/examples/telemetry-stdout.graphql b/examples/telemetry-stdout.graphql index 1907d6e2b4..c9245f4b92 100644 --- a/examples/telemetry-stdout.graphql +++ b/examples/telemetry-stdout.graphql @@ -1,6 +1,6 @@ schema @server(port: 8000, hostname: "0.0.0.0") - @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: true) + @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42) @telemetry(export: {stdout: {pretty: true}}) { query: Query } diff --git a/generated/.tailcallrc.graphql b/generated/.tailcallrc.graphql index 9b6705faeb..8e167258ea 100644 --- a/generated/.tailcallrc.graphql +++ b/generated/.tailcallrc.graphql @@ -362,11 +362,11 @@ directive @upstream( """ http2Only: Boolean """ - Activating this enables Tailcall's HTTP caching, adhering to the [HTTP Caching RFC](https://tools.ietf.org/html/rfc7234), - to enhance performance by minimizing redundant data fetches. Defaults to `false` - if unspecified. + Providing httpCache size enables Tailcall's HTTP caching, adhering to the [HTTP Caching + RFC](https://tools.ietf.org/html/rfc7234), to enhance performance by minimizing redundant + data fetches. Defaults to `0` if unspecified. """ - httpCache: Boolean + httpCache: Int """ The time in seconds between each keep-alive message sent to maintain the connection. """ diff --git a/generated/.tailcallrc.schema.json b/generated/.tailcallrc.schema.json index 00890a5fe1..0bcd9fcfa5 100644 --- a/generated/.tailcallrc.schema.json +++ b/generated/.tailcallrc.schema.json @@ -1366,11 +1366,13 @@ ] }, "httpCache": { - "description": "Activating this enables Tailcall's HTTP caching, adhering to the [HTTP Caching RFC](https://tools.ietf.org/html/rfc7234), to enhance performance by minimizing redundant data fetches. Defaults to `false` if unspecified.", + "description": "Providing httpCache size enables Tailcall's HTTP caching, adhering to the [HTTP Caching RFC](https://tools.ietf.org/html/rfc7234), to enhance performance by minimizing redundant data fetches. Defaults to `0` if unspecified.", "type": [ - "boolean", + "integer", "null" - ] + ], + "format": "uint64", + "minimum": 0.0 }, "keepAliveInterval": { "description": "The time in seconds between each keep-alive message sent to maintain the connection.", diff --git a/src/cli/runtime/http.rs b/src/cli/runtime/http.rs index e05660fbc0..bf8945c002 100644 --- a/src/cli/runtime/http.rs +++ b/src/cli/runtime/http.rs @@ -112,10 +112,10 @@ impl NativeHttp { let mut client = ClientBuilder::new(builder.build().expect("Failed to build client")); - if upstream.http_cache { + if upstream.http_cache > 0 { client = client.with(Cache(HttpCache { mode: CacheMode::Default, - manager: HttpCacheManager::default(), + manager: HttpCacheManager::new(upstream.http_cache), options: HttpCacheOptions::default(), })) } @@ -190,13 +190,20 @@ mod tests { use tokio; use super::*; + use crate::core::http::Response; fn start_mock_server() -> httpmock::MockServer { httpmock::MockServer::start() } + async fn make_request(request_url: &str, native_http: &NativeHttp) -> Response { + let request = reqwest::Request::new(Method::GET, request_url.parse().unwrap()); + let result = native_http.execute(request).await; + result.unwrap() + } + #[tokio::test] - async fn test_native_http_get_request() { + async fn test_native_http_get_request_without_cache() { let server = start_mock_server(); let header_serv = server.mock(|when, then| { @@ -208,17 +215,70 @@ mod tests { let port = server.port(); // Build a GET request to the mock server let request_url = format!("http://localhost:{}/test", port); - let request = reqwest::Request::new(Method::GET, request_url.parse().unwrap()); + let response = make_request(&request_url, &native_http).await; - // Execute the request - let result = native_http.execute(request).await; + // Assert the response is as expected + assert_eq!(response.status, reqwest::StatusCode::OK); + assert_eq!(response.body, Bytes::from("Hello")); + assert!(response.headers.get("x-cache-lookup").is_none()); + + let request_url = format!("http://localhost:{}/test", port); + let response = make_request(&request_url, &native_http).await; // Assert the response is as expected - assert!(result.is_ok()); - let response = result.unwrap(); assert_eq!(response.status, reqwest::StatusCode::OK); assert_eq!(response.body, Bytes::from("Hello")); + assert!(response.headers.get("x-cache-lookup").is_none()); + + header_serv.assert_hits(2); + } + + #[tokio::test] + async fn test_native_http_get_request_with_cache() { + let server = start_mock_server(); + + server.mock(|when, then| { + when.method(httpmock::Method::GET).path("/test-1"); + then.status(200).body("Hello"); + }); + + server.mock(|when, then| { + when.method(httpmock::Method::GET).path("/test-2"); + then.status(200).body("Hello"); + }); + + server.mock(|when, then| { + when.method(httpmock::Method::GET).path("/test-3"); + then.status(200).body("Hello"); + }); + + let upstream = Upstream { http_cache: 2, ..Default::default() }; + let native_http = NativeHttp::init(&upstream, &Default::default()); + let port = server.port(); + + let url1 = format!("http://localhost:{}/test-1", port); + let resp = make_request(&url1, &native_http).await; + assert_eq!(resp.headers.get("x-cache-lookup").unwrap(), "MISS"); + + let resp = make_request(&url1, &native_http).await; + assert_eq!(resp.headers.get("x-cache-lookup").unwrap(), "HIT"); + + let url2 = format!("http://localhost:{}/test-2", port); + let resp = make_request(&url2, &native_http).await; + assert_eq!(resp.headers.get("x-cache-lookup").unwrap(), "MISS"); + + let resp = make_request(&url2, &native_http).await; + assert_eq!(resp.headers.get("x-cache-lookup").unwrap(), "HIT"); + + // now cache is full, let's make 3rd request and cache it and evict url1. + let url3 = format!("http://localhost:{}/test-3", port); + let resp = make_request(&url3, &native_http).await; + assert_eq!(resp.headers.get("x-cache-lookup").unwrap(), "MISS"); + + let resp = make_request(&url3, &native_http).await; + assert_eq!(resp.headers.get("x-cache-lookup").unwrap(), "HIT"); - header_serv.assert(); + let resp = make_request(&url1, &native_http).await; + assert_eq!(resp.headers.get("x-cache-lookup").unwrap(), "MISS"); } } diff --git a/src/core/blueprint/upstream.rs b/src/core/blueprint/upstream.rs index 81a2ba68fa..564e3e2612 100644 --- a/src/core/blueprint/upstream.rs +++ b/src/core/blueprint/upstream.rs @@ -24,7 +24,7 @@ pub struct Upstream { pub user_agent: String, pub allowed_headers: BTreeSet, pub base_url: Option, - pub http_cache: bool, + pub http_cache: u64, pub batch: Option, pub http2_only: bool, pub dedupe: bool, @@ -78,7 +78,7 @@ impl TryFrom<&ConfigModule> for Upstream { user_agent: (config_upstream).get_user_agent(), allowed_headers, base_url, - http_cache: (config_upstream).get_enable_http_cache(), + http_cache: (config_upstream).get_http_cache_size(), batch, http2_only: (config_upstream).get_http_2_only(), dedupe: (config_upstream).get_dedupe(), diff --git a/src/core/config/key_values.rs b/src/core/config/key_values.rs index c36c53fa8a..e414f4c490 100644 --- a/src/core/config/key_values.rs +++ b/src/core/config/key_values.rs @@ -26,17 +26,24 @@ pub struct KeyValue { pub value: String, } +// When we merge values, we do a merge right, which is to say that +// where both current and other have the same key, we use the value +// from other. This simplifies the merge_right_vars function in +// server.rs. pub fn merge_key_value_vecs(current: &[KeyValue], other: &[KeyValue]) -> Vec { - let mut acc: BTreeMap<&String, &String> = - current.iter().map(|kv| (&kv.key, &kv.value)).collect(); + let mut res = BTreeMap::new(); + + for kv in current { + res.insert(kv.key.to_owned(), kv.value.to_owned()); + } for kv in other { - acc.insert(&kv.key, &kv.value); + res.insert(kv.key.to_owned(), kv.value.to_owned()); } - acc.iter() - .map(|(k, v)| KeyValue { key: k.to_string(), value: v.to_string() }) - .collect() + res.into_iter() + .map(|(k, v)| KeyValue { key: k, value: v }) + .collect::>() } impl Serialize for KeyValues { diff --git a/src/core/config/server.rs b/src/core/config/server.rs index a9e6be31f0..53d57b9867 100644 --- a/src/core/config/server.rs +++ b/src/core/config/server.rs @@ -97,15 +97,6 @@ pub struct Server { } fn merge_right_vars(mut left: Vec, right: Vec) -> Vec { - left = right.iter().fold(left.to_vec(), |mut acc, kv| { - let position = acc.iter().position(|x| x.key == kv.key); - if let Some(pos) = position { - acc[pos] = kv.clone(); - } else { - acc.push(kv.clone()); - }; - acc - }); left = merge_key_value_vecs(&left, &right); left } @@ -262,4 +253,59 @@ mod tests { let expected = ScriptOptions { timeout: Some(100) }; assert_eq!(merged.script, Some(expected)); } + + fn get_default_left_vec() -> Vec { + [ + KeyValue { key: "left".to_string(), value: "From Left".to_string() }, + KeyValue { key: "1".to_string(), value: "1, Left".to_string() }, + KeyValue { key: "2".to_string(), value: "2, Left".to_string() }, + ] + .to_vec() + } + + fn get_default_right_vec() -> Vec { + [ + KeyValue { key: "right".to_string(), value: "From Right".to_string() }, + KeyValue { key: "1".to_string(), value: "1, Right".to_string() }, + KeyValue { key: "2".to_string(), value: "2, Right".to_string() }, + ] + .to_vec() + } + + fn get_sorted_expected_merge_value() -> Vec { + let mut res = [ + KeyValue { key: "right".to_string(), value: "From Right".to_string() }, + KeyValue { key: "left".to_string(), value: "From Left".to_string() }, + KeyValue { key: "1".to_string(), value: "1, Right".to_string() }, + KeyValue { key: "2".to_string(), value: "2, Right".to_string() }, + ] + .to_vec(); + res.sort_by(|a, b| a.key.cmp(&b.key)); + res + } + + #[test] + fn check_merge_vec_fn() { + let left_vec = get_default_left_vec(); + let right_vec = get_default_right_vec(); + let expected_vec = get_sorted_expected_merge_value(); + + let mut merge_vec = merge_key_value_vecs(&left_vec, &right_vec); + merge_vec.sort_by(|a, b| a.key.cmp(&b.key)); + + assert_eq!(merge_vec, expected_vec) + } + + #[test] + fn check_merge_right_fn() { + let left_vec = get_default_left_vec(); + let right_vec = get_default_right_vec(); + let expected_vec = get_sorted_expected_merge_value(); + + let mut merge_vec = merge_right_vars(left_vec, right_vec); + + merge_vec.sort_by(|a, b| a.key.cmp(&b.key)); + + assert_eq!(merge_vec, expected_vec) + } } diff --git a/src/core/config/upstream.rs b/src/core/config/upstream.rs index 692c5b25ab..dfd32f613d 100644 --- a/src/core/config/upstream.rs +++ b/src/core/config/upstream.rs @@ -79,8 +79,8 @@ pub struct Upstream { pub connect_timeout: Option, #[serde(default, skip_serializing_if = "is_default")] - /// Activating this enables Tailcall's HTTP caching, adhering to the [HTTP Caching RFC](https://tools.ietf.org/html/rfc7234), to enhance performance by minimizing redundant data fetches. Defaults to `false` if unspecified. - pub http_cache: Option, + /// Providing httpCache size enables Tailcall's HTTP caching, adhering to the [HTTP Caching RFC](https://tools.ietf.org/html/rfc7234), to enhance performance by minimizing redundant data fetches. Defaults to `0` if unspecified. + pub http_cache: Option, #[setters(strip_option)] #[serde(rename = "http2Only", default, skip_serializing_if = "is_default")] @@ -172,8 +172,8 @@ impl Upstream { .clone() .unwrap_or("Tailcall/1.0".to_string()) } - pub fn get_enable_http_cache(&self) -> bool { - self.http_cache.unwrap_or(false) + pub fn get_http_cache_size(&self) -> u64 { + self.http_cache.unwrap_or(0) } pub fn get_allowed_headers(&self) -> BTreeSet { self.allowed_headers.clone().unwrap_or_default() diff --git a/src/core/graphql/request_template.rs b/src/core/graphql/request_template.rs index b8bcdffb8d..1aa5a477aa 100644 --- a/src/core/graphql/request_template.rs +++ b/src/core/graphql/request_template.rs @@ -127,11 +127,11 @@ impl RequestTemplate { } impl CacheKey for RequestTemplate { - fn cache_key(&self, ctx: &Ctx) -> u64 { + fn cache_key(&self, ctx: &Ctx) -> Option { let mut hasher = TailcallHasher::default(); let graphql_query = self.render_graphql_query(ctx); graphql_query.hash(&mut hasher); - hasher.finish() + Some(hasher.finish()) } } diff --git a/src/core/grpc/request_template.rs b/src/core/grpc/request_template.rs index a7f4cb4241..76b8d08781 100644 --- a/src/core/grpc/request_template.rs +++ b/src/core/grpc/request_template.rs @@ -107,11 +107,11 @@ impl RenderedRequestTemplate { } impl CacheKey for RequestTemplate { - fn cache_key(&self, ctx: &Ctx) -> u64 { + fn cache_key(&self, ctx: &Ctx) -> Option { let mut hasher = TailcallHasher::default(); let rendered_req = self.render(ctx).unwrap(); rendered_req.hash(&mut hasher); - hasher.finish() + Some(hasher.finish()) } } diff --git a/src/core/http/request_template.rs b/src/core/http/request_template.rs index 42f4c62870..93990f80f7 100644 --- a/src/core/http/request_template.rs +++ b/src/core/http/request_template.rs @@ -225,7 +225,7 @@ impl TryFrom for RequestTemplate { } impl CacheKey for RequestTemplate { - fn cache_key(&self, ctx: &Ctx) -> u64 { + fn cache_key(&self, ctx: &Ctx) -> Option { let mut hasher = TailcallHasher::default(); let state = &mut hasher; @@ -251,7 +251,7 @@ impl CacheKey for RequestTemplate { let url = self.create_url(ctx).unwrap(); url.hash(state); - hasher.finish() + Some(hasher.finish()) } } @@ -739,7 +739,7 @@ mod tests { use crate::core::lambda::CacheKey; use crate::core::mustache::Mustache; - fn assert_no_duplicate(arr: [u64; N]) { + fn assert_no_duplicate(arr: [Option; N]) { let set = HashSet::from(arr); assert_eq!(arr.len(), set.len()); } diff --git a/src/core/lambda/cache.rs b/src/core/lambda/cache.rs index ca8ce9b732..2f393902c6 100644 --- a/src/core/lambda/cache.rs +++ b/src/core/lambda/cache.rs @@ -8,7 +8,7 @@ use async_graphql_value::ConstValue; use super::{Eval, EvaluationContext, EvaluationError, Expression, ResolverContextLike}; pub trait CacheKey { - fn cache_key(&self, ctx: &Ctx) -> u64; + fn cache_key(&self, ctx: &Ctx) -> Option; } #[derive(Clone, Debug)] @@ -41,17 +41,20 @@ impl Eval for Cache { Box::pin(async move { if let Expression::IO(io) = self.expr.deref() { let key = io.cache_key(&ctx); - - if let Some(val) = ctx.request_ctx.runtime.cache.get(&key).await? { - Ok(val) + if let Some(key) = key { + if let Some(val) = ctx.request_ctx.runtime.cache.get(&key).await? { + Ok(val) + } else { + let val = self.expr.eval(ctx.clone()).await?; + ctx.request_ctx + .runtime + .cache + .set(key, val.clone(), self.max_age) + .await?; + Ok(val) + } } else { - let val = self.expr.eval(ctx.clone()).await?; - ctx.request_ctx - .runtime - .cache - .set(key, val.clone(), self.max_age) - .await?; - Ok(val) + self.expr.eval(ctx).await } } else { Ok(self.expr.eval(ctx).await?) diff --git a/src/core/lambda/io.rs b/src/core/lambda/io.rs index b20aef5d95..cc93946755 100644 --- a/src/core/lambda/io.rs +++ b/src/core/lambda/io.rs @@ -52,12 +52,16 @@ impl Eval for IO { if ctx.request_ctx.upstream.dedupe { Box::pin(async move { let key = self.cache_key(&ctx); - ctx.request_ctx - .cache - .get_or_eval(key, move || Box::pin(async { self.eval_inner(ctx).await })) - .await - .as_ref() - .clone() + if let Some(key) = key { + ctx.request_ctx + .cache + .get_or_eval(key, move || Box::pin(self.eval_inner(ctx))) + .await + .as_ref() + .clone() + } else { + self.eval_inner(ctx).await + } }) } else { Box::pin(self.eval_inner(ctx)) @@ -139,7 +143,7 @@ impl IO { } impl<'a, Ctx: ResolverContextLike<'a> + Sync + Send> CacheKey> for IO { - fn cache_key(&self, ctx: &EvaluationContext<'a, Ctx>) -> u64 { + fn cache_key(&self, ctx: &EvaluationContext<'a, Ctx>) -> Option { match self { IO::Http { req_template, .. } => req_template.cache_key(ctx), IO::Grpc { req_template, .. } => req_template.cache_key(ctx), diff --git a/src/core/runtime.rs b/src/core/runtime.rs index a6d0b45c66..cb8495842c 100644 --- a/src/core/runtime.rs +++ b/src/core/runtime.rs @@ -95,10 +95,10 @@ pub mod test { let mut client = ClientBuilder::new(builder.build().expect("Failed to build client")); - if upstream.http_cache { + if upstream.http_cache > 0 { client = client.with(Cache(HttpCache { mode: CacheMode::Default, - manager: HttpCacheManager::default(), + manager: HttpCacheManager::new(upstream.http_cache), options: HttpCacheOptions::default(), })) } diff --git a/tailcall-aws-lambda/src/http.rs b/tailcall-aws-lambda/src/http.rs index 4cbdf82b37..a6dd7734c7 100644 --- a/tailcall-aws-lambda/src/http.rs +++ b/tailcall-aws-lambda/src/http.rs @@ -68,10 +68,15 @@ pub fn to_request(req: lambda_http::Request) -> anyhow::Result Arc { Arc::new(LambdaHttp::init()) } + +#[cfg(test)] +mod tests { + use lambda_http::http::{Method, Request, StatusCode, Uri}; + use lambda_http::Body; + + use super::*; + + #[tokio::test] + async fn test_to_request() { + let req = Request::builder() + .method(Method::GET) + .uri(Uri::from_static("http://example.com")) + .header("content-type", "application/json") + .header("x-custom-header", "custom-value") + .body(Body::from("Hello, world!")) + .unwrap(); + let hyper_req = to_request(req).unwrap(); + assert_eq!(hyper_req.method(), hyper::Method::GET); + assert_eq!(hyper_req.uri(), "http://example.com/"); + assert_eq!( + hyper_req.headers().get("content-type").unwrap(), + "application/json" + ); + assert_eq!( + hyper_req.headers().get("x-custom-header").unwrap(), + "custom-value" + ); + } + + #[tokio::test] + async fn test_to_response() { + let res = hyper::Response::builder() + .status(200) + .header("content-type", "application/json") + .header("x-custom-header", "custom-value") + .body(hyper::Body::from("Hello, world!")) + .unwrap(); + let lambda_res = to_response(res).await.unwrap(); + assert_eq!(lambda_res.status(), StatusCode::OK); + assert_eq!( + lambda_res.headers().get("content-type").unwrap(), + "application/json" + ); + assert_eq!( + lambda_res.headers().get("x-custom-header").unwrap(), + "custom-value" + ); + } +} diff --git a/tailcall-fixtures/fixtures/configs/user-posts.graphql b/tailcall-fixtures/fixtures/configs/user-posts.graphql index e45f9aa569..b3dfcfecf3 100644 --- a/tailcall-fixtures/fixtures/configs/user-posts.graphql +++ b/tailcall-fixtures/fixtures/configs/user-posts.graphql @@ -1,6 +1,6 @@ schema @server(port: 8000, hostname: "0.0.0.0") - @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: true) { + @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42) { query: Query } diff --git a/tailcall-http-cache/Cargo.toml b/tailcall-http-cache/Cargo.toml index c972e67997..15f391f4f2 100644 --- a/tailcall-http-cache/Cargo.toml +++ b/tailcall-http-cache/Cargo.toml @@ -6,6 +6,9 @@ publish = false [dependencies] http-cache-reqwest = { version = "0.13.0", default-features = false, features = ["manager-moka"] } +moka = { version = "0.12.7", default-features = false, features = [ + "future", +]} http-cache-semantics = { version = "1.0.1", default-features = false, features = ["with_serde", "reqwest"]} serde = "1.0.202" async-trait = "0.1.80" diff --git a/tailcall-http-cache/src/cache.rs b/tailcall-http-cache/src/cache.rs index 317d12aee1..7d53b1d759 100644 --- a/tailcall-http-cache/src/cache.rs +++ b/tailcall-http-cache/src/cache.rs @@ -1,18 +1,20 @@ -use http_cache_reqwest::{CacheManager, HttpResponse, MokaCache}; +use http_cache_reqwest::{CacheManager, HttpResponse}; use http_cache_semantics::CachePolicy; use serde::{Deserialize, Serialize}; pub type BoxError = Box; pub type Result = std::result::Result; - use std::sync::Arc; +use moka::future::Cache; +use moka::policy::EvictionPolicy; + pub struct HttpCacheManager { - pub cache: Arc>, + pub cache: Arc>, } impl Default for HttpCacheManager { fn default() -> Self { - Self::new(MokaCache::new(42)) + Self::new(42) } } @@ -23,7 +25,11 @@ pub struct Store { } impl HttpCacheManager { - pub fn new(cache: MokaCache) -> Self { + pub fn new(cache_size: u64) -> Self { + let cache = Cache::builder() + .eviction_policy(EvictionPolicy::lru()) + .max_capacity(cache_size) + .build(); Self { cache: Arc::new(cache) } } @@ -84,7 +90,7 @@ mod tests { Ok(Response::from(ret_res)) } - async fn insert_key_into_cache(manager: &HttpCacheManager) { + async fn insert_key_into_cache(manager: &HttpCacheManager, key: &str) { let request_url = "http://localhost:8080/test"; let url = Url::parse(request_url).unwrap(); @@ -101,7 +107,7 @@ mod tests { let _ = manager .put( - "test".to_string(), + key.to_string(), http_resp, CachePolicy::new(&request, &resp), ) @@ -112,14 +118,14 @@ mod tests { #[tokio::test] async fn test_put() { let manager = HttpCacheManager::default(); - insert_key_into_cache(&manager).await; + insert_key_into_cache(&manager, "test").await; assert!(manager.cache.contains_key("test")); } #[tokio::test] async fn test_get_when_key_present() { let manager = HttpCacheManager::default(); - insert_key_into_cache(&manager).await; + insert_key_into_cache(&manager, "test").await; let value = manager.get("test").await.unwrap(); assert!(value.is_some()); } @@ -134,7 +140,7 @@ mod tests { #[tokio::test] async fn test_delete_when_key_present() { let manager = HttpCacheManager::default(); - insert_key_into_cache(&manager).await; + insert_key_into_cache(&manager, "test").await; assert!(manager.cache.iter().count() as i32 == 1); let _ = manager.delete("test").await; @@ -144,9 +150,28 @@ mod tests { #[tokio::test] async fn test_clear() { let manager = HttpCacheManager::default(); - insert_key_into_cache(&manager).await; + insert_key_into_cache(&manager, "test").await; assert!(manager.cache.iter().count() as i32 == 1); let _ = manager.clear().await; assert!(manager.cache.iter().count() as i32 == 0); } + + #[tokio::test] + async fn test_lru_eviction_policy() { + let manager = HttpCacheManager::new(2); + insert_key_into_cache(&manager, "test-1").await; + insert_key_into_cache(&manager, "test-2").await; + insert_key_into_cache(&manager, "test-10").await; + + let res = manager.get("test-1").await.unwrap(); + assert!(res.is_none()); + + let res = manager.get("test-2").await.unwrap(); + assert!(res.is_some()); + + let res = manager.get("test-10").await.unwrap(); + assert!(res.is_some()); + + assert_eq!(manager.cache.entry_count(), 2); + } } diff --git a/tailcall-prettier/src/prettier.rs b/tailcall-prettier/src/prettier.rs index b196d667ce..832a5e74db 100644 --- a/tailcall-prettier/src/prettier.rs +++ b/tailcall-prettier/src/prettier.rs @@ -1,4 +1,6 @@ +use std::fs; use std::io::Write; +use std::path::Path; use std::process::{Command, Stdio}; use anyhow::{anyhow, Result}; @@ -7,6 +9,7 @@ pub use super::Parser; pub struct Prettier { runtime: tokio::runtime::Runtime, + config_path: Option, } impl Prettier { @@ -16,20 +19,27 @@ impl Prettier { .build() .unwrap(); - Self { runtime } + let config_path = fs::canonicalize(Path::new("./.prettierrc")) + .map(|a| a.display().to_string()) + .ok(); + Self { runtime, config_path } } pub async fn format<'a>(&'a self, source: String, parser: &'a Parser) -> Result { let parser = parser.clone(); + let config = self.config_path.clone(); self.runtime .spawn_blocking(move || { let mut command = command(); let mut child = command .arg("--stdin-filepath") - .arg(format!("file.{}", parser)) - .stdin(Stdio::piped()) - .stdout(Stdio::piped()) - .spawn()?; + .arg(format!("file.{}", parser)); + + if let Some(config) = config { + child = child.arg("--config").arg(config); + } + + let mut child = child.stdin(Stdio::piped()).stdout(Stdio::piped()).spawn()?; if let Some(ref mut stdin) = child.stdin { stdin.write_all(source.as_bytes())?; diff --git a/tests/core/snapshots/add-field-many-list.md_merged.snap b/tests/core/snapshots/add-field-many-list.md_merged.snap index e5802ae7b9..a3a8115a1f 100644 --- a/tests/core/snapshots/add-field-many-list.md_merged.snap +++ b/tests/core/snapshots/add-field-many-list.md_merged.snap @@ -1,6 +1,6 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- schema @server @upstream { query: Query @@ -16,7 +16,10 @@ type Query { u: U @http(baseURL: "http://jsonplaceholder.typicode.com", path: "/us/1") } -type U @addField(name: "b", path: ["a", "b"]) @addField(name: "c", path: ["a", "c"]) @addField(name: "d", path: ["a", "d"]) { +type U + @addField(name: "b", path: ["a", "b"]) + @addField(name: "c", path: ["a", "c"]) + @addField(name: "d", path: ["a", "d"]) { a: A e: String } diff --git a/tests/core/snapshots/add-field-many.md_merged.snap b/tests/core/snapshots/add-field-many.md_merged.snap index 647189833f..116351d1eb 100644 --- a/tests/core/snapshots/add-field-many.md_merged.snap +++ b/tests/core/snapshots/add-field-many.md_merged.snap @@ -1,12 +1,15 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- schema @server @upstream { query: Query } -type Foo @addField(name: "a", path: ["x", "a"]) @addField(name: "b", path: ["x", "b"]) @addField(name: "c", path: ["x", "c"]) { +type Foo + @addField(name: "a", path: ["x", "a"]) + @addField(name: "b", path: ["x", "b"]) + @addField(name: "c", path: ["x", "c"]) { name: String x: X } diff --git a/tests/core/snapshots/add-field-modify.md_merged.snap b/tests/core/snapshots/add-field-modify.md_merged.snap index 9c5aa370a1..520e038cf1 100644 --- a/tests/core/snapshots/add-field-modify.md_merged.snap +++ b/tests/core/snapshots/add-field-modify.md_merged.snap @@ -1,6 +1,6 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- schema @server @upstream { query: Query @@ -16,7 +16,10 @@ type Query { user: User @http(baseURL: "http://jsonplaceholder.typicode.com", path: "/users/1") } -type User @addField(name: "street", path: ["address", "street"]) @addField(name: "city", path: ["address", "city"]) @addField(name: "zipcode", path: ["address", "zipcode"]) { +type User + @addField(name: "street", path: ["address", "street"]) + @addField(name: "city", path: ["address", "city"]) + @addField(name: "zipcode", path: ["address", "zipcode"]) { address: Address name: String } diff --git a/tests/core/snapshots/add-field-with-composition.md_merged.snap b/tests/core/snapshots/add-field-with-composition.md_merged.snap index 973665cb76..257d3141d3 100644 --- a/tests/core/snapshots/add-field-with-composition.md_merged.snap +++ b/tests/core/snapshots/add-field-with-composition.md_merged.snap @@ -1,6 +1,6 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- schema @server @upstream { query: Query @@ -16,7 +16,9 @@ type Geo { lng: String } -type Query @addField(name: "lat", path: ["user", "address", "geo", "lat"]) @addField(name: "lng", path: ["user", "address", "geo", "lng"]) { +type Query + @addField(name: "lat", path: ["user", "address", "geo", "lat"]) + @addField(name: "lng", path: ["user", "address", "geo", "lng"]) { user: User @http(baseURL: "http://jsonplaceholder.typicode.com", path: "/users/1") } diff --git a/tests/core/snapshots/async-cache-enable-multiple-resolvers.md_merged.snap b/tests/core/snapshots/async-cache-enable-multiple-resolvers.md_merged.snap index b7c0ef74aa..71c14d8ddf 100644 --- a/tests/core/snapshots/async-cache-enable-multiple-resolvers.md_merged.snap +++ b/tests/core/snapshots/async-cache-enable-multiple-resolvers.md_merged.snap @@ -1,8 +1,10 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server(port: 8000, queryValidation: false) @upstream(baseURL: "http://jsonplaceholder.typicode.com", dedupe: true) { +schema + @server(port: 8000, queryValidation: false) + @upstream(baseURL: "http://jsonplaceholder.typicode.com", dedupe: true) { query: Query } diff --git a/tests/core/snapshots/async-cache-enabled.md_merged.snap b/tests/core/snapshots/async-cache-enabled.md_merged.snap index 2baa7e4203..6122c63f2b 100644 --- a/tests/core/snapshots/async-cache-enabled.md_merged.snap +++ b/tests/core/snapshots/async-cache-enabled.md_merged.snap @@ -1,8 +1,10 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server(port: 8000, queryValidation: false) @upstream(baseURL: "http://jsonplaceholder.typicode.com", dedupe: true) { +schema + @server(port: 8000, queryValidation: false) + @upstream(baseURL: "http://jsonplaceholder.typicode.com", dedupe: true) { query: Query } diff --git a/tests/core/snapshots/auth.md_merged.snap b/tests/core/snapshots/auth.md_merged.snap index f89a8e3187..9ad0fc322d 100644 --- a/tests/core/snapshots/auth.md_merged.snap +++ b/tests/core/snapshots/auth.md_merged.snap @@ -1,8 +1,12 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server @upstream @link(id: "htpasswd", src: ".htpasswd", type: Htpasswd) @link(id: "jwks", src: "jwks.json", type: Jwks) { +schema + @server + @upstream + @link(id: "htpasswd", src: ".htpasswd", type: Htpasswd) + @link(id: "jwks", src: "jwks.json", type: Jwks) { query: Query } diff --git a/tests/core/snapshots/batching-default.md_merged.snap b/tests/core/snapshots/batching-default.md_merged.snap index 0ef8726355..d81add832c 100644 --- a/tests/core/snapshots/batching-default.md_merged.snap +++ b/tests/core/snapshots/batching-default.md_merged.snap @@ -1,8 +1,10 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server @upstream(baseURL: "http://jsonplaceholder.typicode.com", batch: {delay: 10, headers: []}, httpCache: true) { +schema + @server + @upstream(baseURL: "http://jsonplaceholder.typicode.com", batch: {delay: 10, headers: []}, httpCache: 42) { query: Query } @@ -10,7 +12,12 @@ type Post { body: String id: Int title: String - user: User @http(batchKey: ["id"], path: "/users", query: [{key: "id", value: "{{.value.userId}}"}, {key: "foo", value: "bar"}]) + user: User + @http( + batchKey: ["id"] + path: "/users" + query: [{key: "id", value: "{{.value.userId}}"}, {key: "foo", value: "bar"}] + ) userId: Int! } diff --git a/tests/core/snapshots/batching-disabled.md_merged.snap b/tests/core/snapshots/batching-disabled.md_merged.snap index 30586519f5..9053b2bf07 100644 --- a/tests/core/snapshots/batching-disabled.md_merged.snap +++ b/tests/core/snapshots/batching-disabled.md_merged.snap @@ -1,8 +1,14 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server @upstream(baseURL: "http://jsonplaceholder.typicode.com", batch: {delay: 0, headers: [], maxSize: 100}, httpCache: true) { +schema + @server + @upstream( + baseURL: "http://jsonplaceholder.typicode.com" + batch: {delay: 0, headers: [], maxSize: 100} + httpCache: 42 + ) { query: Query } diff --git a/tests/core/snapshots/batching-group-by-default.md_merged.snap b/tests/core/snapshots/batching-group-by-default.md_merged.snap index 7dc15f9633..51c51251fd 100644 --- a/tests/core/snapshots/batching-group-by-default.md_merged.snap +++ b/tests/core/snapshots/batching-group-by-default.md_merged.snap @@ -1,8 +1,14 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server @upstream(baseURL: "http://jsonplaceholder.typicode.com", batch: {delay: 1, headers: [], maxSize: 1000}, httpCache: true) { +schema + @server + @upstream( + baseURL: "http://jsonplaceholder.typicode.com" + batch: {delay: 1, headers: [], maxSize: 1000} + httpCache: 42 + ) { query: Query } @@ -10,7 +16,12 @@ type Post { body: String id: Int title: String - user: User @http(batchKey: ["id"], path: "/users", query: [{key: "id", value: "{{.value.userId}}"}, {key: "foo", value: "bar"}]) + user: User + @http( + batchKey: ["id"] + path: "/users" + query: [{key: "id", value: "{{.value.userId}}"}, {key: "foo", value: "bar"}] + ) userId: Int! } diff --git a/tests/core/snapshots/batching-group-by.md_merged.snap b/tests/core/snapshots/batching-group-by.md_merged.snap index 2b75106aca..ed1ac72b40 100644 --- a/tests/core/snapshots/batching-group-by.md_merged.snap +++ b/tests/core/snapshots/batching-group-by.md_merged.snap @@ -1,8 +1,14 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server(port: 8000, queryValidation: false) @upstream(baseURL: "http://jsonplaceholder.typicode.com", batch: {delay: 1, headers: [], maxSize: 1000}, httpCache: true) { +schema + @server(port: 8000, queryValidation: false) + @upstream( + baseURL: "http://jsonplaceholder.typicode.com" + batch: {delay: 1, headers: [], maxSize: 1000} + httpCache: 42 + ) { query: Query } @@ -10,7 +16,12 @@ type Post { body: String id: Int title: String - user: User @http(batchKey: ["id"], path: "/users", query: [{key: "id", value: "{{.value.userId}}"}, {key: "foo", value: "bar"}]) + user: User + @http( + batchKey: ["id"] + path: "/users" + query: [{key: "id", value: "{{.value.userId}}"}, {key: "foo", value: "bar"}] + ) userId: Int! } diff --git a/tests/core/snapshots/batching-post.md_merged.snap b/tests/core/snapshots/batching-post.md_merged.snap index 34b9791fe7..461c1973b0 100644 --- a/tests/core/snapshots/batching-post.md_merged.snap +++ b/tests/core/snapshots/batching-post.md_merged.snap @@ -1,8 +1,14 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server(port: 8000, queryValidation: false) @upstream(baseURL: "http://jsonplaceholder.typicode.com", batch: {delay: 1, headers: [], maxSize: 1000}, httpCache: true) { +schema + @server(port: 8000, queryValidation: false) + @upstream( + baseURL: "http://jsonplaceholder.typicode.com" + batch: {delay: 1, headers: [], maxSize: 1000} + httpCache: 42 + ) { query: Query } diff --git a/tests/core/snapshots/cache-control.md_merged.snap b/tests/core/snapshots/cache-control.md_merged.snap index ce75b519b4..b987165bb2 100644 --- a/tests/core/snapshots/cache-control.md_merged.snap +++ b/tests/core/snapshots/cache-control.md_merged.snap @@ -1,13 +1,14 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- schema @server(headers: {cacheControl: true}) @upstream { query: Query } type Query { - user(id: Int): User @http(baseURL: "http://jsonplaceholder.typicode.com", path: "/users", query: [{key: "id", value: "{{.args.id}}"}]) + user(id: Int): User + @http(baseURL: "http://jsonplaceholder.typicode.com", path: "/users", query: [{key: "id", value: "{{.args.id}}"}]) } type User { diff --git a/tests/core/snapshots/call-graphql-datasource.md_merged.snap b/tests/core/snapshots/call-graphql-datasource.md_merged.snap index 12db968e5d..d99c0b0ddc 100644 --- a/tests/core/snapshots/call-graphql-datasource.md_merged.snap +++ b/tests/core/snapshots/call-graphql-datasource.md_merged.snap @@ -1,8 +1,10 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server(hostname: "0.0.0.0", port: 8000) @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: true) { +schema + @server(hostname: "0.0.0.0", port: 8000) + @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42) { query: Query } @@ -16,7 +18,8 @@ type Post { type Query { posts: [Post] @http(path: "/posts") - user(id: Int!): User @graphQL(args: [{key: "id", value: "{{.args.id}}"}], baseURL: "http://upstream/graphql", name: "user") + user(id: Int!): User + @graphQL(args: [{key: "id", value: "{{.args.id}}"}], baseURL: "http://upstream/graphql", name: "user") } type User { diff --git a/tests/core/snapshots/call-multiple-steps-piping.md_merged.snap b/tests/core/snapshots/call-multiple-steps-piping.md_merged.snap index d9d2d3a8ef..64fce1675f 100644 --- a/tests/core/snapshots/call-multiple-steps-piping.md_merged.snap +++ b/tests/core/snapshots/call-multiple-steps-piping.md_merged.snap @@ -1,6 +1,6 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- schema @server @upstream { query: Query @@ -9,8 +9,27 @@ schema @server @upstream { type Query { a(input: JSON): JSON @expr(body: "{{.args.input.a}}") a_input(input: JSON): JSON @expr(body: {input: "{{.args.input.a}}"}) - abc(input: JSON): JSON @call(steps: [{query: "a", args: {input: "{{.args.input}}"}}, {query: "wrap_args"}, {query: "b"}, {query: "wrap_args"}, {query: "c"}]) - abc_input(input: JSON): JSON @call(steps: [{query: "wrap_input", args: {input: "{{.args.input}}"}}, {query: "a_input"}, {query: "wrap_input"}, {query: "b_input"}, {query: "wrap_input"}, {query: "c"}]) + abc(input: JSON): JSON + @call( + steps: [ + {query: "a", args: {input: "{{.args.input}}"}} + {query: "wrap_args"} + {query: "b"} + {query: "wrap_args"} + {query: "c"} + ] + ) + abc_input(input: JSON): JSON + @call( + steps: [ + {query: "wrap_input", args: {input: "{{.args.input}}"}} + {query: "a_input"} + {query: "wrap_input"} + {query: "b_input"} + {query: "wrap_input"} + {query: "c"} + ] + ) b(input: JSON): JSON @expr(body: "{{.args.input.b}}") b_input(input: JSON): JSON @expr(body: {input: "{{.args.input.b}}"}) c(input: JSON): JSON @expr(body: "{{.args.input.c}}") diff --git a/tests/core/snapshots/call-mutation.md_merged.snap b/tests/core/snapshots/call-mutation.md_merged.snap index 4684f682f2..ee40791749 100644 --- a/tests/core/snapshots/call-mutation.md_merged.snap +++ b/tests/core/snapshots/call-mutation.md_merged.snap @@ -1,6 +1,6 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- schema @server @upstream(baseURL: "http://jsonplaceholder.typicode.com") { query: Query @@ -20,12 +20,17 @@ input PostInputWithoutUserId { } type Mutation { - attachPostToFirstUser(postId: Int!): User @call(steps: [{mutation: "attachPostToUser", args: {postId: "{{.args.postId}}", userId: 1}}]) - attachPostToUser(postId: Int!, userId: Int!): User @http(body: "{\"postId\":{{.args.postId}}}", method: "PATCH", path: "/users/{{.args.userId}}") - insertMockedPost: Post @call(steps: [{mutation: "insertPost", args: {input: {body: "post-body", title: "post-title", userId: 1}}}]) + attachPostToFirstUser(postId: Int!): User + @call(steps: [{mutation: "attachPostToUser", args: {postId: "{{.args.postId}}", userId: 1}}]) + attachPostToUser(postId: Int!, userId: Int!): User + @http(body: "{\"postId\":{{.args.postId}}}", method: "PATCH", path: "/users/{{.args.userId}}") + insertMockedPost: Post + @call(steps: [{mutation: "insertPost", args: {input: {body: "post-body", title: "post-title", userId: 1}}}]) insertPost(input: PostInput): Post @http(body: "{{.args.input}}", method: "POST", path: "/posts") - insertPostToFirstUser(input: PostInputWithoutUserId): Post @call(steps: [{mutation: "insertPostToUser", args: {input: "{{.args.input}}", userId: 1}}]) - insertPostToUser(input: PostInputWithoutUserId!, userId: Int!): Post @http(body: "{{.args.input}}", method: "POST", path: "/users/{{.args.userId}}/posts") + insertPostToFirstUser(input: PostInputWithoutUserId): Post + @call(steps: [{mutation: "insertPostToUser", args: {input: "{{.args.input}}", userId: 1}}]) + insertPostToUser(input: PostInputWithoutUserId!, userId: Int!): Post + @http(body: "{{.args.input}}", method: "POST", path: "/users/{{.args.userId}}/posts") } type Post { diff --git a/tests/core/snapshots/call-operator.md_merged.snap b/tests/core/snapshots/call-operator.md_merged.snap index dc9d89aabc..757ed26cbf 100644 --- a/tests/core/snapshots/call-operator.md_merged.snap +++ b/tests/core/snapshots/call-operator.md_merged.snap @@ -1,8 +1,11 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server(hostname: "0.0.0.0", port: 8000) @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: true) @link(id: "news", src: "news.proto", type: Protobuf) { +schema + @server(hostname: "0.0.0.0", port: 8000) + @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42) + @link(id: "news", src: "news.proto", type: Protobuf) { query: Query } @@ -35,13 +38,16 @@ type Post { type Query { news: NewsData! @grpc(baseURL: "http://localhost:50051", method: "news.NewsService.GetAllNews") - newsWithPortArg(port: Int!): NewsData! @grpc(baseURL: "http://localhost:{{.args.port}}", method: "news.NewsService.GetAllNews") + newsWithPortArg(port: Int!): NewsData! + @grpc(baseURL: "http://localhost:{{.args.port}}", method: "news.NewsService.GetAllNews") posts: [Post] @http(path: "/posts") user(id: Int!): User @http(path: "/users/{{.args.id}}") user1: User @http(path: "/users/1") userFromValue: User @http(path: "/users/{{.value.userId}}") - userGraphQL(id: Int): User @graphQL(args: [{key: "id", value: "{{.args.id}}"}], baseURL: "http://upstream/graphql", name: "user") - userGraphQLHeaders(id: Int!): User @graphQL(baseURL: "http://upstream/graphql", headers: [{key: "id", value: "{{.args.id}}"}], name: "user") + userGraphQL(id: Int): User + @graphQL(args: [{key: "id", value: "{{.args.id}}"}], baseURL: "http://upstream/graphql", name: "user") + userGraphQLHeaders(id: Int!): User + @graphQL(baseURL: "http://upstream/graphql", headers: [{key: "id", value: "{{.args.id}}"}], name: "user") userHttpHeaders(id: ID!): User @http(headers: [{key: "id", value: "{{.args.id}}"}], path: "/users") userHttpQuery(id: ID!): User @http(path: "/users", query: [{key: "id", value: "{{.args.id}}"}]) userId: Int! @expr(body: 2) diff --git a/tests/core/snapshots/cors-allow-cred-false.md_merged.snap b/tests/core/snapshots/cors-allow-cred-false.md_merged.snap index 3d1469055a..fd0444e0dc 100644 --- a/tests/core/snapshots/cors-allow-cred-false.md_merged.snap +++ b/tests/core/snapshots/cors-allow-cred-false.md_merged.snap @@ -1,8 +1,21 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server(headers: {cors: {allowHeaders: ["Authorization"], allowMethods: ["POST", "OPTIONS"], allowOrigins: ["abc.com", "xyz.com"], allowPrivateNetwork: true, maxAge: 23, vary: ["origin", "access-control-request-method", "access-control-request-headers"]}}) @upstream(baseURL: "http://example.com", batch: {delay: 1, headers: [], maxSize: 1000}) { +schema + @server( + headers: { + cors: { + allowHeaders: ["Authorization"] + allowMethods: ["POST", "OPTIONS"] + allowOrigins: ["abc.com", "xyz.com"] + allowPrivateNetwork: true + maxAge: 23 + vary: ["origin", "access-control-request-method", "access-control-request-headers"] + } + } + ) + @upstream(baseURL: "http://example.com", batch: {delay: 1, headers: [], maxSize: 1000}) { query: Query } diff --git a/tests/core/snapshots/cors-allow-cred-true.md_merged.snap b/tests/core/snapshots/cors-allow-cred-true.md_merged.snap index 93e6b8bb82..13287b6775 100644 --- a/tests/core/snapshots/cors-allow-cred-true.md_merged.snap +++ b/tests/core/snapshots/cors-allow-cred-true.md_merged.snap @@ -1,8 +1,21 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server(headers: {cors: {allowCredentials: true, allowMethods: ["OPTIONS", "POST", "GET"], allowOrigins: ["abc.com", "xyz.com"], exposeHeaders: [""], maxAge: 23, vary: ["origin", "access-control-request-method", "access-control-request-headers"]}}) @upstream(baseURL: "http://example.com", batch: {delay: 1, headers: [], maxSize: 1000}) { +schema + @server( + headers: { + cors: { + allowCredentials: true + allowMethods: ["OPTIONS", "POST", "GET"] + allowOrigins: ["abc.com", "xyz.com"] + exposeHeaders: [""] + maxAge: 23 + vary: ["origin", "access-control-request-method", "access-control-request-headers"] + } + } + ) + @upstream(baseURL: "http://example.com", batch: {delay: 1, headers: [], maxSize: 1000}) { query: Query } diff --git a/tests/core/snapshots/cors-allow-cred-vary.md_merged.snap b/tests/core/snapshots/cors-allow-cred-vary.md_merged.snap index 93e6b8bb82..13287b6775 100644 --- a/tests/core/snapshots/cors-allow-cred-vary.md_merged.snap +++ b/tests/core/snapshots/cors-allow-cred-vary.md_merged.snap @@ -1,8 +1,21 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server(headers: {cors: {allowCredentials: true, allowMethods: ["OPTIONS", "POST", "GET"], allowOrigins: ["abc.com", "xyz.com"], exposeHeaders: [""], maxAge: 23, vary: ["origin", "access-control-request-method", "access-control-request-headers"]}}) @upstream(baseURL: "http://example.com", batch: {delay: 1, headers: [], maxSize: 1000}) { +schema + @server( + headers: { + cors: { + allowCredentials: true + allowMethods: ["OPTIONS", "POST", "GET"] + allowOrigins: ["abc.com", "xyz.com"] + exposeHeaders: [""] + maxAge: 23 + vary: ["origin", "access-control-request-method", "access-control-request-headers"] + } + } + ) + @upstream(baseURL: "http://example.com", batch: {delay: 1, headers: [], maxSize: 1000}) { query: Query } diff --git a/tests/core/snapshots/graphql-dataloader-batch-request.md_merged.snap b/tests/core/snapshots/graphql-dataloader-batch-request.md_merged.snap index 2f76478dfa..2e58baa40f 100644 --- a/tests/core/snapshots/graphql-dataloader-batch-request.md_merged.snap +++ b/tests/core/snapshots/graphql-dataloader-batch-request.md_merged.snap @@ -1,6 +1,6 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- schema @server @upstream(batch: {delay: 1, headers: []}) { query: Query @@ -9,7 +9,13 @@ schema @server @upstream(batch: {delay: 1, headers: []}) { type Post { id: Int title: String - user: User @graphQL(args: [{key: "id", value: "{{.value.userId}}"}], baseURL: "http://upstream/graphql", batch: true, name: "user") + user: User + @graphQL( + args: [{key: "id", value: "{{.value.userId}}"}] + baseURL: "http://upstream/graphql" + batch: true + name: "user" + ) userId: Int } diff --git a/tests/core/snapshots/graphql-datasource-errors.md_merged.snap b/tests/core/snapshots/graphql-datasource-errors.md_merged.snap index 8dfbfa8b10..d48edf4f44 100644 --- a/tests/core/snapshots/graphql-datasource-errors.md_merged.snap +++ b/tests/core/snapshots/graphql-datasource-errors.md_merged.snap @@ -1,13 +1,14 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- schema @server @upstream { query: Query } type Query { - user(id: Int): User @graphQL(args: [{key: "id", value: "{{.args.id}}"}], baseURL: "http://upstream/graphql", name: "user") + user(id: Int): User + @graphQL(args: [{key: "id", value: "{{.args.id}}"}], baseURL: "http://upstream/graphql", name: "user") } type User { diff --git a/tests/core/snapshots/graphql-datasource-mutation.md_merged.snap b/tests/core/snapshots/graphql-datasource-mutation.md_merged.snap index 3cd8c33c5b..d2c986e266 100644 --- a/tests/core/snapshots/graphql-datasource-mutation.md_merged.snap +++ b/tests/core/snapshots/graphql-datasource-mutation.md_merged.snap @@ -1,6 +1,6 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- schema @server @upstream { query: Query @@ -14,7 +14,8 @@ input UserInput { } type Mutation { - createUser(user: UserInput!): User @graphQL(args: [{key: "user", value: "{{.args.user}}"}], baseURL: "http://upstream/graphql", name: "createUser") + createUser(user: UserInput!): User + @graphQL(args: [{key: "user", value: "{{.args.user}}"}], baseURL: "http://upstream/graphql", name: "createUser") } type Query { diff --git a/tests/core/snapshots/graphql-datasource-with-args.md_merged.snap b/tests/core/snapshots/graphql-datasource-with-args.md_merged.snap index e84cc42c8a..beb3b66e16 100644 --- a/tests/core/snapshots/graphql-datasource-with-args.md_merged.snap +++ b/tests/core/snapshots/graphql-datasource-with-args.md_merged.snap @@ -1,6 +1,6 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- schema @server @upstream { query: Query @@ -12,8 +12,10 @@ type Post { } type Query { - post(id: Int): Post @graphQL(args: [{key: "id", value: "{{.args.id}}"}], baseURL: "http://upstream/graphql", name: "post") - user(id: Int): User @graphQL(args: [{key: "id", value: "{{.args.id}}"}], baseURL: "http://upstream/graphql", name: "user") + post(id: Int): Post + @graphQL(args: [{key: "id", value: "{{.args.id}}"}], baseURL: "http://upstream/graphql", name: "post") + user(id: Int): User + @graphQL(args: [{key: "id", value: "{{.args.id}}"}], baseURL: "http://upstream/graphql", name: "user") } type User { diff --git a/tests/core/snapshots/grpc-batch.md_merged.snap b/tests/core/snapshots/grpc-batch.md_merged.snap index 26d6e41803..8e98e9f969 100644 --- a/tests/core/snapshots/grpc-batch.md_merged.snap +++ b/tests/core/snapshots/grpc-batch.md_merged.snap @@ -1,8 +1,11 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server(port: 8000) @upstream(batch: {delay: 10, headers: []}, httpCache: true) @link(id: "news", src: "news.proto", type: Protobuf) { +schema + @server(port: 8000) + @upstream(batch: {delay: 10, headers: []}, httpCache: 42) + @link(id: "news", src: "news.proto", type: Protobuf) { query: Query } @@ -26,5 +29,11 @@ type NewsData { type Query { news: NewsData! @grpc(baseURL: "http://localhost:50051", method: "news.NewsService.GetAllNews") - newsById(news: NewsInput!): News! @grpc(baseURL: "http://localhost:50051", body: "{{.args.news}}", batchKey: ["news", "id"], method: "news.NewsService.GetMultipleNews") + newsById(news: NewsInput!): News! + @grpc( + baseURL: "http://localhost:50051" + body: "{{.args.news}}" + batchKey: ["news", "id"] + method: "news.NewsService.GetMultipleNews" + ) } diff --git a/tests/core/snapshots/grpc-error.md_merged.snap b/tests/core/snapshots/grpc-error.md_merged.snap index 385aa86cce..1f0a6c0194 100644 --- a/tests/core/snapshots/grpc-error.md_merged.snap +++ b/tests/core/snapshots/grpc-error.md_merged.snap @@ -1,8 +1,11 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server(port: 8000) @upstream(batch: {delay: 10, headers: []}, httpCache: true) @link(id: "news", src: "news.proto", type: Protobuf) { +schema + @server(port: 8000) + @upstream(batch: {delay: 10, headers: []}, httpCache: 42) + @link(id: "news", src: "news.proto", type: Protobuf) { query: Query } @@ -26,5 +29,6 @@ type NewsData { type Query { news: NewsData! @grpc(baseURL: "http://localhost:50051", method: "news.NewsService.GetAllNews") - newsById(news: NewsInput!): News! @grpc(baseURL: "http://localhost:50051", body: "{{.args.news}}", method: "news.NewsService.GetNews") + newsById(news: NewsInput!): News! + @grpc(baseURL: "http://localhost:50051", body: "{{.args.news}}", method: "news.NewsService.GetNews") } diff --git a/tests/core/snapshots/grpc-map.md_merged.snap b/tests/core/snapshots/grpc-map.md_merged.snap index 2b1fd8cb85..2228f6bcc4 100644 --- a/tests/core/snapshots/grpc-map.md_merged.snap +++ b/tests/core/snapshots/grpc-map.md_merged.snap @@ -1,8 +1,11 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server(port: 8000) @upstream(baseURL: "http://localhost:50051", batch: {delay: 10, headers: []}, httpCache: true) @link(src: "map.proto", type: Protobuf) { +schema + @server(port: 8000) + @upstream(baseURL: "http://localhost:50051", batch: {delay: 10, headers: []}, httpCache: 42) + @link(src: "map.proto", type: Protobuf) { query: Query } @@ -11,7 +14,8 @@ input map__MapRequest { } type Query { - map__MapService__GetMap(mapRequest: map__MapRequest!): map__MapResponse! @grpc(body: "{{.args.mapRequest}}", method: "map.MapService.GetMap") + map__MapService__GetMap(mapRequest: map__MapRequest!): map__MapResponse! + @grpc(body: "{{.args.mapRequest}}", method: "map.MapService.GetMap") } type map__MapResponse @tag(id: "map.MapResponse") { diff --git a/tests/core/snapshots/grpc-override-url-from-upstream.md_merged.snap b/tests/core/snapshots/grpc-override-url-from-upstream.md_merged.snap index b4310be979..8c57437643 100644 --- a/tests/core/snapshots/grpc-override-url-from-upstream.md_merged.snap +++ b/tests/core/snapshots/grpc-override-url-from-upstream.md_merged.snap @@ -1,8 +1,11 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server(port: 8000) @upstream(baseURL: "http://not-a-valid-grpc-url.com", batch: {delay: 10, headers: []}, httpCache: true) @link(id: "news", src: "news.proto", type: Protobuf) { +schema + @server(port: 8000) + @upstream(baseURL: "http://not-a-valid-grpc-url.com", batch: {delay: 10, headers: []}, httpCache: 42) + @link(id: "news", src: "news.proto", type: Protobuf) { query: Query } @@ -26,5 +29,6 @@ type NewsData { type Query { news: NewsData! @grpc(baseURL: "http://localhost:50051", method: "news.NewsService.GetAllNews") - newsById(news: NewsInput!): News! @grpc(baseURL: "http://localhost:50051", body: "{{.args.news}}", method: "news.NewsService.GetNews") + newsById(news: NewsInput!): News! + @grpc(baseURL: "http://localhost:50051", body: "{{.args.news}}", method: "news.NewsService.GetNews") } diff --git a/tests/core/snapshots/grpc-proto-with-same-package.md_merged.snap b/tests/core/snapshots/grpc-proto-with-same-package.md_merged.snap index 627c602738..36c170df71 100644 --- a/tests/core/snapshots/grpc-proto-with-same-package.md_merged.snap +++ b/tests/core/snapshots/grpc-proto-with-same-package.md_merged.snap @@ -1,8 +1,12 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server(port: 8000) @upstream(baseURL: "http://localhost:50051") @link(src: "foo.proto", type: Protobuf) @link(src: "bar.proto", type: Protobuf) { +schema + @server(port: 8000) + @upstream(baseURL: "http://localhost:50051") + @link(src: "foo.proto", type: Protobuf) + @link(src: "bar.proto", type: Protobuf) { query: Query } diff --git a/tests/core/snapshots/grpc-reflection.md_merged.snap b/tests/core/snapshots/grpc-reflection.md_merged.snap index 3588897f4b..4ca7accb96 100644 --- a/tests/core/snapshots/grpc-reflection.md_merged.snap +++ b/tests/core/snapshots/grpc-reflection.md_merged.snap @@ -1,8 +1,11 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server(port: 8000) @upstream(baseURL: "http://localhost:50051", httpCache: true) @link(src: "http://localhost:50051", type: Grpc) { +schema + @server(port: 8000) + @upstream(baseURL: "http://localhost:50051", httpCache: 42) + @link(src: "http://localhost:50051", type: Grpc) { query: Query } diff --git a/tests/core/snapshots/grpc-simple.md_merged.snap b/tests/core/snapshots/grpc-simple.md_merged.snap index 9751b57650..68f0569573 100644 --- a/tests/core/snapshots/grpc-simple.md_merged.snap +++ b/tests/core/snapshots/grpc-simple.md_merged.snap @@ -1,8 +1,11 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server(port: 8000) @upstream(baseURL: "http://localhost:50051", batch: {delay: 10, headers: []}, httpCache: true) @link(id: "news", src: "news.proto", type: Protobuf) { +schema + @server(port: 8000) + @upstream(baseURL: "http://localhost:50051", batch: {delay: 10, headers: []}, httpCache: 42) + @link(id: "news", src: "news.proto", type: Protobuf) { query: Query } diff --git a/tests/core/snapshots/grpc-url-from-upstream.md_merged.snap b/tests/core/snapshots/grpc-url-from-upstream.md_merged.snap index ccab578907..017ee069e3 100644 --- a/tests/core/snapshots/grpc-url-from-upstream.md_merged.snap +++ b/tests/core/snapshots/grpc-url-from-upstream.md_merged.snap @@ -1,8 +1,11 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server(port: 8000) @upstream(baseURL: "http://localhost:50051", batch: {delay: 10, headers: []}, httpCache: true) @link(id: "news", src: "news.proto", type: Protobuf) { +schema + @server(port: 8000) + @upstream(baseURL: "http://localhost:50051", batch: {delay: 10, headers: []}, httpCache: 42) + @link(id: "news", src: "news.proto", type: Protobuf) { query: Query } diff --git a/tests/core/snapshots/inline-many-list.md_merged.snap b/tests/core/snapshots/inline-many-list.md_merged.snap index 948144023f..0815875a14 100644 --- a/tests/core/snapshots/inline-many-list.md_merged.snap +++ b/tests/core/snapshots/inline-many-list.md_merged.snap @@ -1,6 +1,6 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- schema @server @upstream { query: Query @@ -16,7 +16,10 @@ type Query { u: U @http(baseURL: "http://jsonplaceholder.typicode.com", path: "/us/1") } -type U @addField(name: "b", path: ["a", "b"]) @addField(name: "c", path: ["a", "c"]) @addField(name: "d", path: ["a", "d"]) { +type U + @addField(name: "b", path: ["a", "b"]) + @addField(name: "c", path: ["a", "c"]) + @addField(name: "d", path: ["a", "d"]) { a: A @modify(omit: true) e: String } diff --git a/tests/core/snapshots/inline-many.md_merged.snap b/tests/core/snapshots/inline-many.md_merged.snap index 480ebd722d..8b477cb9f1 100644 --- a/tests/core/snapshots/inline-many.md_merged.snap +++ b/tests/core/snapshots/inline-many.md_merged.snap @@ -1,6 +1,6 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- schema @server @upstream { query: Query @@ -16,7 +16,10 @@ type Query { user: User @http(baseURL: "http://jsonplaceholder.typicode.com", path: "/users/1") } -type User @addField(name: "city", path: ["address", "city"]) @addField(name: "street", path: ["address", "street"]) @addField(name: "zipcode", path: ["address", "zipcode"]) { +type User + @addField(name: "city", path: ["address", "city"]) + @addField(name: "street", path: ["address", "street"]) + @addField(name: "zipcode", path: ["address", "zipcode"]) { address: Address @modify(omit: true) name: String } diff --git a/tests/core/snapshots/io-cache.md_merged.snap b/tests/core/snapshots/io-cache.md_merged.snap index 87b91f625b..a30fcb2e35 100644 --- a/tests/core/snapshots/io-cache.md_merged.snap +++ b/tests/core/snapshots/io-cache.md_merged.snap @@ -1,8 +1,10 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server(hostname: "0.0.0.0", port: 8000) @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: true) { +schema + @server(hostname: "0.0.0.0", port: 8000) + @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42) { query: Query } diff --git a/tests/core/snapshots/jsonplaceholder-call-post.md_merged.snap b/tests/core/snapshots/jsonplaceholder-call-post.md_merged.snap index e49ac9d01a..ace551158a 100644 --- a/tests/core/snapshots/jsonplaceholder-call-post.md_merged.snap +++ b/tests/core/snapshots/jsonplaceholder-call-post.md_merged.snap @@ -1,8 +1,10 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server(hostname: "0.0.0.0", port: 8000) @upstream(baseURL: "http://jsonplaceholder.typicode.com", batch: {delay: 100, headers: []}, httpCache: true) { +schema + @server(hostname: "0.0.0.0", port: 8000) + @upstream(baseURL: "http://jsonplaceholder.typicode.com", batch: {delay: 100, headers: []}, httpCache: 42) { query: Query } diff --git a/tests/core/snapshots/nullable-arg-query.md_merged.snap b/tests/core/snapshots/nullable-arg-query.md_merged.snap index 1ca244272c..fe601bc3fb 100644 --- a/tests/core/snapshots/nullable-arg-query.md_merged.snap +++ b/tests/core/snapshots/nullable-arg-query.md_merged.snap @@ -1,13 +1,14 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- schema @server @upstream { query: Query } type Query { - users(id: ID): [User] @http(baseURL: "http://jsonplaceholder.typicode.com", path: "/users", query: [{key: "id", value: "{{.args.id}}"}]) + users(id: ID): [User] + @http(baseURL: "http://jsonplaceholder.typicode.com", path: "/users", query: [{key: "id", value: "{{.args.id}}"}]) } type User { diff --git a/tests/core/snapshots/omit-many.md_merged.snap b/tests/core/snapshots/omit-many.md_merged.snap index 8a9c853868..0cf54fc9f7 100644 --- a/tests/core/snapshots/omit-many.md_merged.snap +++ b/tests/core/snapshots/omit-many.md_merged.snap @@ -1,6 +1,6 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- schema @server @upstream { query: Query @@ -17,7 +17,9 @@ type Query { user: User @http(baseURL: "http://jsonplaceholder.typicode.com", path: "/users/1") } -type User @addField(name: "zipcode", path: ["address", "zipcode"]) @addField(name: "complements", path: ["address", "complements"]) { +type User + @addField(name: "zipcode", path: ["address", "zipcode"]) + @addField(name: "complements", path: ["address", "complements"]) { address: Address @omit name: String } diff --git a/tests/core/snapshots/recursive-type-json.md_merged.snap b/tests/core/snapshots/recursive-type-json.md_merged.snap index 1920b7efbb..1e9694e922 100644 --- a/tests/core/snapshots/recursive-type-json.md_merged.snap +++ b/tests/core/snapshots/recursive-type-json.md_merged.snap @@ -2,7 +2,7 @@ source: tests/core/spec.rs expression: merged --- -schema @server @upstream(baseURL: "https://jsonplaceholder.typicode.com", httpCache: true) { +schema @server @upstream(baseURL: "https://jsonplaceholder.typicode.com", httpCache: 42) { query: Query } diff --git a/tests/core/snapshots/request-to-upstream-batching.md_merged.snap b/tests/core/snapshots/request-to-upstream-batching.md_merged.snap index b72e0d430f..94404e77e9 100644 --- a/tests/core/snapshots/request-to-upstream-batching.md_merged.snap +++ b/tests/core/snapshots/request-to-upstream-batching.md_merged.snap @@ -1,13 +1,19 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- schema @server(batchRequests: true) @upstream(batch: {delay: 1, headers: [], maxSize: 100}) { query: Query } type Query { - user(id: Int!): User @http(baseURL: "http://jsonplaceholder.typicode.com", batchKey: ["id"], path: "/users", query: [{key: "id", value: "{{.args.id}}"}]) + user(id: Int!): User + @http( + baseURL: "http://jsonplaceholder.typicode.com" + batchKey: ["id"] + path: "/users" + query: [{key: "id", value: "{{.args.id}}"}] + ) } type User { diff --git a/tests/core/snapshots/resolve-with-vars.md_merged.snap b/tests/core/snapshots/resolve-with-vars.md_merged.snap index a3cc637dd8..2ea04d7d21 100644 --- a/tests/core/snapshots/resolve-with-vars.md_merged.snap +++ b/tests/core/snapshots/resolve-with-vars.md_merged.snap @@ -1,13 +1,14 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- schema @server(vars: [{key: "id", value: "1"}]) @upstream { query: Query } type Query { - user: [User] @http(baseURL: "http://jsonplaceholder.typicode.com", path: "/users", query: [{key: "id", value: "{{.vars.id}}"}]) + user: [User] + @http(baseURL: "http://jsonplaceholder.typicode.com", path: "/users", query: [{key: "id", value: "{{.vars.id}}"}]) } type User { diff --git a/tests/core/snapshots/rest-api-error.md_merged.snap b/tests/core/snapshots/rest-api-error.md_merged.snap index 7ef5777788..eb5274189a 100644 --- a/tests/core/snapshots/rest-api-error.md_merged.snap +++ b/tests/core/snapshots/rest-api-error.md_merged.snap @@ -1,8 +1,11 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server @upstream(baseURL: "http://jsonplaceholder.typicode.com") @link(src: "operation-user.graphql", type: Operation) { +schema + @server + @upstream(baseURL: "http://jsonplaceholder.typicode.com") + @link(src: "operation-user.graphql", type: Operation) { query: Query } diff --git a/tests/core/snapshots/rest-api-post.md_merged.snap b/tests/core/snapshots/rest-api-post.md_merged.snap index 7ef5777788..eb5274189a 100644 --- a/tests/core/snapshots/rest-api-post.md_merged.snap +++ b/tests/core/snapshots/rest-api-post.md_merged.snap @@ -1,8 +1,11 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server @upstream(baseURL: "http://jsonplaceholder.typicode.com") @link(src: "operation-user.graphql", type: Operation) { +schema + @server + @upstream(baseURL: "http://jsonplaceholder.typicode.com") + @link(src: "operation-user.graphql", type: Operation) { query: Query } diff --git a/tests/core/snapshots/rest-api.md_merged.snap b/tests/core/snapshots/rest-api.md_merged.snap index 7ef5777788..eb5274189a 100644 --- a/tests/core/snapshots/rest-api.md_merged.snap +++ b/tests/core/snapshots/rest-api.md_merged.snap @@ -1,8 +1,11 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server @upstream(baseURL: "http://jsonplaceholder.typicode.com") @link(src: "operation-user.graphql", type: Operation) { +schema + @server + @upstream(baseURL: "http://jsonplaceholder.typicode.com") + @link(src: "operation-user.graphql", type: Operation) { query: Query } diff --git a/tests/core/snapshots/test-enum-default.md_merged.snap b/tests/core/snapshots/test-enum-default.md_merged.snap index f5750f210c..3d43b1c3d6 100644 --- a/tests/core/snapshots/test-enum-default.md_merged.snap +++ b/tests/core/snapshots/test-enum-default.md_merged.snap @@ -1,8 +1,11 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server(port: 8080) @upstream(baseURL: "http://localhost:50051", batch: {delay: 10, headers: []}, httpCache: true) @link(id: "news", src: "./service.proto", type: Protobuf) { +schema + @server(port: 8080) + @upstream(baseURL: "http://localhost:50051", batch: {delay: 10, headers: []}, httpCache: 42) + @link(id: "news", src: "./service.proto", type: Protobuf) { query: Query } diff --git a/tests/core/snapshots/test-grpc.md_merged.snap b/tests/core/snapshots/test-grpc.md_merged.snap index 425c09a8d3..88ee926795 100644 --- a/tests/core/snapshots/test-grpc.md_merged.snap +++ b/tests/core/snapshots/test-grpc.md_merged.snap @@ -1,8 +1,11 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server(port: 8000) @upstream(baseURL: "http://localhost:50051", batch: {delay: 10, headers: [], maxSize: 1000}) @link(id: "news", src: "news.proto", type: Protobuf) { +schema + @server(port: 8000) + @upstream(baseURL: "http://localhost:50051", batch: {delay: 10, headers: [], maxSize: 1000}) + @link(id: "news", src: "news.proto", type: Protobuf) { query: Query } @@ -27,5 +30,6 @@ type NewsData { type Query { news: NewsData! @grpc(method: "news.NewsService.GetAllNews") newsById(news: NewsInput!): News! @grpc(body: "{{.args.news}}", method: "news.NewsService.GetNews") - newsByIdBatch(news: NewsInput!): News! @grpc(body: "{{.args.news}}", batchKey: ["news", "id"], method: "news.NewsService.GetMultipleNews") + newsByIdBatch(news: NewsInput!): News! + @grpc(body: "{{.args.news}}", batchKey: ["news", "id"], method: "news.NewsService.GetMultipleNews") } diff --git a/tests/core/snapshots/test-set-cookie-headers.md_merged.snap b/tests/core/snapshots/test-set-cookie-headers.md_merged.snap index d3da154ead..c88f3e4b3a 100644 --- a/tests/core/snapshots/test-set-cookie-headers.md_merged.snap +++ b/tests/core/snapshots/test-set-cookie-headers.md_merged.snap @@ -1,8 +1,10 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- -schema @server(headers: {setCookies: true}, hostname: "0.0.0.0", port: 8080) @upstream(baseURL: "http://jsonplaceholder.typicode.com") { +schema + @server(headers: {setCookies: true}, hostname: "0.0.0.0", port: 8080) + @upstream(baseURL: "http://jsonplaceholder.typicode.com") { query: Query } diff --git a/tests/core/snapshots/upstream-batching.md_merged.snap b/tests/core/snapshots/upstream-batching.md_merged.snap index 96bc34ca2a..b1cc966d58 100644 --- a/tests/core/snapshots/upstream-batching.md_merged.snap +++ b/tests/core/snapshots/upstream-batching.md_merged.snap @@ -1,13 +1,19 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- schema @server @upstream(batch: {delay: 1, headers: [], maxSize: 100}) { query: Query } type Query { - user(id: Int): User @http(baseURL: "http://jsonplaceholder.typicode.com", batchKey: ["id"], path: "/users", query: [{key: "id", value: "{{.args.id}}"}]) + user(id: Int): User + @http( + baseURL: "http://jsonplaceholder.typicode.com" + batchKey: ["id"] + path: "/users" + query: [{key: "id", value: "{{.args.id}}"}] + ) } type User { diff --git a/tests/core/snapshots/with-args.md_merged.snap b/tests/core/snapshots/with-args.md_merged.snap index 8d4d6edafd..b73ee87968 100644 --- a/tests/core/snapshots/with-args.md_merged.snap +++ b/tests/core/snapshots/with-args.md_merged.snap @@ -1,13 +1,14 @@ --- source: tests/core/spec.rs -expression: merged +expression: formatter --- schema @server @upstream { query: Query } type Query { - user(id: Int!): [User] @http(baseURL: "http://jsonplaceholder.typicode.com", path: "/users", query: [{key: "id", value: "{{.args.id}}"}]) + user(id: Int!): [User] + @http(baseURL: "http://jsonplaceholder.typicode.com", path: "/users", query: [{key: "id", value: "{{.args.id}}"}]) } type User { diff --git a/tests/core/spec.rs b/tests/core/spec.rs index d85886d00d..f054475ddf 100644 --- a/tests/core/spec.rs +++ b/tests/core/spec.rs @@ -18,6 +18,7 @@ use tailcall::core::http::{handle_request, AppContext}; use tailcall::core::merge_right::MergeRight; use tailcall::core::print_schema::print_schema; use tailcall::core::valid::{Cause, ValidationError}; +use tailcall_prettier::Parser; use super::file::File; use super::http::Http; @@ -225,9 +226,13 @@ async fn test_spec(spec: ExecutionSpec) { .fold(Config::default(), |acc, c| acc.merge_right(c.clone())) .to_sdl(); + let formatter = tailcall_prettier::format(merged, &Parser::Gql) + .await + .unwrap(); + let snapshot_name = format!("{}_merged", spec.safe_name); - insta::assert_snapshot!(snapshot_name, merged); + insta::assert_snapshot!(snapshot_name, formatter); // Resolve all configs let mut runtime = runtime::create_runtime(mock_http_client.clone(), spec.env.clone(), None); @@ -264,9 +269,13 @@ async fn test_spec(spec: ExecutionSpec) { .unwrap()) .to_schema(), ); + + let formatted = tailcall_prettier::format(client, &Parser::Gql) + .await + .unwrap(); let snapshot_name = format!("{}_client", spec.safe_name); - insta::assert_snapshot!(snapshot_name, client); + insta::assert_snapshot!(snapshot_name, formatted); } // run query tests diff --git a/tests/execution/batching-default.md b/tests/execution/batching-default.md index 6abee0a2d0..0793ba2683 100644 --- a/tests/execution/batching-default.md +++ b/tests/execution/batching-default.md @@ -1,7 +1,7 @@ # Batching default ```graphql @config -schema @server @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: true, batch: {delay: 10}) { +schema @server @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42, batch: {delay: 10}) { query: Query } diff --git a/tests/execution/batching-disabled.md b/tests/execution/batching-disabled.md index d825a1cb58..cd21a6b94c 100644 --- a/tests/execution/batching-disabled.md +++ b/tests/execution/batching-disabled.md @@ -5,7 +5,7 @@ "server": {}, "upstream": { "baseURL": "http://jsonplaceholder.typicode.com", - "httpCache": true, + "httpCache": 42, "batch": { "maxSize": 100, "delay": 0, diff --git a/tests/execution/batching-group-by-default.md b/tests/execution/batching-group-by-default.md index 2831031714..78ead4a198 100644 --- a/tests/execution/batching-group-by-default.md +++ b/tests/execution/batching-group-by-default.md @@ -3,7 +3,7 @@ ```graphql @config schema @server - @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: true, batch: {delay: 1, maxSize: 1000}) { + @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42, batch: {delay: 1, maxSize: 1000}) { query: Query } diff --git a/tests/execution/batching-group-by.md b/tests/execution/batching-group-by.md index 4525e06f04..985138ab9a 100644 --- a/tests/execution/batching-group-by.md +++ b/tests/execution/batching-group-by.md @@ -3,7 +3,7 @@ ```graphql @config schema @server(port: 8000, queryValidation: false) - @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: true, batch: {delay: 1, maxSize: 1000}) { + @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42, batch: {delay: 1, maxSize: 1000}) { query: Query } diff --git a/tests/execution/batching-post.md b/tests/execution/batching-post.md index aa166d2742..b2426a32fd 100644 --- a/tests/execution/batching-post.md +++ b/tests/execution/batching-post.md @@ -4,7 +4,7 @@ schema @server(port: 8000, queryValidation: false) @upstream( - httpCache: true + httpCache: 42 batch: {maxSize: 1000, delay: 1, headers: []} baseURL: "http://jsonplaceholder.typicode.com" ) { diff --git a/tests/execution/call-graphql-datasource.md b/tests/execution/call-graphql-datasource.md index 1f55fad496..4a840b5b64 100644 --- a/tests/execution/call-graphql-datasource.md +++ b/tests/execution/call-graphql-datasource.md @@ -3,7 +3,7 @@ ```graphql @config schema @server(port: 8000, hostname: "0.0.0.0") - @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: true) { + @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42) { query: Query } diff --git a/tests/execution/call-operator.md b/tests/execution/call-operator.md index a239e7174f..855fa52412 100644 --- a/tests/execution/call-operator.md +++ b/tests/execution/call-operator.md @@ -39,7 +39,7 @@ message NewsList { ```graphql @config schema @server(port: 8000, hostname: "0.0.0.0") - @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: true) + @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42) @link(id: "news", src: "news.proto", type: Protobuf) { query: Query } diff --git a/tests/execution/graphql-dataloader-batch-keys.md b/tests/execution/graphql-dataloader-batch-keys.md index e49c2b1fb1..066021cf58 100644 --- a/tests/execution/graphql-dataloader-batch-keys.md +++ b/tests/execution/graphql-dataloader-batch-keys.md @@ -10,7 +10,7 @@ skip: true ```graphql @config schema @server(port: 8001, queryValidation: false, hostname: "0.0.0.0") - @upstream(baseURL: "http://upstream/graphql", httpCache: true, batch: {delay: 1}) { + @upstream(baseURL: "http://upstream/graphql", httpCache: 42, batch: {delay: 1}) { query: Query } diff --git a/tests/execution/grpc-batch.md b/tests/execution/grpc-batch.md index 4db1d06a87..3b0ffaef1e 100644 --- a/tests/execution/grpc-batch.md +++ b/tests/execution/grpc-batch.md @@ -39,7 +39,7 @@ message NewsList { ```graphql @config schema @server(port: 8000) - @upstream(httpCache: true, batch: {delay: 10}) + @upstream(httpCache: 42, batch: {delay: 10}) @link(id: "news", src: "news.proto", type: Protobuf) { query: Query } diff --git a/tests/execution/grpc-error.md b/tests/execution/grpc-error.md index 39ffeef27c..077e83d5d3 100644 --- a/tests/execution/grpc-error.md +++ b/tests/execution/grpc-error.md @@ -39,7 +39,7 @@ message NewsList { ```graphql @config schema @server(port: 8000) - @upstream(httpCache: true, batch: {delay: 10}) + @upstream(httpCache: 42, batch: {delay: 10}) @link(id: "news", src: "news.proto", type: Protobuf) { query: Query } diff --git a/tests/execution/grpc-map.md b/tests/execution/grpc-map.md index 2ae69a5296..a116ef83a1 100644 --- a/tests/execution/grpc-map.md +++ b/tests/execution/grpc-map.md @@ -22,7 +22,7 @@ service MapService { ```graphql @config schema @server(port: 8000) - @upstream(baseURL: "http://localhost:50051", httpCache: true, batch: {delay: 10}) + @upstream(baseURL: "http://localhost:50051", httpCache: 42, batch: {delay: 10}) @link(src: "map.proto", type: Protobuf) { query: Query } diff --git a/tests/execution/grpc-override-url-from-upstream.md b/tests/execution/grpc-override-url-from-upstream.md index 41e8b83748..1eb2a2a702 100644 --- a/tests/execution/grpc-override-url-from-upstream.md +++ b/tests/execution/grpc-override-url-from-upstream.md @@ -39,7 +39,7 @@ message NewsList { ```graphql @config schema @server(port: 8000) - @upstream(httpCache: true, batch: {delay: 10}, baseURL: "http://not-a-valid-grpc-url.com") + @upstream(httpCache: 42, batch: {delay: 10}, baseURL: "http://not-a-valid-grpc-url.com") @link(id: "news", src: "news.proto", type: Protobuf) { query: Query } diff --git a/tests/execution/grpc-reflection.md b/tests/execution/grpc-reflection.md index 500e7f0f89..134d5e4582 100644 --- a/tests/execution/grpc-reflection.md +++ b/tests/execution/grpc-reflection.md @@ -3,7 +3,7 @@ ```graphql @config schema @server(port: 8000) - @upstream(httpCache: true, baseURL: "http://localhost:50051") + @upstream(httpCache: 42, baseURL: "http://localhost:50051") @link(src: "http://localhost:50051", type: Grpc) { query: Query } diff --git a/tests/execution/grpc-simple.md b/tests/execution/grpc-simple.md index 77e035345f..75f3ed5c19 100644 --- a/tests/execution/grpc-simple.md +++ b/tests/execution/grpc-simple.md @@ -39,7 +39,7 @@ message NewsList { ```graphql @config schema @server(port: 8000) - @upstream(baseURL: "http://localhost:50051", httpCache: true, batch: {delay: 10}) + @upstream(baseURL: "http://localhost:50051", httpCache: 42, batch: {delay: 10}) @link(id: "news", src: "news.proto", type: Protobuf) { query: Query } diff --git a/tests/execution/grpc-url-from-upstream.md b/tests/execution/grpc-url-from-upstream.md index f9c03fe7c3..a63181f68f 100644 --- a/tests/execution/grpc-url-from-upstream.md +++ b/tests/execution/grpc-url-from-upstream.md @@ -39,7 +39,7 @@ message NewsList { ```graphql @config schema @server(port: 8000) - @upstream(httpCache: true, batch: {delay: 10}, baseURL: "http://localhost:50051") + @upstream(httpCache: 42, batch: {delay: 10}, baseURL: "http://localhost:50051") @link(id: "news", src: "news.proto", type: Protobuf) { query: Query } diff --git a/tests/execution/io-cache.md b/tests/execution/io-cache.md index 0b02596cb7..f32585cf6a 100644 --- a/tests/execution/io-cache.md +++ b/tests/execution/io-cache.md @@ -3,7 +3,7 @@ ```graphql @config schema @server(port: 8000, hostname: "0.0.0.0") - @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: true) { + @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42) { query: Query } diff --git a/tests/execution/jsonplaceholder-call-post.md b/tests/execution/jsonplaceholder-call-post.md index 5bd0922191..27eebe6d95 100644 --- a/tests/execution/jsonplaceholder-call-post.md +++ b/tests/execution/jsonplaceholder-call-post.md @@ -3,7 +3,7 @@ ```graphql @config schema @server(port: 8000, hostname: "0.0.0.0") - @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: true, batch: {delay: 100}) { + @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42, batch: {delay: 100}) { query: Query } diff --git a/tests/execution/recursive-type-json.md b/tests/execution/recursive-type-json.md index 615f6baa6d..92e855eeaa 100644 --- a/tests/execution/recursive-type-json.md +++ b/tests/execution/recursive-type-json.md @@ -5,7 +5,7 @@ "$schema": "./.tailcallrc.schema.json", "upstream": { "baseURL": "https://jsonplaceholder.typicode.com", - "httpCache": true + "httpCache": 42 }, "schema": { "query": "Query" diff --git a/tests/execution/test-duplicated-link.md b/tests/execution/test-duplicated-link.md index 8b29d32641..12b4697584 100644 --- a/tests/execution/test-duplicated-link.md +++ b/tests/execution/test-duplicated-link.md @@ -7,7 +7,7 @@ error: true ```graphql @file:jsonplaceholder.graphql schema @server(port: 8000, hostname: "0.0.0.0") - @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: true, batch: {delay: 100}) { + @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42, batch: {delay: 100}) { query: Query } diff --git a/tests/execution/test-enum-default.md b/tests/execution/test-enum-default.md index 7ebe4a92cf..047acdc1af 100644 --- a/tests/execution/test-enum-default.md +++ b/tests/execution/test-enum-default.md @@ -32,7 +32,7 @@ message NewsList { # for test upstream server see [repo](https://github.com/tailcallhq/rust-grpc) schema @server(port: 8080) - @upstream(baseURL: "http://localhost:50051", httpCache: true, batch: {delay: 10}) + @upstream(baseURL: "http://localhost:50051", httpCache: 42, batch: {delay: 10}) @link(id: "news", src: "./service.proto", type: Protobuf) { query: Query } diff --git a/tests/execution/test-groupby-without-batching.md b/tests/execution/test-groupby-without-batching.md index ee73ea2176..e1ef65570c 100644 --- a/tests/execution/test-groupby-without-batching.md +++ b/tests/execution/test-groupby-without-batching.md @@ -5,7 +5,7 @@ error: true # test-groupby-without-batching ```graphql @config -schema @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: true) { +schema @upstream(baseURL: "http://jsonplaceholder.typicode.com", httpCache: 42) { query: Query } diff --git a/tests/execution/test-grpc-group-by.md b/tests/execution/test-grpc-group-by.md index b494c2a01d..e0e6092715 100644 --- a/tests/execution/test-grpc-group-by.md +++ b/tests/execution/test-grpc-group-by.md @@ -43,7 +43,7 @@ message NewsList { ```graphql @config schema @server(port: 8000) - @upstream(httpCache: true, batch: {delay: 10}) + @upstream(httpCache: 42, batch: {delay: 10}) @link(id: "news", src: "news.proto", type: Protobuf) { query: Query } diff --git a/tests/execution/test-grpc-nested-data.md b/tests/execution/test-grpc-nested-data.md index 69f2b13db0..e26d77a5c1 100644 --- a/tests/execution/test-grpc-nested-data.md +++ b/tests/execution/test-grpc-nested-data.md @@ -43,7 +43,7 @@ message NewsList { ```graphql @config schema @server(port: 8000) - @upstream(httpCache: true, batch: {delay: 10}) + @upstream(httpCache: 42, batch: {delay: 10}) @link(id: "news", src: "news.proto", type: Protobuf) { query: Query } diff --git a/tests/server_spec.rs b/tests/server_spec.rs index 42903203af..d32b5603a0 100644 --- a/tests/server_spec.rs +++ b/tests/server_spec.rs @@ -58,10 +58,10 @@ pub mod test { let mut client = ClientBuilder::new(builder.build().expect("Failed to build client")); - if upstream.http_cache { + if upstream.http_cache > 0 { client = client.with(Cache(HttpCache { mode: CacheMode::Default, - manager: HttpCacheManager::default(), + manager: HttpCacheManager::new(upstream.http_cache), options: HttpCacheOptions::default(), })) }