Skip to content

Commit

Permalink
fix(deps): update dependency ioredis to v5 (#1384)
Browse files Browse the repository at this point in the history
* fix(deps): update dependency ioredis to v5

* chore(dependencies): updated changesets for modified dependencies

* chore(dependencies): updated changesets for modified dependencies

* Fix tests

* Fix v15 tests

* ..

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Arda TANRIKULU <[email protected]>
  • Loading branch information
3 people authored Jan 15, 2025
1 parent 06f6a8b commit ed8c444
Show file tree
Hide file tree
Showing 14 changed files with 260 additions and 278 deletions.
5 changes: 5 additions & 0 deletions .changeset/@envelop_apollo-federation-1384-dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@envelop/apollo-federation": patch
---
dependencies updates:
- Removed dependency [`@apollo/gateway@^0.54.0` ↗︎](https://www.npmjs.com/package/@apollo/gateway/v/0.54.0) (from `peerDependencies`)
5 changes: 5 additions & 0 deletions .changeset/@envelop_response-cache-redis-1384-dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@envelop/response-cache-redis": patch
---
dependencies updates:
- Updated dependency [`ioredis@^5.4.2` ↗︎](https://www.npmjs.com/package/ioredis/v/5.4.2) (from `^4.27.9`, in `dependencies`)
5 changes: 2 additions & 3 deletions packages/plugins/apollo-federation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
},
"typings": "dist/typings/index.d.ts",
"peerDependencies": {
"@apollo/gateway": "^0.54.0",
"@envelop/core": "^5.0.3",
"graphql": "^14.0.0 || ^15.0.0 || ^16.0.0"
},
Expand All @@ -57,8 +56,8 @@
"tslib": "^2.5.0"
},
"devDependencies": {
"@apollo/federation": "0.38.1",
"@apollo/gateway": "0.54.1",
"@apollo/gateway": "2.9.3",
"@apollo/subgraph": "2.9.3",
"@envelop/core": "workspace:^",
"graphql": "16.8.1",
"graphql-tag": "2.12.6",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/apollo-federation/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { InMemoryLRUCache, KeyValueCache } from 'apollo-server-caching';
import { CachePolicy, GraphQLRequestMetrics, Logger, SchemaHash } from 'apollo-server-types';
import { getOperationAST, print, printSchema } from 'graphql';
import { ApolloGateway } from '@apollo/gateway';
import type { ApolloGateway } from '@apollo/gateway';
import { getDocumentString, Plugin } from '@envelop/core';
import { newCachePolicy } from './new-cache-policy.js';

Expand Down
64 changes: 35 additions & 29 deletions packages/plugins/apollo-federation/test/federation.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { execute, parse } from 'graphql';
import { execute, parse, versionInfo } from 'graphql';
import type { ApolloGateway } from '@apollo/gateway';
import { assertSingleExecutionValue, createTestkit } from '@envelop/testing';
import { useApolloFederation } from '../src/index.js';

describe('useApolloFederation', () => {
const describeIf = (condition: boolean) => (condition ? describe : describe.skip);

describeIf(versionInfo.major >= 16)('useApolloFederation', () => {
const query = /* GraphQL */ `
# A query that the gateway resolves by calling all three services
query GetCurrentUserReviews {
Expand All @@ -19,37 +22,40 @@ describe('useApolloFederation', () => {
}
`;

const {
ApolloGateway,
LocalGraphQLDataSource,
}: typeof import('@apollo/gateway') = require('@apollo/gateway');
const accounts: typeof import('./fixtures/accounts') = require('./fixtures/accounts');
const products: typeof import('./fixtures/products') = require('./fixtures/products');
const reviews: typeof import('./fixtures/reviews') = require('./fixtures/reviews');
let gateway: ApolloGateway;

const gateway = new ApolloGateway({
localServiceList: [
{ name: 'accounts', typeDefs: accounts.typeDefs },
{ name: 'products', typeDefs: products.typeDefs },
{ name: 'reviews', typeDefs: reviews.typeDefs },
],
buildService: definition => {
switch (definition.name) {
case 'accounts':
return new LocalGraphQLDataSource(accounts.schema);
case 'products':
return new LocalGraphQLDataSource(products.schema);
case 'reviews':
return new LocalGraphQLDataSource(reviews.schema);
}
throw new Error(`Unknown service ${definition.name}`);
},
});
beforeAll(() => {
const {
ApolloGateway,
LocalGraphQLDataSource,
}: typeof import('@apollo/gateway') = require('@apollo/gateway');
const accounts: typeof import('./fixtures/accounts') = require('./fixtures/accounts');
const products: typeof import('./fixtures/products') = require('./fixtures/products');
const reviews: typeof import('./fixtures/reviews') = require('./fixtures/reviews');

beforeAll(async () => {
await gateway.load();
gateway = new ApolloGateway({
localServiceList: [
{ name: 'accounts', typeDefs: accounts.typeDefs },
{ name: 'products', typeDefs: products.typeDefs },
{ name: 'reviews', typeDefs: reviews.typeDefs },
],
buildService: definition => {
switch (definition.name) {
case 'accounts':
return new LocalGraphQLDataSource(accounts.schema);
case 'products':
return new LocalGraphQLDataSource(products.schema);
case 'reviews':
return new LocalGraphQLDataSource(reviews.schema);
}
throw new Error(`Unknown service ${definition.name}`);
},
});
return gateway.load();
});

afterAll(() => gateway.stop());

const useTestFederation = () =>
useApolloFederation({
gateway,
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/apollo-federation/test/fixtures/accounts.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import gql from 'graphql-tag';
import { buildFederatedSchema } from '@apollo/federation';
import { buildSubgraphSchema } from '@apollo/subgraph';

const users = [
{
Expand Down Expand Up @@ -31,7 +31,7 @@ export const typeDefs = gql`
}
`;

export const schema = buildFederatedSchema({
export const schema = buildSubgraphSchema({
typeDefs,
resolvers: {
Query: {
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/apollo-federation/test/fixtures/products.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import gql from 'graphql-tag';
import { buildFederatedSchema } from '@apollo/federation';
import { buildSubgraphSchema } from '@apollo/subgraph';

const products = [
{
Expand Down Expand Up @@ -35,7 +35,7 @@ export const typeDefs = gql`
}
`;

export const schema = buildFederatedSchema({
export const schema = buildSubgraphSchema({
typeDefs,
resolvers: {
Product: {
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/apollo-federation/test/fixtures/reviews.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import gql from 'graphql-tag';
import { buildFederatedSchema } from '@apollo/federation';
import { buildSubgraphSchema } from '@apollo/subgraph';

const usernames = [
{ id: '1', username: '@ada' },
Expand Down Expand Up @@ -52,7 +52,7 @@ export const typeDefs = gql`
}
`;

export const schema = buildFederatedSchema({
export const schema = buildSubgraphSchema({
typeDefs,
resolvers: {
Review: {
Expand Down
1 change: 0 additions & 1 deletion packages/plugins/generic-auth/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ export const useGenericAuth = <
return;
}

// @ts-expect-error - Fix this
const typeDirectives = parentType && getDirectiveExtensions(parentType, schema);
const typeAuthArgs = typeDirectives[authDirectiveName]?.[0];
const typeScopes = typeDirectives[requiresScopesDirectiveName]?.[0]?.scopes;
Expand Down
6 changes: 3 additions & 3 deletions packages/plugins/response-cache-redis/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@
"peerDependencies": {},
"dependencies": {
"@envelop/response-cache": "^6.1.2",
"ioredis": "^4.27.9",
"ioredis": "^5.4.2",
"tslib": "^2.5.0"
},
"devDependencies": {
"@envelop/core": "workspace:^",
"@graphql-tools/schema": "10.0.16",
"@types/ioredis": "4.28.10",
"@types/ioredis": "5.0.0",
"graphql": "16.9.0",
"ioredis-mock": "5.9.1",
"ioredis-mock": "8.9.0",
"typescript": "5.7.3"
},
"publishConfig": {
Expand Down
4 changes: 2 additions & 2 deletions packages/plugins/response-cache-redis/src/redis-cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ export type BuildRedisOperationResultCacheKey = (responseId: string) => string;
export type RedisCacheParameter = {
/**
* Redis instance
* @see Redis.Redis https://github.com/luin/ioredis
* @see Redis https://github.com/luin/ioredis
*/
redis: Redis.Redis;
redis: Redis;
/**
* Customize how the cache entity id is built.
* By default the typename is concatenated with the id e.g. `User:1`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
defaultBuildRedisOperationResultCacheKey,
} from '../src/index.js';

jest.mock('ioredis', () => require('ioredis-mock/jest'));
jest.mock('ioredis', () => require('ioredis-mock'));

const describeIf = (condition: boolean) => (condition ? describe : describe.skip);

Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/response-cache/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"@graphql-tools/executor": "^1.3.1",
"@graphql-tools/schema": "10.0.16",
"graphql": "16.8.1",
"ioredis-mock": "5.9.1",
"ioredis-mock": "8.9.0",
"typescript": "5.7.3"
},
"publishConfig": {
Expand Down
Loading

0 comments on commit ed8c444

Please sign in to comment.