Skip to content

Commit

Permalink
Merge branch 'main' into prime-with-promise
Browse files Browse the repository at this point in the history
  • Loading branch information
saihaj committed Apr 12, 2022
2 parents 0a1ea89 + 254a875 commit 786008f
Show file tree
Hide file tree
Showing 17 changed files with 1,311 additions and 246 deletions.
8 changes: 8 additions & 0 deletions .changeset/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Changesets

Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works
with multi-package repos, or single-package repos to help you version and publish your code. You can
find the full documentation for it [in our repository](https://github.com/changesets/changesets)

We have a quick list of common questions to get you started engaging with this project in
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md)
9 changes: 9 additions & 0 deletions .changeset/afraid-nails-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"dataloader": minor
---

- Do not return void results from arrow functions https://github.com/graphql/dataloader/commit/3b0bae94e91453d9a432c02628745252abc5e011
- Fix typo in `loader.load()` error message https://github.com/graphql/dataloader/commit/249b2b966a8807c50e07746ff04acb8c48fa4357
- Fix typo in SQL example https://github.com/graphql/dataloader/commit/cae1a3d9bfa48e181a49fd443f43813b335dc120
- Fix typo in TypeScript declaration https://github.com/graphql/dataloader/commit/ef6d32f97cde16aba84d96dc806c4439eaf8efae
- Most of the browsers don't have `setImmediate`. `setImmediate || setTimeout` doesn't work and it throws `setImmediate` is not defined in this case, so we should check setImmediate with typeof. And some environments like Cloudflare Workers don't allow you to set setTimeout directly to another variable. https://github.com/graphql/dataloader/commit/3e62fbe7d42b7ab1ec54818a1491cb0107dd828a
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/config@2.0.0/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
5 changes: 5 additions & 0 deletions .changeset/great-swans-ring.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"dataloader": patch
---

Fix typo in jsdoc comment; flip "objects are keys" to "keys are objects"
39 changes: 39 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Release

on:
push:
branches:
- "main"

jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@master
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0

- name: Setup Node.js 16.x
uses: actions/setup-node@master
with:
node-version: 16.x

- name: Get yarn cache
uses: c-hive/gha-yarn-cache@v2

- name: Install Dependencies using Yarn
run: yarn --ignore-engines

- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@master
with:
publish: npm run release
commit: "release: update package versions"
title: "Upcoming Release Changes"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
33 changes: 33 additions & 0 deletions .github/workflows/validation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Flow check, Lint and Tests

on: push

jobs:
validation:
name: Testing on Node ${{ matrix.node-version }}
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12, 14, 16, 17]
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Use Node ${{ matrix.node-version }}
uses: actions/setup-node@master
with:
node-version: ${{ matrix.node-version }}

- name: Get yarn cache
uses: c-hive/gha-yarn-cache@v2

- name: Install Dependencies using Yarn
run: yarn --ignore-engines

- name: Tests
run: yarn test:ci

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
fail_ci_if_error: true
32 changes: 0 additions & 32 deletions .travis.yml

This file was deleted.

3 changes: 1 addition & 2 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
MIT License

Copyright (c) 2015-2018, Facebook, Inc.
Copyright (c) 2019-present, GraphQL Foundation
Copyright (c) GraphQL Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -657,3 +657,13 @@ DataLoader and how it works.
[babel/polyfill]: https://babeljs.io/docs/usage/polyfill/
[lru_map]: https://github.com/rsms/js-lru
[source code]: https://github.com/graphql/dataloader/blob/master/src/index.js

# Contributing to this repo

