Skip to content

Commit

Permalink
Merge pull request #10 from blackflux/dev
Browse files Browse the repository at this point in the history
[Gally]: master <- dev
  • Loading branch information
simlu authored Aug 26, 2019
2 parents 05a5e02 + 4ac5692 commit ddcdbd5
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 29 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ Install with [npm](https://www.npmjs.com/):

Parse info object to easily access relevant information.

### getDeprecationDate(schema, queryAst, offsetInDays = 0)
### getDeprecationDate(schema, queryAst)

Fetch nearest deprecation date that is accessed by the query as `http-date` string.
Fetch nearest deprecation date that is accessed by the query as date object.
Returns `null` when there is no deprecated access. Expects custom deprecation syntax, see below.

Can e.g. be used to return a `Sunset` header.
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
"@babel/plugin-proposal-object-rest-spread": "7.5.5",
"@babel/register": "7.5.5",
"@blackflux/eslint-plugin-rules": "1.3.7",
"@blackflux/robo-config-plugin": "2.5.11",
"@blackflux/robo-config-plugin": "2.5.12",
"apollo-server": "2.9.0",
"babel-eslint": "10.0.2",
"babel-eslint": "10.0.3",
"chai": "4.2.0",
"coveralls": "3.0.6",
"eslint": "6.2.2",
Expand Down
8 changes: 2 additions & 6 deletions src/modules/deprecation.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const getDeprecationDetails = (schema, ast) => {
};
module.exports.getDeprecationDetails = getDeprecationDetails;

module.exports.getDeprecationDate = (schema, ast, offsetInDays = 0) => {
module.exports.getDeprecationDate = (schema, ast) => {
let result = null;
getDeprecationDetails(schema, ast)
.forEach((d) => {
Expand All @@ -54,9 +54,5 @@ module.exports.getDeprecationDate = (schema, ast, offsetInDays = 0) => {
result = date;
}
});
if (result === null) {
return null;
}
result.setTime(result.getTime() + offsetInDays * 24 * 60 * 60 * 1000);
return result.toUTCString();
return result;
};
3 changes: 2 additions & 1 deletion test/modules/deprecation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ describe('Testing deprecation.js', () => {
}));
const deprecationDate = getDeprecationDate(schema, query);
expect(result).to.deep.equal(expectedResult);
expect(deprecationDate).to.equal(expectedDeprecationDate);
expect(deprecationDate === null ? null : deprecationDate.toUTCString())
.to.equal(expectedDeprecationDate);
});
});
});
Expand Down
28 changes: 10 additions & 18 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@
dependencies:
smart-fs "1.9.10"

"@blackflux/robo-config-plugin@2.5.11":
version "2.5.11"
resolved "https://registry.yarnpkg.com/@blackflux/robo-config-plugin/-/robo-config-plugin-2.5.11.tgz#5fa9ad9771e60e1ab4d11a52bb49e779d1daf5ca"
integrity sha512-KZtrq2JabHTSpIWF5c9Al0i1GayrjuAAEKgUwjNmz0zE4HVUpjaEtyiZZ9rPtcBthnxNHe4Od8iat6US0pCyhw==
"@blackflux/robo-config-plugin@2.5.12":
version "2.5.12"
resolved "https://registry.yarnpkg.com/@blackflux/robo-config-plugin/-/robo-config-plugin-2.5.12.tgz#7df56216e33c449d00153104f8fcaef3ca14f3a1"
integrity sha512-SM/R/XBDxIWgNfScv6UNBTFZu7Ioqw+bS1WAEAD8v25KaRUs5tv7xETVHCvSsXNBaROrfPOBvyTtU4CxpwZEcA==

"@hapi/address@2.x.x":
version "2.0.0"
Expand Down Expand Up @@ -1124,17 +1124,17 @@ babel-code-frame@^6.26.0:
esutils "^2.0.2"
js-tokens "^3.0.2"

babel-eslint@10.0.2:
version "10.0.2"
resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-10.0.2.tgz#182d5ac204579ff0881684b040560fdcc1558456"
integrity sha512-UdsurWPtgiPgpJ06ryUnuaSXC2s0WoSZnQmEpbAH65XZSdwowgN5MvyP7e88nW07FYXv72erVtpBkxyDVKhH1Q==
babel-eslint@10.0.3:
version "10.0.3"
resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-10.0.3.tgz#81a2c669be0f205e19462fed2482d33e4687a88a"
integrity sha512-z3U7eMY6r/3f3/JB9mTsLjyxrv0Yb1zb8PCWCLpguxfCzBIZUwy23R1t/XKewP+8mEN2Ck8Dtr4q20z6ce6SoA==
dependencies:
"@babel/code-frame" "^7.0.0"
"@babel/parser" "^7.0.0"
"@babel/traverse" "^7.0.0"
"@babel/types" "^7.0.0"
eslint-scope "3.7.1"
eslint-visitor-keys "^1.0.0"
resolve "^1.12.0"

babel-messages@^6.23.0:
version "6.23.0"
Expand Down Expand Up @@ -2533,14 +2533,6 @@ eslint-plugin-mocha@6.1.0:
dependencies:
ramda "^0.26.1"

eslint-scope@3.7.1:
version "3.7.1"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8"
integrity sha1-PWPD7f2gLgbgGkUq2IyqzHzctug=
dependencies:
esrecurse "^4.1.0"
estraverse "^4.1.1"

eslint-scope@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.0.0.tgz#e87c8887c73e8d1ec84f1ca591645c358bfc8fb9"
Expand Down Expand Up @@ -6939,7 +6931,7 @@ resolve-url@^0.2.1:
resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a"
integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=

resolve@^1.10.0, resolve@^1.11.0, resolve@^1.3.2, resolve@^1.5.0:
resolve@^1.10.0, resolve@^1.11.0, resolve@^1.12.0, resolve@^1.3.2, resolve@^1.5.0:
version "1.12.0"
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.12.0.tgz#3fc644a35c84a48554609ff26ec52b66fa577df6"
integrity sha512-B/dOmuoAik5bKcD6s6nXDCjzUKnaDvdkRyAk6rsmsKLipWj4797iothd7jmmUhWTfinVMU+wc56rYKsit2Qy4w==
Expand Down

0 comments on commit ddcdbd5

Please sign in to comment.