Socket
Socket
Sign inDemoInstall

apollo-cache-inmemory

Package Overview
Dependencies
Maintainers
4
Versions
149
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-cache-inmemory - npm Package Compare versions

Comparing version 1.3.9-beta.1 to 1.3.9

LICENSE

5

package.json
{
"name": "apollo-cache-inmemory",
"version": "1.3.9-beta.1",
"version": "1.3.9",
"description": "Core abstract of Caching layer for Apollo Client",

@@ -64,3 +64,4 @@ "author": "James Baxley <james@meteor.com>",

"testURL": "http://localhost"
}
},
"gitHead": "9e7f06b856b133216bb639f787d8da81a6ab2df4"
}

@@ -9,2 +9,3 @@ import gql, { disableFragmentWarnings } from 'graphql-tag';

import { defaultDataIdFromObject } from '../inMemoryCache';
import { NormalizedCache } from '../types';

@@ -1029,2 +1030,102 @@ const fragmentMatcherFunction = new HeuristicFragmentMatcher().match;

});
describe('issue #4081', () => {
it('should not return results containing cycles', () => {
const company = {
__typename: 'Company',
id: 1,
name: 'Apollo',
users: [],
};
company.users.push({
__typename: 'User',
id: 1,
name: 'Ben',
company,
}, {
__typename: 'User',
id: 2,
name: 'James',
company,
});
const query = gql`
query Query {
user {
...UserFragment
company {
users {
...UserFragment
}
}
}
}
fragment UserFragment on User {
id
name
company {
id
name
}
}
`;
function check(store: NormalizedCache) {
const { result } = reader.diffQueryAgainstStore({ store, query });
// This JSON.stringify call has the side benefit of verifying that the
// result does not have any cycles.
const json = JSON.stringify(result);
company.users.forEach(user => {
expect(json).toContain(JSON.stringify(user.name));
});
expect(result).toEqual({
user: {
id: 1,
name: 'Ben',
company: {
id: 1,
name: 'Apollo',
users: [{
id: 1,
name: 'Ben',
company: {
id: 1,
name: 'Apollo',
},
}, {
id: 2,
name: 'James',
company: {
id: 1,
name: 'Apollo',
},
}],
},
},
});
}
// Check first using generated IDs.
check(writer.writeQueryToStore({
query,
result: {
user: company.users[0],
},
}));
// Now check with __typename-specific IDs.
check(writer.writeQueryToStore({
dataIdFromObject: defaultDataIdFromObject,
query,
result: {
user: company.users[0],
},
}));
});
});
});
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc