Skip to content

Commit 738b0fd

Browse files
Update to NDC TypeScript SDK v4 (#11)
1 parent a8600ca commit 738b0fd

File tree

8 files changed

+14
-44
lines changed

8 files changed

+14
-44
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ This changelog documents the changes between release versions.
44
## main
55
Changes to be included in the next upcoming release
66

7-
- Support for NDC Spec v0.1.0-rc.15 via the NDC TypeScript SDK v3.0.0. This is a breaking change and must be used with the latest Hasura engine.
7+
- Support for NDC Spec v0.1.0-rc.15 via the NDC TypeScript SDK v4.0.0 ([#8](https://github.com/hasura/ndc-nodejs-lambda/pull/8), [#10](https://github.com/hasura/ndc-nodejs-lambda/pull/11)). This is a breaking change and must be used with the latest Hasura engine.
88
- Support for nested object/array selection
99
- New function calling convention that relies on nested object queries
1010
- New mutation request/response format
11+
- [New names](https://github.com/hasura/ndc-sdk-typescript/releases/tag/v4.0.0) for configuration environment variables
12+
- The default port is now 8080 instead of 8100
1113

1214
## v0.14.0
1315
- Support for "relaxed types" ([#10](https://github.com/hasura/ndc-nodejs-lambda/pull/10))

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ COPY /docker /scripts
77
COPY /functions /functions
88
RUN /scripts/package-restore.sh
99

10-
EXPOSE 8100
10+
EXPOSE 8080
1111

1212
CMD [ "sh", "/scripts/start.sh" ]

ndc-lambda-sdk/bin/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ const { makeCommand } = require("../dist/src/cmdline")
1212
// We need to get at the user's specified typescript functions file path early here in this shim
1313
// so that we can search for their tsconfig in order to configure ts-node/ts-node-dev properly
1414
const program = makeCommand({
15-
serveAction: () => {},
16-
configurationServeAction: () => {}
15+
serveAction: () => {}
1716
})
1817
program.parse();
1918

ndc-lambda-sdk/package-lock.json

Lines changed: 4 additions & 5 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: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@
3030
"url": "git+https://github.com/hasura/ndc-nodejs-lambda.git"
3131
},
3232
"dependencies": {
33-
"@hasura/ndc-sdk-typescript": "^3.0.0",
34-
"@json-schema-tools/meta-schema": "^1.7.0",
33+
"@hasura/ndc-sdk-typescript": "^4.0.0",
3534
"@tsconfig/node18": "^18.2.2",
3635
"commander": "^11.1.0",
3736
"cross-spawn": "^7.0.3",

ndc-lambda-sdk/src/cmdline.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ export type HostOptions = {
99

1010
export interface CommandActions {
1111
serveAction(hostOpts: HostOptions, serverOpts: sdk.ServerOptions): Promise<void> | void
12-
configurationServeAction(hostOpts: HostOptions, serverOpts: sdk.ConfigurationServerOptions): Promise<void> | void
1312
}
1413

1514
export function makeCommand(commandActions: CommandActions): Command {
@@ -23,12 +22,6 @@ export function makeCommand(commandActions: CommandActions): Command {
2322
return commandActions.serveAction(hostOpts, serverOptions);
2423
})
2524

26-
const configurationServeCommand = sdk.getServeConfigurationCommand();
27-
configurationServeCommand.commands.find(c => c.name() === "serve")?.action((serverOptions: sdk.ConfigurationServerOptions, command: Command) => {
28-
const hostOpts: HostOptions = hostCommand.opts();
29-
return commandActions.configurationServeAction(hostOpts, serverOptions);
30-
});
31-
3225
const hostCommand = program
3326
.command("host")
3427
.addOption(
@@ -37,8 +30,7 @@ export function makeCommand(commandActions: CommandActions): Command {
3730
.env("WATCH")
3831
)
3932
.requiredOption("-f, --functions <filepath>", "path to your TypeScript functions file")
40-
.addCommand(serveCommand)
41-
.addCommand(configurationServeCommand);
33+
.addCommand(serveCommand);
4234

4335
return program;
4436
}

ndc-lambda-sdk/src/connector.ts

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
import * as sdk from "@hasura/ndc-sdk-typescript";
2-
import { JSONSchemaObject } from "@json-schema-tools/meta-schema";
32
import path from "node:path"
43
import { FunctionsSchema, getNdcSchema, printRelaxedTypesWarning } from "./schema";
54
import { deriveSchema, printCompilerDiagnostics, printFunctionIssues } from "./inference";
65
import { RuntimeFunctions, executeMutation, executeQuery } from "./execution";
76

8-
export type RawConfiguration = {};
97
export type Configuration = {
108
functionsSchema: FunctionsSchema
119
};
@@ -14,34 +12,16 @@ export type State = {
1412
runtimeFunctions: RuntimeFunctions
1513
}
1614

17-
export const RAW_CONFIGURATION_SCHEMA: JSONSchemaObject = {
18-
description: 'NodeJS Lambda SDK Connector Configuration',
19-
type: 'object',
20-
required: [],
21-
properties: {}
22-
};
23-
2415
export type ConnectorOptions = {
2516
functionsFilePath: string
2617
}
2718

28-
export function createConnector(options: ConnectorOptions): sdk.Connector<RawConfiguration, Configuration, State> {
19+
export function createConnector(options: ConnectorOptions): sdk.Connector<Configuration, State> {
2920
const functionsFilePath = path.resolve(options.functionsFilePath);
3021

31-
const connector: sdk.Connector<RawConfiguration, Configuration, State> = {
32-
getRawConfigurationSchema: function (): JSONSchemaObject {
33-
return RAW_CONFIGURATION_SCHEMA;
34-
},
35-
36-
makeEmptyConfiguration: function (): RawConfiguration {
37-
return {};
38-
},
39-
40-
updateConfiguration: async function (rawConfiguration: RawConfiguration): Promise<RawConfiguration> {
41-
return {};
42-
},
22+
const connector: sdk.Connector<Configuration, State> = {
4323

44-
validateRawConfiguration: async function (rawConfiguration: RawConfiguration): Promise<Configuration> {
24+
parseConfiguration: async function (configurationDir: string): Promise<Configuration> {
4525
const schemaResults = deriveSchema(functionsFilePath);
4626
printCompilerDiagnostics(schemaResults.compilerDiagnostics);
4727
printFunctionIssues(schemaResults.functionIssues);

ndc-lambda-sdk/src/host.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { makeCommand } from "./cmdline";
44

55
const program = makeCommand({
66
serveAction: (hostOpts, serveOpts) => sdk.startServer(createConnector({functionsFilePath: hostOpts.functions}), serveOpts),
7-
configurationServeAction: (hostOpts, serveOpts) => sdk.startConfigurationServer(createConnector({functionsFilePath: hostOpts.functions}), serveOpts),
87
});
98

109
program.parseAsync().catch(err => {

0 commit comments

Comments
 (0)