Skip to content

Commit 2a9a04d

Browse files
Update to NDC TypeScript SDK v5.2.0, remove yeoman generator, update readme instructions (#38)
* Update TypeScript SDK version * Delete unused yeoman generator * Update readme with latest instructions * Update changelog
1 parent 9b5f795 commit 2a9a04d

File tree

15 files changed

+44
-6428
lines changed

15 files changed

+44
-6428
lines changed

.github/workflows/generator-hasura-ndc-nodejs-lambda.yaml

Lines changed: 0 additions & 61 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
# Node.js Lambda Connector Changelog
22
This changelog documents the changes between release versions.
33

4-
> [!IMPORTANT]
5-
> Hasura DDN Alpha users should use 0.x versions of the `ndc-lambda-sdk`. v1.x versions of the `ndc-lambda-sdk` support the Hasura DDN Beta.
6-
74
## [Unreleased]
85
Changes to be included in the next upcoming release
96

7+
## [1.5.0] - 2024-07-30
8+
- Updated the NDC TypeScript SDK to v5.2.0 ([#38](https://github.com/hasura/ndc-nodejs-lambda/pull/38))
9+
- The connector now listens on both ipv4 and ipv6 interfaces
10+
1011
## [1.4.1] - 2024-06-06
1112

1213
- Added a default .gitignore that ignores node_modules in the connector template ([#34](https://github.com/hasura/ndc-nodejs-lambda/pull/34))
13-
- Updated to NDC TypeScript SDK to v5.0.0 ([#35](https://github.com/hasura/ndc-nodejs-lambda/pull/35))
14+
- Updated the NDC TypeScript SDK to v5.0.0 ([#35](https://github.com/hasura/ndc-nodejs-lambda/pull/35))
1415
- The BigInt scalar type now uses the biginteger type representation
1516
- Added `dotenv-cli` to the dev dependencies of the connector's default package.json to help with using .env files ([#36](https://github.com/hasura/ndc-nodejs-lambda/pull/36))
1617

README.md

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,65 +6,60 @@ The Node.js Lambda connector allows you to expose TypeScript functions as NDC fu
66
> [!TIP]
77
> The following instructions are just a quick summary of how to use the Node.js Lambda connector.
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/).
9-
> The Node.js Lambda connector is used in the business logic part of that tutorial.
9+
> 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:
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:
1212

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

1717
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.
1818

19-
Restore all the npm packages required to run the connector by running inside the connector's directory:
19+
To add a `DataConnectorLink` to link the connector into the wider Hasura DDN project, run:
2020

2121
```bash
22-
npm install
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
2326
```
2427

25-
You may wish to change the port the connector runs on to one that is unused (the default is 8080). You can do so by changing the `.env.local` file and adding:
28+
Restore all the npm packages required to run the connector by running inside the connector's directory:
2629

27-
```
28-
HASURA_CONNECTOR_PORT=<port>
30+
```bash
31+
npm install
2932
```
3033

31-
To run the connector with these environment environment variables applied, you can run the following command:
34+
To run the connector with the required environment variables applied, you can run the following command:
3235

3336
```bash
3437
npx dotenv -e .env.local -- npm run watch
3538
```
3639

3740
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.
3841

39-
To add a `DataConnectorLink` to link the connector into the wider Hasura DDN project, run:
40-
41-
```bash
42-
ddn connector-link add my_ts
43-
```
44-
45-
Then, update the values in your subgraph's `.env.my_subgraph` file to include this connector.
46-
47-
```
48-
MY_SUBGRAPH_MY_TS_READ_URL=http://local.hasura.dev:<port>
49-
MY_SUBGRAPH_MY_TS_WRITE_URL=http://local.hasura.dev:<port>
50-
```
51-
5242
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:
5343

5444
```bash
55-
ddn connector-link update my_ts --subgraph my_subgraph --add-all-resources
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
5649
```
5750

5851
To make a local build of your supergraph you can run:
5952

6053
```bash
61-
ddn supergraph build local --output-dir ./engine
54+
ddn supergraph build local \
55+
--output-dir engine \
56+
--subgraph-env-file my_subgraph:my_subgraph/.env.my_subgraph.local
6257
```
6358

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

6661
```bash
67-
HASURA_DDN_PAT=$(ddn auth print-pat) docker compose -f docker-compose.hasura.yaml watch
62+
HASURA_DDN_PAT=$(ddn auth print-pat) docker compose up --build --watch
6863
```
6964

7065
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`.

ndc-lambda-sdk/package-lock.json

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ndc-lambda-sdk/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@hasura/ndc-lambda-sdk",
3-
"version": "1.4.1",
3+
"version": "1.5.0",
44
"description": "SDK that can automatically expose TypeScript functions as Hasura NDC functions/procedures",
55
"author": "Hasura",
66
"license": "Apache-2.0",
@@ -30,7 +30,7 @@
3030
"url": "git+https://github.com/hasura/ndc-nodejs-lambda.git"
3131
},
3232
"dependencies": {
33-
"@hasura/ndc-sdk-typescript": "^5.0.0",
33+
"@hasura/ndc-sdk-typescript": "^5.2.0",
3434
"@tsconfig/node20": "^20.1.3",
3535
"commander": "^11.1.0",
3636
"cross-spawn": "^7.0.3",

ndc-lambda-sdk/src/connector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export function createConnector(options: ConnectorOptions): sdk.Connector<Config
6767

6868
getCapabilities: function (configuration: Configuration): sdk.CapabilitiesResponse {
6969
return {
70-
version: "0.1.3",
70+
version: "0.1.5",
7171
capabilities: {
7272
query: {
7373
variables: {},

yeoman-generator/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)