New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

graphql-hooks

Package Overview
Dependencies
Maintainers
1
Versions
89
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphql-hooks - npm Package Compare versions

Comparing version 2.0.4 to 3.0.0

6

package.json
{
"name": "graphql-hooks",
"version": "2.0.4",
"version": "3.0.0",
"description": "Graphql Hooks",

@@ -36,4 +36,4 @@ "main": "src/index.js",

"pretty-quick": "1.10.0",
"react": "16.8.2",
"react-dom": "16.8.2",
"react": "16.8.3",
"react-dom": "16.8.3",
"react-testing-library": "5.9.0"

@@ -40,0 +40,0 @@ },

@@ -14,3 +14,4 @@ const ClientContext = require('./ClientContext');

// alias
useMutation: useClientRequest
useMutation: (query, options) =>
useClientRequest(query, { isMutation: true, ...options })
};

@@ -13,2 +13,5 @@ const React = require('react');

case actionTypes.LOADING:
if (state.loading) {
return state; // saves a render cycle as state is the same
}
return {

@@ -52,8 +55,8 @@ ...state,

const cacheKey = client.getCacheKey(operation, initialOpts);
const intialCacheHit =
const initialCacheHit =
initialOpts.skipCache || !client.cache ? null : client.cache.get(cacheKey);
const [state, dispatch] = React.useReducer(reducer, {
...intialCacheHit,
cacheHit: !!intialCacheHit,
loading: !intialCacheHit
...initialCacheHit,
cacheHit: !!initialCacheHit,
loading: initialOpts.isMutation ? false : !initialCacheHit
});

@@ -60,0 +63,0 @@

@@ -72,2 +72,17 @@ import React from 'react';

});
it('sets loading to false if isMutation is passed in', () => {
let fetchData, state;
testHook(
() =>
([fetchData, state] = useClientRequest(TEST_QUERY, {
isMutation: true
})),
{
wrapper: Wrapper
}
);
expect(fetchData).toEqual(expect.any(Function));
expect(state).toEqual({ cacheHit: false, loading: false });
});
});

@@ -74,0 +89,0 @@

@@ -12,5 +12,6 @@ import { useMutation, useClientRequest } from '../../src';

describe('useMutation', () => {
it('calls useClientRequest with options', () => {
it('calls useClientRequest with options and isMutation set to true', () => {
useMutation(TEST_QUERY, { option: 'option' });
expect(useClientRequest).toHaveBeenCalledWith(TEST_QUERY, {
isMutation: true,
option: 'option'

@@ -17,0 +18,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