Uploaded image for project: 'Realm JavaScript SDK'
  1. Realm JavaScript SDK
  2. RJS-1909

Web SDK constructs the Apollo GraphQL `HttpLink`

      Problem

      right now when i use the Realm Web SDK with the Apollo GraphQL JS client, i must write the following boilerplate code to construct the HttpLink instance:

      const client = new ApolloClient({
          link: new HttpLink({
            uri: process.env.NEXT_PUBLIC_GRAPHQL_API_ENDPOINT,
            // We get the latest access token on each request
            fetch: async (uri, options) => {
              const accessToken = app?.currentUser?.accessToken;
              options.headers.Authorization = `Bearer ${accessToken}`;
              return fetch(uri, options);
            },
          }),
          cache: new InMemoryCache(),
        });
      

      i would like if this boilerplate could be replaced with a built-in member of the realm-web package.

      Solution

      implement something like User.ApolloHttpLink, so i could replace the above code with something like:

      const client = new ApolloClient({
          link: new user.ApolloHttpLink(),
          cache: new InMemoryCache(),
        });
      

      How important is this improvement for you?

      I'd like to see it, but have a workaround

            Assignee:
            Unassigned Unassigned
            Reporter:
            unitosyncbot Unito Sync Bot
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: