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

Uncaught ReferenceError: regeneratorRuntime is not defined #3

Closed
ajaypillay opened this issue Jun 19, 2021 · 3 comments
Closed

Uncaught ReferenceError: regeneratorRuntime is not defined #3

ajaypillay opened this issue Jun 19, 2021 · 3 comments

Comments

@ajaypillay
Copy link

ajaypillay commented Jun 19, 2021

Hi, so I've been experimenting around with migrating my hooks to this package but I have this error thrown in my browser console whenever I try to execute a mutation.

I'm using a Meteor/Apollo stack so my client code is as follows:

import React from "react"
import { Meteor } from "meteor/meteor"
import { render } from "react-dom"
import { BrowserRouter } from "react-router-dom"
import { ApolloClient, HttpLink, split, InMemoryCache, ApolloProvider } from "@apollo/client"
import { ApolloLink, from } from "apollo-link"

import { DDPSubscriptionLink, isSubscription } from 'apollo-link-ddp'
import { offsetLimitPagination } from "@apollo/client/utilities"
import { initAugmentedHooks } from "apollo-augmented-hooks"
import App from "../../ui/App"

const httpLink = new HttpLink({ uri: "http://XXX.XXX.XX.XX:3000/graphql" })

const authLink = new ApolloLink((operation, forward) => {
    const token = Accounts._storedLoginToken()
    operation.setContext(() => ({
        headers: {
            authorization: token
        }
    }))
    return forward(operation)
})

const subscriptionLink = new DDPSubscriptionLink()

const splitLink = split(
    isSubscription,
    subscriptionLink,
    httpLink
)

const cache = new InMemoryCache({
    typePolicies: {
        Query: {
            fields: {
                getFeed: offsetLimitPagination()
            }
        }
    }
})

const client = new ApolloClient({
    link: from([authLink, splitLink]),
    cache
})

initAugmentedHooks(client)

const ApolloApp = () => (
    <BrowserRouter>
        <ApolloProvider client={client}>
            <App client={client} />
        </ApolloProvider>
    </BrowserRouter>
)

Meteor.startup(() => {
    render(<ApolloApp />, document.getElementById("app"))
})

And my mutation is merely as follows:

const EDIT_THING = gql`
    mutation EditThing($someInt: Int!) {
        editThing(someInt: $someInt)
    }
`

Initialized as such:

import { useMutation } from "apollo-augmented-hooks"
import { gql } from "@apollo/client"
const sendMutation = useMutation(EDIT_THING)

Further in my component I have:

sendMutation({ variables: { someInt: IntFromComponent }})

But this throws Uncaught ReferenceError: regeneratorRuntime is not defined in my console for some reason. I'm using the latest release, 1.8.0. Have also tried removing the package and re-installing it to no avail.

@mindnektar
Copy link
Owner

Hey Ajay! I won't be able to fix this until Monday, but it's because I forgot to add @babel/polyfill as a dependency, which is required for things like async/await. It works for me, because the projects in which I am using apollo-augmented-hooks include it themselves. You can do the same thing in the meantime, until I add the dependency to this package!

@ajaypillay
Copy link
Author

Ah I see. I shall probably wait till then and work on other things in the meantime. Thanks Martin!

@mindnektar
Copy link
Owner

I've released v1.8.1 - it should work now.

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