gqty icon indicating copy to clipboard operation
gqty copied to clipboard

[Question] GQTy cli uses "gqty.config.js" file for generating pages?

Open aitoraznar opened this issue 3 years ago • 5 comments

Hi.

I have the need to add some headers into the GQTY introspection. The command gqty generate seems to work fine but when next build generates the pages the config it's not used.

so my question is GQTy cli uses "gqty.config.js" file for generating pages?

Many thanks

My config file: Screenshot 2022-04-27 at 11 44 53

aitoraznar avatar Apr 27 '22 10:04 aitoraznar

I don't think I understand, gqty doesn't generate any pages, and the whole point of gqty is to only generate once, since all the queries are generated on runtime

PabloSzx avatar Apr 27 '22 14:04 PabloSzx

The config is used on both "gqty generate" and cli programmatic usage https://gqty.dev/docs/cli/programmatic

PabloSzx avatar Apr 27 '22 14:04 PabloSzx

Maybe it's a feature of FaustJS that uses the GraphQL endpoint to get the page data to generate it at NextJS' build time.

I'll try to go deep into this.

many thanks

aitoraznar avatar Apr 27 '22 15:04 aitoraznar

If I am understanding the question correctly, gqty.config.js is only used when you generate the client.

Common use cases of next.js only imports the generated client, it should not be aware of gqty.config.js at all.

If you want to include custom headers at runtime, e.g. when you are doing next build, you may have to edit the fetch code of the generated client.

vicary avatar Apr 28 '22 08:04 vicary

@aitoraznar checkout https://codesandbox.io/s/gqty-sandbox-forked-o9int?from-embed=&file=/src/gqty/index.ts:803-874 as an example of how to provide a custom queryFetcher to your gqty client. As mentioned above, the headers in the gqty config are only for the introspection request (which is why they are under the introspection property).

jordanmaslyn avatar May 06 '22 17:05 jordanmaslyn

@aitoraznar please reopen and add more context if you find this is still an issue.

vicary avatar Dec 04 '22 17:12 vicary