gqty: basic query results in infinite loop (issue with pg_graphql)

Problem

Using a basic query results in an infinite loop.

import { useQuery } from "mfe-admin-gql-client";

export default function Home() {
  const query = useQuery({
    suspense: false,
  });
  if (query.$state.isLoading) return <p>Loading...</p>;
  return (
      <pre>
        {query.allMfes().edges?.map((e) => {
          return e.node.version; // 😵
        })}
      </pre>
  )
}

The network tab shows that each and every query completes successfully.

It is not repeatable on all APIs, but my API and project is very repeatable. Mentioned also in #314. Seems perhaps a cache lookup issue?

Reproduction

Requires docker-compose

https://github.com/cdaringe/mfe-tools/tree/bug-demo#reproduction

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

@cdaringe this is fixed on master in pg_graphql please try again when ready & lmk if you run into anything unexpected

@cdaringe confirmed that this is an issue with the API not respecting the graphql alias, you can read about it here https://graphql.org/learn/queries/#aliases:

Check:

image image

the graphql request clearly requires that allMfes is served in allMfes0, which is not what it’s getting, gqty starts looping because it doesn’t do validation on the API request, it just assumes the data coming from the server is correct

Hi @PabloSzx, thanks for your hard work. How can I apply this patch of “pg_graphql” in gqty? I’m not sure if it’s a gqty thing or this has to be applied in the server-side (in my case wp-graphql for Wordpress). Many thanks.

Yeah, it’s not a gqty thing, it this issue appears in another environment different than pg_graphql we need a way to reproduce the issue

Ok, there were a few things that made debugging less intuitive 😃

  • make sure you are on the correct branch,bug-demo
  • the build script was purging the gqty code and regenerating it 😃, Previously, it was"build": "rm -rf src/generated && gqty generate && tsc". whoops! patched. it will not generate any more on build. you can just manually regenerate as needed by calling gqty generate from the packages/mfe-admin-gql-client folder iff needed
  • parcel was stripping debugger statements. how irritating! I added a terser config to not drop debugger statements

patches here: https://github.com/cdaringe/mfe-tools/commit/d2d70d4cc35ea9561f5835a3ca017ac8545cd575

So, when you make changes, you can just run npm build from the root, and it will take. I followed my own instructions on a fresh clone, and these patches should make your expectations work 😃