You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
raw client feels unresolved, not fun enough to use.
Ideas / Proposed Solution(s)
Summary benefits of following idea(s) over current raw approach:
String and DocumentNode are two separate APIs. Consolidating them is easier to learn and use if done right.
Choice between string and document node always left to user. But internally, Graffle could make better
automatic decisions. For example if there are schema-driven features present, then there would be no need
to parse the string into a DocumentNode. Don't require users think about this to get best performance for
their chosen feature set.
Separating variables and operation name from the document parameter allows us to leverage a template literal
approach which is more succinct to read and it brings some other benefits, see following points.
Putting gql method on chain permits IDE tooling support without having to deal with importing gql from graffle
or any other helper package/module. So easier to use.
The type inference is a PITA using the current object approach. I've struggled to get the variables key to
depend on the state of the passed in typed document node/string/query. Moving the variables and operation name
to another method makes the typing much easier to pull off. Functionally, I have been unable to get the result
set to infer with types computed (aka. simplified). While correct, they are unreadable.
The idea of extending gql method to root type namespaces on the chaining api seems to open up a really nice
convenience method. The template literal allows us to have arguments passed in-context. It doesn't allow one
operation argument to apply in two places but that's ok, its just for simple cases. Its sugar. Nice sugar.
Without the template literal succinctness this idea wouldn't be compelling.
Document Level template literal with variables
constdata=awaitgraffle.gql` query pokemonByName ($Name: String!) { pokemonByName (name: $Name) { name continent { name } } } `.run({name: `Pikachu`,})
Document Level template literal with variables, operation name
constdata=awaitgraffle.gql` query pokemonByName ($Name: String!) { pokemonByName (name: $Name) { name continent { name } } } `.run(`pokemonByName`,{name: `Pikachu`,})
Passing in a type variable to have the arguments typed and results inferred.
Is it possible to pass in TypedDocumentNode from https://github.com/dotansimha/graphql-typed-document-node? Im thinking about using the raw client with generated typed document nodes to avoid the client bundle overhead from the generated graffle client. Typed document nodes could likely be tree-shaken per page so that each page only bundles the graphql documents needed instead of a full-blown client.
Perceived Problem
Ideas / Proposed Solution(s)
Summary benefits of following idea(s) over current raw approach:
automatic decisions. For example if there are schema-driven features present, then there would be no need
to parse the string into a DocumentNode. Don't require users think about this to get best performance for
their chosen feature set.
approach which is more succinct to read and it brings some other benefits, see following points.
or any other helper package/module. So easier to use.
depend on the state of the passed in typed document node/string/query. Moving the variables and operation name
to another method makes the typing much easier to pull off. Functionally, I have been unable to get the result
set to infer with types computed (aka. simplified). While correct, they are unreadable.
convenience method. The template literal allows us to have arguments passed in-context. It doesn't allow one
operation argument to apply in two places but that's ok, its just for simple cases. Its sugar. Nice sugar.
Without the template literal succinctness this idea wouldn't be compelling.
Document Level template literal with variables
Document Level template literal with variables, operation name
Passing in a type variable to have the arguments typed and results inferred.
Using a prepared DocumentNode instance.
The
gql
function can continue to be used as a way to create documents.Access the constructed DocumentNode instance
Sugar: Root Type Level template literal. Interpolates variables into GraphQL document
The text was updated successfully, but these errors were encountered: