GithubHelp home page GithubHelp logo

urql-graphql / urql-devtools-exchange Goto Github PK

View Code? Open in Web Editor NEW
54.0 40.0 6.0 2.09 MB

The exchange for usage with Urql Devtools

Home Page: https://www.npmjs.com/package/@urql/devtools

License: MIT License

TypeScript 84.95% JavaScript 12.14% Shell 2.91%
urql exchange devtools graphql extension urql-devtools

urql-devtools-exchange's People

Contributors

andyrichardson avatar jovidecroock avatar jpdriver avatar kitten avatar lukasluecke avatar renovate-bot avatar sofiapoh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

urql-devtools-exchange's Issues

Anything special to get this working in Expo?

Hi, first time user here.
I've got urql set up and working great in a react-native Expo project.
However, when I debug remote-js in the browser and access the urql tab I see this.

I'm also a little confused by this part of the instructions.

What's "the electron app"?

Thanks!

Stuck in "Waiting for exchange"

Hello and thanks for URQL.

I'm attempting to set up the devtools in a basic web app. I've added the devtools exchange to the client, but the URQL panel in the dev tools says "Waiting for exchange". How can I debug this?

Here's my client config code for reference:

import { Client, fetchExchange, gql } from "@urql/svelte";
import { cacheExchange } from "@urql/exchange-graphcache";
import { devtoolsExchange } from "@urql/devtools";
import * as util from '@/lib/util';

export default function client() {
    const client = new Client({
        url: "http://localhost:4040/api/report-graphql",
        exchanges: [
            devtoolsExchange,
            cacheExchange({ ... }),
            fetchExchange,
        ],
        fetchOptions: () => {
            const csrfToken = util.csrfToken();
            return {
                headers: { "X-CSRF-Token": csrfToken },
            };
        },
    });

    return client;
}

Uncaught ReferenceError: process is not defined

I'm using @rollup/plugin-replace:

...
    replace({
      'process.env.NODE_ENV': JSON.stringify(
        production ? 'production' : 'development'
      )
    }),

but I get this error using @urql/svelte:

urql-devtools-exchange.es.js:46 Uncaught ReferenceError: process is not defined
    at devtoolsExchange (urql-devtools-exchange.es.js:46)
    at urql-core.mjs:329
    at Array.reduceRight (<anonymous>)
    at urql-core.mjs:328
    at new Z$1 (urql-core.mjs:418)
    at initClient (urql-svelte.mjs:63)
    at Object.OnInit (urql.js:162)
    at onInit (actions.js:14)
    at instance$q (App.svelte:14)
    at init (index.mjs:1409)

Remove React dependency

We are looking at React internals to derive the displayName we could defer this to the integration specific implementation and make this a dev-only thing.

Error when using as an SSR module in SvelteKit

We're seeing the following error when using the devtools exchange within sveltekit as a module. For example, I have a gql.js file in which I'm setting up urql and all related exchanges, but when I pull that into a __layout.js and set it up, I'm getting the following error.

TypeError: window.addEventListener is not a function
    at /Users/<REDACTED>/node_modules/@urql/devtools/dist/urql-devtools-exchange.js:240:12
    at /Users/<REDACTED>/node_modules/@urql/devtools/dist/urql-devtools-exchange.js:257:4
    at Object.<anonymous> (/Users/<REDACTED>/node_modules/@urql/devtools/dist/urql-devtools-exchange.js:258:2)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:196:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:183:25)
    at async Loader.import (node:internal/modules/esm/loader:178:24)
4:55:21 PM [vite] Error when evaluating SSR module /src/routes/__layout.svelte:
TypeError: window.addEventListener is not a function
    at /Users/<REDACTED>/node_modules/@urql/devtools/dist/urql-devtools-exchange.js:240:12
    at /Users/<REDACTED>/node_modules/@urql/devtools/dist/urql-devtools-exchange.js:257:4
    at Object.<anonymous> (/Users/<REDACTED>/node_modules/@urql/devtools/dist/urql-devtools-exchange.js:258:2)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:196:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:183:25)
    at async Loader.import (node:internal/modules/esm/loader:178:24)
