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)
@cdaringe this is fixed on master in pg_graphql please try again when ready & lmk if you run into anything unexpected
created the issue in pg_graphql: https://github.com/supabase/pg_graphql/issues/40
@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:
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
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 😃
bug-demo
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 callinggqty generate
from thepackages/mfe-admin-gql-client
folder iff neededdebugger
statements. how irritating! I added a terser config to not dropdebugger
statementspatches 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 😃