New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[graphql] [@apollo/client] add graphql libdef and integrate with @apollo/client #4550
[graphql] [@apollo/client] add graphql libdef and integrate with @apollo/client #4550
Conversation
which isn't in the typescript sources anymore.
// @apollo/client/link/core/types.d.ts | ||
// Globals to support global ApolloLink class | ||
declare type ApolloClient$Path = $ReadOnlyArray<string | number>; | ||
declare type GraphQL$VariableNode = Object; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't use Object
as this resolves to any
. Use { ... }
or { [key: string]: any }
instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 93a5212
In this case, I added a libdef for "graphql", because { ... }
or { [key: string]: any }
led to flow errors in correct application code around the GraphQL types.
} | ||
declare export function makeReference(id: string): Reference; | ||
declare export function isReference(obj: any): boolean; | ||
declare export type StoreValue = number | string | string[] | Reference | Reference[] | null | void | void | Object; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should tidy this type up a bit. void | void
and Object
should be { ... }
as mentioned above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in b3c6310
argObj: any, | ||
name: GraphQL$NameNode, | ||
value: GraphQL$ValueNode, | ||
variables?: Object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Object
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in a763180
Re |
rather than interfaces because they are used with object spread but not class extension.
One problem with with this approach is that |
Right I see |
Other notes:
getMainDefinition
, which is shown in apollo client example code.There is a limitation in flow libdefs, which makes it awkward to define a class hierarchy that spans a module boundary. The following is an error:
I tried combinations of
import typeof
andextends Class<Base>
, but these don't seem to solve the problem.In this PR I left the error suppression
$FlowFixMe[value-as-type]
in the libdef. This lets the libdef source express the class hierarchy and module membership correctly to a human reader, and there are no incorrect flow diagnostics in application code that uses these types.