# Apollo Client in Auth0 Actions

**URL:** <https://community.auth0.com/t/apollo-client-in-auth0-actions/96871>\
**Category:** Get Help\
**Tags:** extensibility, actions-extensibility\
**Created:** [December 21, 2022, 6:01am UTC](https://community.auth0.com/t/apollo-client-in-auth0-actions/96871 "2022-12-21T06:01:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![chrisar](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/chrisar/32/33549_2.png) [@chrisar](https://community.auth0.com/u/chrisar)\
**Post date:** [December 21, 2022, 6:01am UTC](https://community.auth0.com/t/apollo-client-in-auth0-actions/96871/1 "2022-12-21T06:01:29Z")

</div>

Hi there,

i have a GraphQL API for my Backend. Now i want to create some sample data when the user logged in for the first time. I tried the Auth0 Actions PostSignup because i thought this is the best way. Unfortunately i cant get the Apollo Client to work, thats my current code:

```auto
exports.onExecutePostUserRegistration = async (event, api) => {
  var fetch = require('cross-fetch');
  var _client = require('@apollo/client');
  var gql = require('@apollo/client');
  
  const client = new _client.ApolloClient({
    uri: new _client.HttpLink({ uri: 'https://api.***.de', fetch }),
    cache: new _client.InMemoryCache(),
  });

  client 
  .query({
    query: gql`
      query Todos {
        getTodos {
          createdAt
          description
          id
          isCompleted
          title
          userID
        }
      }
    `,
  })
  .then((result) => console.log(result));
};`Preformatted text`

```

I get this error: "\n"fetch" has not been found globally and no fetcher has been configured.

Do you have any idea whats wrong here ? Or do you even know a way i could implement this maybe in my own project ? I use NextJS.

Thanks!

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [December 22, 2022, 10:30pm UTC](https://community.auth0.com/t/apollo-client-in-auth0-actions/96871/3 "2022-12-22T22:30:49Z")

</div>

Hi @chrisar,

Welcome to the Auth0 Community!

> [@chrisar](#):
>
> I get this error: “\n"fetch” has not been found globally and no fetcher has been configured.

This error happens when you are trying to use a module that was not installed in your Action’s **Dependencies**.

Let me also add that you can only install modules found [here](https://auth0-extensions.github.io/canirequire/#).

 ![image](https://global.discourse-cdn.com/auth0/original/3X/d/c/dc7ad8be64b0ff6fedf3bf3b6981b54954bf691e.jpeg)

> [@chrisar](#):
>
> Now i want to create some sample data when the user logged in for the first time.

For this behavior, I recommend using a Post-Login Action instead of a Post-User Registration Action and checking if the user’s `logins_count === 1`.  
For example:

```auto
exports.onExecutePostLogin = async (event, api) => {
  if(event.stats.logins_count === 1){
    //YOUR CODE HERE
  }
};

```

Please reach out if you have any additional questions.

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [January 5, 2023, 10:31pm UTC](https://community.auth0.com/t/apollo-client-in-auth0-actions/96871/4 "2023-01-05T22:31:49Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
