|
1 | 1 | { pkgs |
2 | 2 | , port ? "7100" |
3 | 3 | , hostPort ? null |
4 | | -, connector-url ? "http://connector:7130" |
5 | | -, ddn-subgraph-dir ? ../fixtures/ddn/subgraphs/chinook |
| 4 | +, connectors ? [{ name = "sample_mflix"; url = "http://connector:7130"; subgraph = ../fixtures/ddn/subgraphs/sample_mflix; }] |
6 | 5 | , auth-webhook ? { url = "http://auth-hook:3050/validate-request"; } |
7 | 6 | , otlp-endpoint ? "http://jaeger:4317" |
8 | 7 | , service ? { } # additional options to customize this service configuration |
|
12 | 11 | # Compile JSON metadata from HML fixture |
13 | 12 | metadata = pkgs.stdenv.mkDerivation { |
14 | 13 | name = "hasura-metadata.json"; |
15 | | - src = ddn-subgraph-dir; |
16 | | - nativeBuildInputs = with pkgs; [ jq yq-go ]; |
| 14 | + src = (builtins.head connectors).subgraph; |
| 15 | + nativeBuildInputs = with pkgs; [ findutils jq yq-go ]; |
17 | 16 |
|
18 | 17 | # The yq command converts the input sequence of yaml docs to a sequence of |
19 | 18 | # newline-separated json docs. |
|
22 | 21 | # switch), and modifies the json to update the data connector url. |
23 | 22 | buildPhase = '' |
24 | 23 | combined=$(mktemp -t subgraph-XXXXXX.hml) |
25 | | - for obj in **/*.hml; do |
| 24 | + for obj in $(find . -name '*hml'); do |
26 | 25 | echo "---" >> "$combined" |
27 | 26 | cat "$obj" >> "$combined" |
28 | 27 | done |
29 | 28 | cat "$combined" \ |
30 | 29 | | yq -o=json \ |
31 | | - | jq -s 'map(if .kind == "DataConnectorLink" then .definition.url = { singleUrl: { value: "${connector-url}" } } else . end) | map(select(type != "null"))' \ |
| 30 | + ${connector-url-substituters} \ |
| 31 | + | jq -s 'map(select(type != "null"))' \ |
32 | 32 | > metadata.json |
33 | 33 | ''; |
34 | 34 |
|
|
37 | 37 | ''; |
38 | 38 | }; |
39 | 39 |
|
| 40 | + # Pipe commands to replace data connector urls in fixture configuration with |
| 41 | + # urls of dockerized connector instances |
| 42 | + connector-url-substituters = builtins.toString (builtins.map |
| 43 | + ({ name, url, ... }: |
| 44 | + '' | jq 'if .kind == "DataConnectorLink" and .definition.name == "${name}" then .definition.url = { singleUrl: { value: "${url}" } } else . end' '' |
| 45 | + ) |
| 46 | + connectors); |
| 47 | + |
40 | 48 | auth-config = pkgs.writeText "auth_config.json" (builtins.toJSON { |
41 | 49 | version = "v1"; |
42 | 50 | definition = { |
|
0 commit comments