window.addEventListener is not a function
TypeError: window.addEventListener is not a function
    at /Users/<REDACTED>/node_modules/@urql/devtools/dist/urql-devtools-exchange.js:240:12
    at /Users/<REDACTED>/node_modules/@urql/devtools/dist/urql-devtools-exchange.js:257:4
    at Object.<anonymous> (/Users/<REDACTED>/node_modules/@urql/devtools/dist/urql-devtools-exchange.js:258:2)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:196:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:183:25)
    at async Loader.import (node:internal/modules/esm/loader:178:24)
window.addEventListener is not a function
TypeError: window.addEventListener is not a function
    at /Users/<REDACTED>/node_modules/@urql/devtools/dist/urql-devtools-exchange.js:240:12
    at /Users/<REDACTED>/node_modules/@urql/devtools/dist/urql-devtools-exchange.js:257:4
    at Object.<anonymous> (/Users/<REDACTED>/node_modules/@urql/devtools/dist/urql-devtools-exchange.js:258:2)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:196:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:183:25)
    at async Loader.import (node:internal/modules/esm/loader:178:24)

From the looks of it, when I do that, this exchange is relying on window to be available as part of the document, but in this context, that's not true. Maybe to fix, this could be wrapped in a try/catch first so it doesn't fire on the server-side, but does work on the client side.

Conditions for Chrome extension / devtoolsExchange init

Hey,

what are the conditions for the Chrome extension to pick up the devtoolsExchange correctly?

On our website I only see:

Waiting for exchange
Make sure you're using the Urql Devtools exchange!

but it never seems to be able to connect with the urql client.

I use:

  • @urql/preact
  • @urql/devtools
  • devtoolsExchange is first in exchanges
  • the website loads an embed script which initializes web components
  • urql client(s) get initialized within web components

In the source code I saw that the connection between urql client and urql devtools works via window.postMessage, so web components shouldn't be the hurdle

Add support for debugging on native iOS devices (over USB)

About

In react native, this library works great when running on a simulator as localhost will resolve to the host running the packager. However, when running on an actual iOS device, the hostname needs to be the IP Address of the machine running the packager. This can be retrieved through:

import { NativeModules } from 'react-native';
const scriptUrl = NativeModules.SourceCode.scriptURL;

However, there are no options to add the host name into these devtools since by default the native will use localhost:

https://github.com/FormidableLabs/urql-devtools-exchange/blob/3c61033465cd4e40430b6b224f750d332de86532/src/utils/messaging.ts#L21-L30

Add Support for SharedWorker Environments

Our team is currently running URQL in a SharedWorker and we'd like to use urql-devtools but it seems there isn't support for it yet. Currently, our environment is being misidentified as prod/SSR because SharedWorkers don't have a window object (link to code). Would you be able to add support for SharedWorker environments as well?

Let me know if you need any additional information. Thanks! ๐Ÿ˜ƒ

Option to force on in production

Currently, there is no way to force the exchange to work in production. This can be useful when you want to analyse things in production. This has actually been previously discussed on a ticket i created a while ago (on the wrong repo, whoops): urql-graphql/urql-devtools#48.

It was kindly fixed by @JoviDeCroock.

Since then though it looks like the guard on NODE_ENV has returned and theres no way to override it.

It'd probably be annoying for folks to just remove the guard because people might see it unexpectedly start being there in prod (which might be why it came back?), so I understand this is actually not that trivial to fix without major version bump.

Maybe the exchange could have a new init function attached to it which accepts a config object or something?

createClient({
  exchanges: [
    devToolsExchange.init({force: true})
  ]
})

That way you could still use the current behaviour like

createClient({
  exchanges: [
    devToolsExchange
  ]
})

Without changing it for anyone. Alternatively there could be another env var introduced to override.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.