Skip to content
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

Cannot read properties of undefined (reading 'length') - graphql-ruby-client npm package (js_client) #4170

Closed
j-arnaiz opened this issue Aug 26, 2022 · 1 comment

Comments

@j-arnaiz
Copy link

Im trying to make it work with a graphql cable server but when i add a split with ActionCableLink it generates an error on ApolloLink
in this line:

return link.request.length <= 1;

due to link.request is undefined

Is this library working with apollo 3.6.9?

The problem is in javascript:

const ActionCable = import('@rails/actioncable')
import ActionCableLink from 'graphql-ruby-client/subscriptions/ActionCableLink'

...


split(
      // split based on operation type
      ({ query }) => {
        const { kind, operation } = getMainDefinition(query)
        return kind === 'OperationDefinition' &&
          operation === 'subscription'
      },
      new ActionCableLink({ cable: ActionCable.createConsumer("ws://myhost:port") }),
      httpLink
    )

Describe the bug

Apollo breaks with TypeError: Cannot read properties of undefined (reading 'length') when using ActionCableLink

Versions
Backend
graphql version: 2.0.12
rails (or other framework): 7.0.3.1

Frontend:
apollo/client: 3.6.9
@rails/actioncable: "7.0.3-1",
graphql-ruby-client: "^1.11.1",

Log

react-dom.development.js?9c41:29840 Download the React DevTools for a better development experience: https://reactjs.org/link/react-devtools
ApolloLink.js?6fa2:12 Uncaught TypeError: Cannot read properties of undefined (reading 'length')
at isTerminating (ApolloLink.js?6fa2:12:1)
at ApolloLink.split (ApolloLink.js?6fa2:39:1)
at createApolloClient (apolloClient.js?44bf:90:22)
at initializeApollo (apolloClient.js?44bf:127:3)
at eval (apolloClient.js?44bf:167:28)
at mountMemo (react-dom.development.js?9c41:17225:1)
at Object.useMemo (react-dom.development.js?9c41:17670:1)
at useMemo (react.development.js?dad3:1650:1)
at useApollo (apolloClient.js?44bf:167:28)
at App (VM24807 _app.js:100:84)
at renderWithHooks (react-dom.development.js?9c41:16305:1)
at mountIndeterminateComponent (react-dom.development.js?9c41:20074:1)
at beginWork (react-dom.development.js?9c41:21587:1)
at HTMLUnknownElement.callCallback (react-dom.development.js?9c41:4164:1)
at Object.invokeGuardedCallbackDev (react-dom.development.js?9c41:4213:1)
at invokeGuardedCallback (react-dom.development.js?9c41:4277:1)
at beginWork$1 (react-dom.development.js?9c41:27451:1)
at performUnitOfWork (react-dom.development.js?9c41:26557:1)
at workLoopSync (react-dom.development.js?9c41:26466:1)
at renderRootSync (react-dom.development.js?9c41:26434:1)
at performConcurrentWorkOnRoot (react-dom.development.js?9c41:25738:1)
at workLoop (scheduler.development.js?ad37:266:1)
at flushWork (scheduler.development.js?ad37:239:1)
at MessagePort.performWorkUntilDeadline (scheduler.development.js?ad37:533:1)
isTerminating @ ApolloLink.js?6fa2:12
ApolloLink.split @ ApolloLink.js?6fa2:39
createApolloClient @ apolloClient.js?44bf:90
initializeApollo @ apolloClient.js?44bf:127
eval @ apolloClient.js?44bf:167
mountMemo @ react-dom.development.js?9c41:17225
useMemo @ react-dom.development.js?9c41:17670
useMemo @ react.development.js?dad3:1650
useApollo @ apolloClient.js?44bf:167
App @ VM24807 _app.js:100
renderWithHooks @ react-dom.development.js?9c41:16305
mountIndeterminateComponent @ react-dom.development.js?9c41:20074
beginWork @ react-dom.development.js?9c41:21587
callCallback @ react-dom.development.js?9c41:4164
invokeGuardedCallbackDev @ react-dom.development.js?9c41:4213
invokeGuardedCallback @ react-dom.development.js?9c41:4277
beginWork$1 @ react-dom.development.js?9c41:27451
performUnitOfWork @ react-dom.development.js?9c41:26557
workLoopSync @ react-dom.development.js?9c41:26466
renderRootSync @ react-dom.development.js?9c41:26434
performConcurrentWorkOnRoot @ react-dom.development.js?9c41:25738
workLoop @ scheduler.development.js?ad37:266
flushWork @ scheduler.development.js?ad37:239
performWorkUntilDeadline @ scheduler.development.js?ad37:533
next-dev.js?878b:24 Warning: An error occurred during hydration. The server HTML was replaced with client content in

.

@j-arnaiz j-arnaiz changed the title graphql-ruby-client npm package (js_client) graphql-ruby-client npm package (js_client) Cannot read properties of undefined (reading 'length') Sep 15, 2022
@j-arnaiz j-arnaiz changed the title graphql-ruby-client npm package (js_client) Cannot read properties of undefined (reading 'length') Cannot read properties of undefined (reading 'length') - graphql-ruby-client npm package (js_client) Sep 15, 2022
@rmosolgo
Copy link
Owner

Sorry I never investigated this! If anyone encounters something similar on more recent versions of these libraries, please open a new issue and we'll look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants