Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit adde916

Browse files
committedAug 27, 2024··
Update readme with latest CLI instructions
1 parent 1270df5 commit adde916

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed
 

‎README.md

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,17 @@ The Node.js Lambda connector allows you to expose TypeScript functions as NDC fu
88
> To see it in use in a wider Hasura DDN project, and to understand the underlying DDN concepts, please check out the [Hasura DDN Getting Started Guide](https://hasura.io/docs/3.0/getting-started/overview/).
99
> The Node.js Lambda connector is used in the [business logic](https://hasura.io/docs/3.0/getting-started/build/add-business-logic?db=TypeScript) part of that tutorial.
1010
11-
First, ensure you have Node.js v20+ installed and an existing Hasura DDN project created (see the [Hasura DDN Getting Started Guide](https://hasura.io/docs/3.0/getting-started/overview/)). Then, initialize the connector into that project on an unused port of your choosing:
11+
First, ensure you have Node.js v20+ installed and an existing Hasura DDN project created (see the [Hasura DDN Getting Started Guide](https://hasura.io/docs/3.0/getting-started/overview/)). Then, initialize the connector into that project:
1212

1313
```bash
14-
ddn connector init my_ts --subgraph my_subgraph/subgraph.yaml --hub-connector hasura/nodejs --configure-port 8085
14+
ddn connector init -i
1515
```
1616

17-
This will generate the necessary files into the `my_subgraph/connector/my_ts` directory. This creates a `functions.ts` file in which you will write your functions, and a `package.json` with the `ndc-lambda-sdk` installed into it.
18-
19-
To add a `DataConnectorLink` to link the connector into the wider Hasura DDN project, run:
17+
* Select `hasura/nodejs` from the list of connectors
18+
* Name it something descriptive. For this example, we'll call it `my_ts`
19+
* Choose a port (press enter to accept the default recommended by the CLI).
2020

21-
```bash
22-
ddn connector-link add my_ts \
23-
--subgraph my_subgraph/subgraph.yaml \
24-
--configure-host http://local.hasura.dev:8085 \
25-
--target-env-file my_subgraph/.env.my_subgraph.local
26-
```
21+
This will generate the necessary files into the `my_subgraph/connector/my_ts` directory. This creates a `functions.ts` file in which you will write your functions, and a `package.json` with the `ndc-lambda-sdk` installed into it.
2722

2823
Restore all the npm packages required to run the connector by running inside the connector's directory:
2924

@@ -34,35 +29,40 @@ npm install
3429
To run the connector with the required environment variables applied, you can run the following command:
3530

3631
```bash
37-
npx dotenv -e .env.local -- npm run watch
32+
ddn connector setenv --connector connector.yaml -- npm run watch
3833
```
3934

4035
This starts the connector in watch mode, which watches for code changes and restarts the connector when they are detected. `npm run start` can be used instead to just start the connector without watching for changes. Both `start` and `watch` are defined in the `package.json`'s scripts section and use the `ndc-lambda-sdk` to host your `functions.ts` file.
4136

42-
Once you have written your functions, and while the connector is running, you can update that `DataConnectorLink` and add all the new functions to your subgraph by running:
37+
Once you have written your functions, use the following to generate the related metadata that will link together any functions in this functions.ts file and your API:
38+
39+
```bash
40+
ddn connector introspect my_ts
41+
```
42+
43+
Then you can generate all the necessary `hml` files with the Commands that expose your functions in the API by running the following:
4344

4445
```bash
45-
ddn connector-link update my_ts \
46-
--subgraph my_subgraph/subgraph.yaml \
47-
--env-file my_subgraph/.env.my_subgraph.local \
48-
--add-all-resources
46+
ddn connector-link add-resources my_ts
4947
```
5048

5149
To make a local build of your supergraph you can run:
5250

5351
```bash
54-
ddn supergraph build local \
55-
--output-dir engine \
56-
--subgraph-env-file my_subgraph:my_subgraph/.env.my_subgraph.local
52+
ddn supergraph build local
5753
```
5854

5955
You can then run that build locally for testing by starting the engine and other connectors in the DDN project using Docker Compose:
6056

6157
```bash
62-
HASURA_DDN_PAT=$(ddn auth print-pat) docker compose up --build --watch
58+
HASURA_DDN_PAT=$(ddn auth print-pat) docker compose --env-file .env up --build --watch
6359
```
6460

65-
You can view and query that local instance using the Hasura Graphiql Explorer by navigating to `https://console.hasura.io/local/graphql?url=http://localhost:3000`.
61+
You can view and query that local instance using the Hasura Graphiql Explorer by running:
62+
63+
```bash
64+
ddn console --local
65+
```
6666

6767
### Functions
6868
Any functions exported from `functions.ts` are made available as NDC functions/procedures to use in your Hasura metadata and expose as GraphQL fields in queries or mutation.

0 commit comments

Comments
 (0)
Please sign in to comment.