This repository is managed by EasyCLA. Project participants must sign the free ([GraphQL Specification Membership agreement](https://preview-spec-membership.graphql.org) before making a contribution. You only need to do this one time, and it can be signed by [individual contributors](http://individual-spec-membership.graphql.org/) or their [employers](http://corporate-spec-membership.graphql.org/).

To initiate the signature process please open a PR against this repo. The EasyCLA bot will block the merge if we still need a membership agreement from you.

You can find [detailed information here](https://github.com/graphql/graphql-wg/tree/main/membership). If you have issues, please email [operations@graphql.org](mailto:operations@graphql.org).

If your company benefits from GraphQL and you would like to provide essential financial support for the systems and people that power our community, please also consider membership in the [GraphQL Foundation](https://foundation.graphql.org/join).
2 changes: 1 addition & 1 deletion examples/SQL.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const userLoader = new DataLoader(ids => new Promise((resolve, reject) => {
reject(error);
} else {
resolve(ids.map(
id => rows.find(row => rows.id === id) || new Error(`Row not found: ${id}`)
id => rows.find(row => row.id === id) || new Error(`Row not found: ${id}`)
));
}
});
Expand Down
12 changes: 7 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@
"typings": "index.d.ts",
"scripts": {
"test": "npm run lint && npm run check && npm run testonly",
"test:ci": "npm run lint && npm run check && npm run testonly:coveralls",
"test:ci": "npm run lint && npm run check && npm run testonly -- --coverage",
"lint": "eslint src",
"check": "flow check --max-warnings 0",
"build": "babel src --ignore src/__tests__ --out-dir dist/ ; cp src/index.js dist/index.js.flow ; cp src/index.d.ts dist/",
"watch": "babel resources/watch.js | node",
"testonly": "jest src",
"testonly:coveralls": "jest src --coverage && cat ./coverage/lcov.info | coveralls",
"preversion": ". ./resources/checkgit.sh && npm test",
"prepublish": ". ./resources/prepublish.sh"
"prerelease": ". ./resources/prepublish.sh",
"release": "changeset publish"
},
"files": [
"index.js",
Expand All @@ -44,11 +43,14 @@
"@babel/node": "7.7.0",
"@babel/preset-env": "7.7.1",
"@babel/preset-flow": "7.0.0",
"@changesets/cli": "^2.22.0",
"babel-eslint": "10.0.3",
"coveralls": "3.0.7",
"eslint": "6.6.0",
"flow-bin": "0.112.0",
"jest": "24.9.0",
"sane": "4.1.0"
},
"publishConfig": {
"access": "public"
}
}
8 changes: 8 additions & 0 deletions renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"github>the-guild-org/shared-config:renovate",
":preserveSemverRanges"
],
"packageRules": []
}
27 changes: 0 additions & 27 deletions resources/checkgit.sh

This file was deleted.

21 changes: 2 additions & 19 deletions resources/prepublish.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
# Because of a long-running npm issue (https://github.com/npm/npm/issues/3059)
# prepublish runs after `npm install` and `npm pack`.
# In order to only run prepublish before `npm publish`, we have to check argv.
if node -e "process.exit(($npm_config_argv).original.length > 0 && ($npm_config_argv).original[0].indexOf('pu') === 0)"; then
exit 0;
fi

# Publishing to NPM is currently supported by Travis CI, which ensures that all
# tests pass first and the deployed module contains the correct file structure.
# In order to prevent inadvertently circumventing this, we ensure that a CI
# environment exists before continuing.
if [ "$CI" != true ]; then
echo "\n\n\n \033[101;30m Only Travis CI can publish to NPM. \033[0m" 1>&2;
echo " Ensure git is left is a good state by backing out any commits and deleting any tags." 1>&2;
echo " Then read CONTRIBUTING.md to learn how to publish to NPM.\n\n\n" 1>&2;
exit 1;
fi;

# Build before publishing
npm run build;

Expand All @@ -29,4 +11,5 @@ cp dist/* .
node -e "var package = require('./package.json'); \
delete package.scripts; \
delete package.devDependencies; \
require('fs').writeFileSync('package.json', JSON.stringify(package, null, 2));"
delete package.publishConfig; \
require('fs').writeFileSync('dist/package.json', JSON.stringify(package, null, 2));"
4 changes: 2 additions & 2 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ declare class DataLoader<K, V, C = K> {
clearAll(): this;

/**
* Adds the provied key and value to the cache. If the key already exists, no
* Adds the provided key and value to the cache. If the key already exists, no
* change is made. Returns itself for method chaining.
*/
prime(key: K, value: V | PromiseLike<V> | Error): this;
Expand Down Expand Up @@ -106,7 +106,7 @@ declare namespace DataLoader {

/**
* Default `key => key`. Produces cache key for a given load key. Useful
* when objects are keys and two objects should be considered equivalent.
* when keys are objects and two objects should be considered equivalent.
*/
cacheKeyFn?: (key: K) => C,

Expand Down
6 changes: 5 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,11 @@ var enqueuePostPromiseJob =
process.nextTick(fn);
});
} :
setImmediate || setTimeout;
typeof setImmediate === 'function' ? function (fn) {
setImmediate(fn);
} : function (fn) {
setTimeout(fn);
};

// Private: cached resolved Promise instance
var resolvedPromise;
Expand Down

0 comments on commit 786008f

Please sign in to comment.