Skip to content

Commit 4a05913

Browse files
authored
chore: some improvements on cache and workflows
1 parent 893915a commit 4a05913

File tree

6 files changed

+8
-7
lines changed

6 files changed

+8
-7
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
- name: Release
6666
run: |
6767
VERSION=$(node -pe "require('./package.json').version")
68-
gh release create v$(echo $VERSION) -F CHANGELOG.md --title "Release v$(echo $VERSION)"
68+
gh release create v$(echo $VERSION) -F CHANGELOG.md --title "v$(echo $VERSION)"
6969
7070
- name: Upload package
7171
run: |

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "graphql-fastify-server",
33
"type": "commonjs",
4-
"version": "1.0.1",
4+
"version": "1.0.2",
55
"author": "rpvsilva",
66
"description": "Lightweight GraphQL server for fastify",
77
"license": "MIT",

src/middlewares/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
RouteShorthandOptions,
66
} from 'fastify';
77
import { GraphQLBody, GraphQLFastifyConfig } from '../types';
8-
import { isIntrospectionQuery } from '../utils';
8+
import { isIntrospectionQuery } from '../utils/cache';
99

1010
const disableIntrospection = (
1111
request: FastifyRequest,

src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { parse } from 'graphql';
66
import { postMiddleware } from './middlewares';
77
import { GetCacheKey, GraphqlFastifyCache } from './types/cache';
88
import cache from './cache';
9-
import { generateCacheKey, getCacheTtl, isIntrospectionQuery } from './utils';
9+
import { generateCacheKey, getCacheTtl, isIntrospectionQuery } from './utils/cache';
1010
import { FastifyInstance } from 'fastify';
1111

1212
class GraphQLFastify {

src/utils/index.ts renamed to src/utils/cache.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,13 @@ const getCacheableTtls = (selections: readonly SelectionNode[], cachePolicy: Cac
4343
if (selection.kind !== 'Field' || defaultQueryFields.includes(selection.name.value)) {
4444
return acc;
4545
}
46+
4647
const name = selection.name.value;
4748
const cacheRule = cachePolicy[name];
4849

4950
if (!cacheRule) return acc;
5051

51-
acc.cacheTtls = [...acc.cacheTtls, cacheRule.ttl];
52+
acc.cacheTtls.push(cacheRule.ttl);
5253

5354
if (!acc.isPrivate) acc.isPrivate = cacheRule.scope === 'PRIVATE';
5455

0 commit comments

Comments
 (0)