https://www.the-guild.dev/graphql/codegen
I have run through the getting started guide and now I have a generated code file that was built from an existing deployed federated graph. In there I have:
export type Query = {
__typename?: 'Query';
customerById: Customer;
// not a complete list
OK, now I'd like to use that query to get a customer, say it's customer ID 5a5e5aca-5512-4fb7-bde4-03fadf88e777
. The docs have me writing new GQL, e.g.:
const allFilmsWithVariablesQueryDocument = graphql(/* GraphQL */
query allFilmsWithVariablesQuery($first: Int!) {
allFilms(first: $first) {
edges {
node {
...FilmItem
...
const { data } = useQuery(allFilmsWithVariablesQueryDocument, { variables: { first: 10 } })
Which makes it seem like I need local GQL to query my remote GQL?
But really I'd like to just write something like const customer = runQuery(Queries.customerById, {id: '5a5e5aca-5512-4fb7-bde4-03fadf88e777' })
. Which is much closer to what Zeus does (see "Query with Zeus Chain Client" section).
I'd like to be able to get autocomplete in a query. Zeus has this, sort of, but there are some odd dependencies (global fetch, global Websocket) that put me off of it -- I don't want to have to correct generated code.
Is this a capability that @graphql-codegen has? or am I misunderstanding? If it's possible to use that Query:customerById
in a function, how?