@graphcommerce/graphql 9.0.0-canary.85 → 9.0.0-canary.86
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 9.0.0-canary.86
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#2379](https://github.com/graphcommerce-org/graphcommerce/pull/2379) [`c4ff06d`](https://github.com/graphcommerce-org/graphcommerce/commit/c4ff06da58e01de47c48aa55f4f822223202570c) - When a useInContextQuery is called, only execute when there is no InContextMaskContext defined above ([@paales](https://github.com/paales))
|
|
8
|
+
|
|
3
9
|
## 9.0.0-canary.85
|
|
4
10
|
|
|
5
11
|
## 9.0.0-canary.84
|
|
@@ -23,9 +23,9 @@ export type InContextMaskProps<
|
|
|
23
23
|
|
|
24
24
|
type InContextMaskContextType = { mask: boolean }
|
|
25
25
|
|
|
26
|
-
const InContextMaskContext = createContext<InContextMaskContextType |
|
|
26
|
+
export const InContextMaskContext = createContext<InContextMaskContextType | undefined>(undefined)
|
|
27
27
|
|
|
28
|
-
export function useInContextInputMask() {
|
|
28
|
+
export function useInContextInputMask(): InContextMaskContextType {
|
|
29
29
|
const context = useContext(InContextMaskContext)
|
|
30
30
|
|
|
31
31
|
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
@@ -3,8 +3,9 @@ import type { InputMaybe, InContextInput } from '@graphcommerce/graphql-mesh'
|
|
|
3
3
|
import { useIsSSR } from '@graphcommerce/next-ui/hooks/useIsSsr'
|
|
4
4
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
5
5
|
import { getCssFlag, removeCssFlag, setCssFlag } from '@graphcommerce/next-ui/utils/cssFlags'
|
|
6
|
-
import { useEffect } from 'react'
|
|
6
|
+
import { useContext, useEffect } from 'react'
|
|
7
7
|
import { QueryHookOptions, QueryResult, TypedDocumentNode, useQuery } from '../apollo'
|
|
8
|
+
import { InContextMaskContext } from '../components/InContextMask/InContextMask'
|
|
8
9
|
import { useInContextInput } from './useInContextInput'
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -32,6 +33,8 @@ export function useInContextQuery<
|
|
|
32
33
|
const context = useInContextInput()
|
|
33
34
|
const isSsr = useIsSSR()
|
|
34
35
|
|
|
36
|
+
const inContext = useContext(InContextMaskContext)
|
|
37
|
+
|
|
35
38
|
useEffect(() => {
|
|
36
39
|
if (isSsr) return
|
|
37
40
|
if (context && !getCssFlag('in-context')) setCssFlag('in-context', true)
|
|
@@ -41,7 +44,7 @@ export function useInContextQuery<
|
|
|
41
44
|
const clientQuery = useQuery<Q, V>(document, {
|
|
42
45
|
...options,
|
|
43
46
|
variables: { ...options.variables, context } as V,
|
|
44
|
-
skip: skip && !context,
|
|
47
|
+
skip: !!inContext || (skip && !context),
|
|
45
48
|
})
|
|
46
49
|
|
|
47
50
|
let { data } = clientQuery
|
|
@@ -53,5 +56,10 @@ export function useInContextQuery<
|
|
|
53
56
|
mask = !skip ? !clientQuery.data && !clientQuery.previousData : !clientQuery.data
|
|
54
57
|
}
|
|
55
58
|
|
|
59
|
+
// If this method is called within an InContextMask, we skip this complete functionality so we show the parent mask.
|
|
60
|
+
if (inContext) {
|
|
61
|
+
mask = inContext.mask
|
|
62
|
+
}
|
|
63
|
+
|
|
56
64
|
return { ...clientQuery, data: data ?? unscopedResult, mask }
|
|
57
65
|
}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/graphql",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "9.0.0-canary.
|
|
5
|
+
"version": "9.0.0-canary.86",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "index.ts",
|
|
8
8
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@graphcommerce/graphql-codegen-near-operation-file": "9.0.0-canary.
|
|
17
|
-
"@graphcommerce/graphql-codegen-relay-optimizer-plugin": "9.0.0-canary.
|
|
16
|
+
"@graphcommerce/graphql-codegen-near-operation-file": "9.0.0-canary.86",
|
|
17
|
+
"@graphcommerce/graphql-codegen-relay-optimizer-plugin": "9.0.0-canary.86",
|
|
18
18
|
"@graphql-codegen/add": "5.0.3",
|
|
19
19
|
"@graphql-codegen/fragment-matcher": "5.0.2",
|
|
20
20
|
"@graphql-codegen/introspection": "4.0.3",
|
|
@@ -28,9 +28,9 @@
|
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"@apollo/client": "^3",
|
|
31
|
-
"@graphcommerce/eslint-config-pwa": "^9.0.0-canary.
|
|
32
|
-
"@graphcommerce/prettier-config-pwa": "^9.0.0-canary.
|
|
33
|
-
"@graphcommerce/typescript-config-pwa": "^9.0.0-canary.
|
|
31
|
+
"@graphcommerce/eslint-config-pwa": "^9.0.0-canary.86",
|
|
32
|
+
"@graphcommerce/prettier-config-pwa": "^9.0.0-canary.86",
|
|
33
|
+
"@graphcommerce/typescript-config-pwa": "^9.0.0-canary.86",
|
|
34
34
|
"graphql": "^16.7.1",
|
|
35
35
|
"react": "^18.2.0",
|
|
36
36
|
"react-dom": "^18.2.0"
|