Urql generation #5683
-
|
I currently write my queries under the form of "detached gql tags", using the urql plugin: import {gql} from '@my-app/data';
import {useFooQuery} from '@my-app/graphql-generated';
gql`
query Foo {
pages {
__typename
uid
name
}
}
`;
export function Pages() {
const [result] = useFooQuery();
return /*...*/;
}I have two questions:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Hi @arcanis ! I can recommend you to use Regarding |
Beta Was this translation helpful? Give feedback.
Hi @arcanis ! I can recommend you to use
typed-document-node(see https://the-guild.dev/blog/typed-document-node). It supported natively byurqland you should get a better type-safety and clean bundle. Also,result.datawill be the same one from Urql, because we don't need a wrapper. I think Urql considerdatato be nullable because it follows the signature ofgraphql- where it can returnerrors: [ ... ], data: nullin some cases.Regarding
__typename- By default, thetypescript-operationsadds__typenameto each level, it should be there.We currently don't have a built-in solution for adding new fields, but you can use custom documents loader (https://graphql-code-generator.com/docs/…