Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dump-lodash Remove lodash dependency #500

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
3 changes: 1 addition & 2 deletions .babelrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
"@babel/typescript"
],
"plugins": [
"@babel/proposal-class-properties",
"lodash"
"@babel/proposal-class-properties"
],
"env": {
"test": {
Expand Down
37 changes: 2 additions & 35 deletions package-lock.json

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

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"dataloader": "^2.0.0",
"graphql": "^15.6.1",
"graphql-tools": "^8.2.0",
"lodash": "^4.17.21",
"mitt": "^3.0.0"
},
"devDependencies": {
Expand All @@ -65,11 +64,9 @@
"@rollup/plugin-node-resolve": "^13.0.5",
"@rollup/plugin-typescript": "^8.2.5",
"@types/graphql": "^14.5.0",
"@types/lodash": "^4.14.175",
"@types/node": "^16.10.3",
"@types/whatwg-fetch": "^0.0.33",
"audit-ci": "^4.1.0",
"babel-plugin-lodash": "^3.3.4",
"chai": "^4.3.4",
"copyfiles": "^2.4.1",
"cross-var": "^1.1.0",
Expand Down
17 changes: 7 additions & 10 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,10 @@ let FORMAT = process.env.FORMAT;
// graphql-tools currently has a rollup build failure, so always call it an external until they fix it
// otherwise, make all npm production dependencies external, plus their subpath usages
// throughout the codebase, which rollup doesn't automatically pick up on
let external = FORMAT==='es' ?
Object.keys(pkg.dependencies)
.concat(
['castArray', 'get','isError', 'isObject', 'mapValues', 'reduce', 'omitBy', 'uniqBy', 'concat', 'uniqBy', 'differenceBy', 'forEach'].map(v => 'lodash/'+v),
['graphql', '@graphql-tools/schema']) :
['@graphql-tools/schema'];

let external =
FORMAT === 'es'
? Object.keys(pkg.dependencies).concat(['graphql', '@graphql-tools/schema'])
: ['@graphql-tools/schema'];

export default {
external,
Expand All @@ -26,7 +23,7 @@ export default {
graphql(),
localResolve(),
nodeResolve({
extensions: [ '.js', '.ts', '.json' ]
extensions: ['.js', '.ts', '.json']
}),
commonjs(),
typescript(),
Expand All @@ -37,6 +34,6 @@ export default {
})
],
output: {
exports: FORMAT==='es' ? null : 'named'
},
exports: FORMAT === 'es' ? null : 'named'
}
};
3 changes: 1 addition & 2 deletions src/apollo/offline-queue-link/util.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { Operation } from '@apollo/client';
import get from 'lodash/get';
import { OfflineOperationEntry, OperationEntry } from './types';

export function hasSensitiveVariables(operation: Operation) {
return !!get(operation, 'variables.password');
return !!operation?.variables?.password;
}

export function isMutationOperation({ query }: Operation) {
Expand Down
5 changes: 3 additions & 2 deletions src/apollo/zimbra-error-link.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ErrorLink } from '@apollo/client/link/error';
import get from 'lodash/get';
import { SingleBatchRequestError } from '../request/types';

class ZimbraErrorLink extends ErrorLink {
handlers: any[] = [];
Expand All @@ -8,7 +8,8 @@ class ZimbraErrorLink extends ErrorLink {
super(({ graphQLErrors, networkError }) => {
graphQLErrors &&
graphQLErrors.map(({ message, originalError, ...rest }) => {
let errorCode = get(originalError, 'faults.0.Detail.Error.Code', '');
let error = <SingleBatchRequestError>originalError;
let errorCode = error?.faults?.[0]?.Detail?.Error?.Code;

this.executeHandlers({
errorCode,
Expand Down
3 changes: 1 addition & 2 deletions src/apollo/zimbra-in-memory-cache.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { defaultDataIdFromObject, InMemoryCache, InMemoryCacheConfig } from '@apollo/client';
import get from 'lodash/get';

const dataIdFromPath = (result: any, path: string) => {
if (result.__typename) {
const id = get(result, path);
const id = result?.[path];
return id ? `${result.__typename}:${id}` : defaultDataIdFromObject(result);
}
};
Expand Down
Loading