Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ jobs:
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 24
node-version: 20.11.0
registry-url: 'https://registry.npmjs.org'

- run: npm ci
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased

## 1.3.4

- Fix CommonJS DataLoader construction and provide CommonJS-safe connection,
base64, and stable-stringify helpers across the supported Node.js range.

## 1.3.3

- Publish both ESM (`.mjs`) and CommonJS (`.js`) runtime artifacts so generated
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "resgraph",
"version": "1.3.3",
"version": "1.3.4",
"description": "Build GraphQL servers in ReScript.",
"main": "index.js",
"scripts": {
Expand Down
20 changes: 13 additions & 7 deletions src/res/DataLoader.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 13 additions & 7 deletions src/res/DataLoader.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
// Generated by ReScript, PLEASE EDIT WITH CARE

import Dataloader from "dataloader";
import * as Stdlib_Lazy from "@rescript/runtime/lib/es6/Stdlib_Lazy.js";
import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
import * as StableStringifyMjs from "./stableStringify.mjs";
import * as StableStringifyCjs from "./stableStringify.cjs";
import * as DataLoaderCompatCjs from "./dataLoaderCompat.cjs";

let Plain = {};
function make(prim0, prim1) {
return new DataLoaderCompatCjs.DataLoader(prim0, prim1 !== undefined ? Primitive_option.valFromOption(prim1) : undefined);
}

let Plain = {
make: make
};

function stableStringifyValue(prim) {
return StableStringifyMjs.stableStringify(prim);
return StableStringifyCjs.stableStringify(prim);
}

function mapOptions(options) {
Expand All @@ -24,11 +30,11 @@ function mapOptions(options) {
}

function makeSingle(loadFn, options) {
return Stdlib_Lazy.make(() => new Dataloader(keys => Promise.all(keys.map(loadFn)), Primitive_option.toUndefined(mapOptions(options))));
return Stdlib_Lazy.make(() => new DataLoaderCompatCjs.DataLoader(keys => Promise.all(keys.map(loadFn)), Primitive_option.toUndefined(mapOptions(options))));
}

function makeBatched(loadFn, options) {
return Stdlib_Lazy.make(() => new Dataloader(loadFn, Primitive_option.toUndefined(mapOptions(options))));
return Stdlib_Lazy.make(() => new DataLoaderCompatCjs.DataLoader(loadFn, Primitive_option.toUndefined(mapOptions(options))));
}

function load(lazyLoader, key) {
Expand Down Expand Up @@ -78,4 +84,4 @@ export {
primeWithPromise,
name,
}
/* dataloader Not a pure module */
/* ./stableStringify.cjs Not a pure module */
6 changes: 3 additions & 3 deletions src/res/DataLoader.res
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ module Plain = {

type batchFn<'key, 'value> = array<'key> => promise<array<'value>>

@new @module("dataloader")
external make: (batchFn<'key, 'value>, ~options: options=?) => t<'key, 'value> = "default"
@new @module("./dataLoaderCompat.cjs")
external make: (batchFn<'key, 'value>, ~options: options=?) => t<'key, 'value> = "DataLoader"

/**
* Loads a key, returning a `promise` for the value represented by that key.
Expand Down Expand Up @@ -108,7 +108,7 @@ type options = {
name?: string,
}

@module("./stableStringify.mjs")
@module("./stableStringify.cjs")
external stableStringifyValue: 'any => 'any = "stableStringify"

let mapOptions = options => {
Expand Down
4 changes: 2 additions & 2 deletions src/res/DataLoader.resi
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ module Plain: {
type batchFn<'key, 'value> = array<'key> => promise<array<'value>>

/** Create a new data loader, from a batch load function. */
@new @module("dataloader")
external make: (batchFn<'key, 'value>, ~options: options=?) => t<'key, 'value> = "default"
@new @module("./dataLoaderCompat.cjs")
external make: (batchFn<'key, 'value>, ~options: options=?) => t<'key, 'value> = "DataLoader"
/**
* Loads a key, returning a `promise` for the value represented by that key.
*/
Expand Down
6 changes: 3 additions & 3 deletions src/res/ResGraph__Connections.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/res/ResGraph__Connections.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Generated by ReScript, PLEASE EDIT WITH CARE

import * as GraphqlRelayConnectionsMjs from "./graphqlRelayConnections.mjs";
import * as GraphqlRelayConnectionsCjs from "./graphqlRelayConnections.cjs";

function connectionFromArray(prim0, prim1) {
return GraphqlRelayConnectionsMjs.connectionFromArray(prim0, prim1);
return GraphqlRelayConnectionsCjs.connectionFromArray(prim0, prim1);
}

export {
connectionFromArray,
}
/* ./graphqlRelayConnections.mjs Not a pure module */
/* ./graphqlRelayConnections.cjs Not a pure module */
2 changes: 1 addition & 1 deletion src/res/ResGraph__Connections.res
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,6 @@ type connectionArgs = {
...backwardConnectionArgs,
}

@module("./graphqlRelayConnections.mjs")
@module("./graphqlRelayConnections.cjs")
external connectionFromArray: (array<'node>, ~args: connectionArgs) => connection<edge<'node>> =
"connectionFromArray"
8 changes: 4 additions & 4 deletions src/res/ResGraph__Utils.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/res/ResGraph__Utils.mjs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Generated by ReScript, PLEASE EDIT WITH CARE

import * as GraphqlRelayConnectionsMjs from "./graphqlRelayConnections.mjs";
import * as GraphqlRelayConnectionsCjs from "./graphqlRelayConnections.cjs";

function encode(prim) {
return GraphqlRelayConnectionsMjs.encodeBase64(prim);
return GraphqlRelayConnectionsCjs.encodeBase64(prim);
}

function decode(prim) {
return GraphqlRelayConnectionsMjs.decodeBase64(prim);
return GraphqlRelayConnectionsCjs.decodeBase64(prim);
}

let Base64 = {
Expand All @@ -18,4 +18,4 @@ let Base64 = {
export {
Base64,
}
/* ./graphqlRelayConnections.mjs Not a pure module */
/* ./graphqlRelayConnections.cjs Not a pure module */
4 changes: 2 additions & 2 deletions src/res/ResGraph__Utils.res
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Base64 = {
@module("./graphqlRelayConnections.mjs")
@module("./graphqlRelayConnections.cjs")
external encode: string => string = "encodeBase64"

@module("./graphqlRelayConnections.mjs")
@module("./graphqlRelayConnections.cjs")
external decode: string => string = "decodeBase64"
}
5 changes: 5 additions & 0 deletions src/res/dataLoaderCompat.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"use strict";

const importedDataLoader = require("dataloader");

exports.DataLoader = importedDataLoader.default ?? importedDataLoader;
Loading
Loading