MCPcopy Create free account
hub / github.com/TanStack/query / withDevtools

Function withDevtools

packages/angular-query-devtools/src/with-devtools.ts:66–165  ·  view source on GitHub ↗
(withDevtoolsFn)

Source from the content-addressed store, hash-verified

64 * @see {@link DevtoolsOptions}
65 */
66export const withDevtools: WithDevtools = (withDevtoolsFn) =>
67 queryFeature(
68 makeEnvironmentProviders([
69 {
70 provide: DEVTOOLS_OPTIONS,
71 useFactory: () => withDevtoolsFn?.() ?? {},
72 },
73 provideEnvironmentInitializer(() => {
74 const devtoolsProvided = inject(DEVTOOLS_PROVIDED)
75 if (
76 !isPlatformBrowser(inject(PLATFORM_ID)) ||
77 devtoolsProvided.isProvided
78 )
79 return
80
81 const injectedClient = inject(QueryClient, { optional: true })
82 const options = inject(DEVTOOLS_OPTIONS)
83 const destroyRef = inject(DestroyRef)
84
85 const client = resolveOption(options.client) ?? injectedClient
86
87 devtoolsProvided.isProvided = true
88 destroyRef.onDestroy(() => {
89 devtoolsProvided.isProvided = false
90 })
91
92 if (!client) throw new Error('No QueryClient found')
93
94 const devtools = new TanstackQueryDevtools({
95 client,
96 queryFlavor: 'Angular Query',
97 version: '5',
98 onlineManager,
99 buttonPosition: resolveOption(options.buttonPosition),
100 position: resolveOption(options.position),
101 initialIsOpen: resolveOption(options.initialIsOpen),
102 errorTypes: resolveOption(options.errorTypes),
103 styleNonce: options.styleNonce,
104 shadowDOMTarget: options.shadowDOMTarget,
105 hideDisabledQueries: options.hideDisabledQueries,
106 theme: resolveOption(options.theme),
107 })
108
109 const shouldMount = computed(() => {
110 const loadDevtools = resolveOption(options.loadDevtools)
111 return typeof loadDevtools === 'boolean' ? loadDevtools : isDevMode()
112 })
113
114 const mount = () => {
115 const element = document.body.appendChild(
116 document.createElement('div'),
117 )
118 element.classList.add('tsqd-parent-container')
119 devtools.mount(element)
120
121 return () => {
122 devtools.unmount()
123 element.remove()

Callers

nothing calls this directly

Calls 9

setClientMethod · 0.95
setButtonPositionMethod · 0.95
setPositionMethod · 0.95
setInitialIsOpenMethod · 0.95
setErrorTypesMethod · 0.95
setThemeMethod · 0.95
queryFeatureFunction · 0.85
resolveOptionFunction · 0.85
registerOptionEffectFunction · 0.85

Tested by

no test coverage detected