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
Is your feature request related to a problem? Please describe.
I enabled @typescript-eslint/no-unsafe-member-access (part of plugin:@typescript-eslint/recommended-type-checked) and I get into trouble now for Unsafe member access .definitions on an `any` value.
This is due to the typings in ExecutionArgs in @envelop/typesv5.0.0 which look like this:
import{typePlugin}from'graphql-yoga';exportconstuseErrorHandling=(): Plugin=>{return{onExecute: (payload)=>{constoperationName=payload.args.operationNameasunknownasstring;// manual type casting...constoperation=payload.args.document.definitions[0]// ^-- Unsafe member access .definitions on an `any` value
Is unsafely accessing definitions on document: any.
Describe the solution you'd like
Isn't there anything we can do to give the user more hints that we have some sort of clue what these properties are? It is set by the framework isn't it so we should know that it is at least e.g.
exportinterfaceExecutionArgs{schema: Schema;// Whatever the correct type isdocument: Document;// Whatever this type is, and that it is likely including `operation` which is e.g `query` | `mutation`rootValue?: RootValue;// Whatever the correct type iscontextValue?: Record<string,unknown>;// Should be possible to get from Context genericvariableValues?: Record<string,unknown>;operationName?: string;fieldResolver?: SomeFn;typeResolver?: AnotherFn;subscribeFieldResolver?: ThirdFn;}
Describe alternatives you've considered
Overriding the type def myself, but I dont think I can make typings file that overrides an internal type :-(
Laborious type casting in place everytime we access this
The text was updated successfully, but these errors were encountered:
For your information, the typing is a custom one here because we wanted to stay agnostic on the actual engine or schema building libraries you are using.
We are searching for an happy path for you to customize this types and avoid the any types everywhere.
We are exploring the possibility to use module declarations, that would let you override the types we use, or some kind of generics to let you define the actual types to use.
I will keep you update here once we will take action on this.
The workaround during this time is, as you pointed out, to type cast each time you use it... Sorry about that, we should come with a better solution soon.
Is your feature request related to a problem? Please describe.
I enabled
@typescript-eslint/no-unsafe-member-access
(part ofplugin:@typescript-eslint/recommended-type-checked
) and I get into trouble now forUnsafe member access .definitions on an `any` value.
This is due to the typings in
ExecutionArgs
in@envelop/types
v5.0.0
which look like this:Example:
Is unsafely accessing
definitions
ondocument: any
.Describe the solution you'd like
Isn't there anything we can do to give the user more hints that we have some sort of clue what these properties are? It is set by the framework isn't it so we should know that it is at least e.g.
Describe alternatives you've considered
The text was updated successfully, but these errors were encountered: