kamilkisiela / apollo-angular

A fully-featured, production ready caching GraphQL client for Angular and every GraphQL server 🎁
https://apollo-angular.com
MIT License
1.5k stars 311 forks source link

Apollo never executes any requests #1990

Closed SirRegion closed 1 year ago

SirRegion commented 1 year ago

Describe the bug

Hi peps,

I'm currently at a complete loss why my code isn't working. I followed the "getting-started" guide, but my client never sends any requests. I even intercepted my browser with mitmproxy, but there aren't any requests there either.

I'm also not getting any error messages.

I'm having a hard time to reproduce this issue in a simple way, because our repository is quite complex (a nx monorepo).

Environment:

Additional context

I know it's hard to help without having access to the code, so I'm mostly looking for debugging tips or hints, what could cause this issue. I did validate that the useFactory method gets called, and i also checked that the component gets loaded correctly (other non apollo functionality works)

Thanks for your help!

SirRegion commented 1 year ago

I solved my issue by not using useFactory during the instantiation.

This is my code now:

 providers: [
        {
            provide: APOLLO_OPTIONS,
            useValue: {
                uri: 'http://localhost:3333/graphql',
                cache: new InMemoryCache()
            },
            deps: [HttpLink],
        }
    ],

I'm not sure if this is a "fix" or just workaround, but it works, so I'm happy