TS apps are unable to instantiate ApolloController
s outside of class definition or to specify dynamic ApolloClient
instance
#274
Labels
bug
Something isn't working
Package
@apollo-elements/core
Description
Filing this here to track lit/lit#2446. Once this upstream issue is rectified, this can be marked resolved.
Summary: it should be possible to instantiate
ApolloQueryController
et. al. within various lifecycle methods (eg.LitElement
'sconnectedCallback
). Currently this will cause a runtime error due to the way the TypeScript compiler handles private member access.Additionally, since
ReactiveElement
properties are not assigned until after the constructor is called, the standard pattern of passing a client down to child components through element context is not workable (any specifiedclient
property will be undefined during class member declarations). This means thatApolloClient
is always assigned from thewindow.__APOLLO_CLIENT__
global and that multiple client instances in the same app are not possible.Steps To Reproduce
You can see this behaviour in any
ReactiveElement
which uses a configuration similar to this (example given as aLitElement
):If code similar to the above is compiled with
tsc
, it will throw a private member access error at the indicated line.Expected Behavior
We should be able to initialise
ApolloController
objects and bind them to a host component dynamically at any time in that host component's lifecycle.Additionally, we should be able to dynamically specify
client
in theApolloController
options, passing a client which has been assigned viaReactiveElement
properties.The text was updated successfully, but these errors were encountered: