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
typeGraphQLQuery<Textendsstring>=TextendskeyofRelayPersistentQueries
? RelayPersistentQueries[T]
: GraphQLTaggedNode;typeFeatureRequestGraphQLFn=<Textendsstring>(query: T): GraphQLQuery<T>;// $graphql would be a new function from relay and keep the other one untouched for backward compatibility.constquery=$graphql(` query something { // ... }`)
If the compiler creates a type definition file with all queries like Record<string, OperationType> as the RelayPersistentQueries we would be able to automatically type queries.
This is good either way because if they manage to add the inferring feature to Typescript than we already have this functionality and would be easy to add to our graphql function as well. Then we only deprecate that $graphql function because I can agree that template literals looks better.
The text was updated successfully, but these errors were encountered:
AFAIK Typescript doesn't have the possibilities to
infer
theTemplateStringsArray
that prevents automatic type resolving.It seems like an hard issue for TypeScript to solve. The request has been around since 2019:
microsoft/TypeScript#33304
I was thinking if we could create an alternative to:
To something like this:
If the compiler creates a type definition file with all queries like
Record<string, OperationType>
as theRelayPersistentQueries
we would be able to automatically type queries.This is good either way because if they manage to add the inferring feature to Typescript than we already have this functionality and would be easy to add to our
graphql
function as well. Then we only deprecate that$graphql
function because I can agree that template literals looks better.The text was updated successfully, but these errors were encountered: