Skip to content

Apollo 4.x #42

@tho-graf

Description

@tho-graf

Hi there,

we just migrated to Apollo 4.x. Our TypeScript complained about the possible undefined forward in request. Our temporary fix is this:
I am not sure when forward is really undefined? Would you be willing to make this link Apollo 4.x ready? Happy to give a helping hand!

Cheers
Thomas

// Wraps apollo-link-serialize package (version 4.0.0) which uses @apollo/client 3.3.20 to work with @apollo/client 3.4.x
export class SerializingLinkWrapper extends ApolloLink {
  private serializingLink: SerializingLink;

  constructor() {
    super();
    this.serializingLink = new SerializingLink();
  }

  request(operation: Operation, forward?: NextLink): Observable<FetchResult> | null {
    if (forward) {
      return this.serializingLink.request(operation, forward);
    } else {
      throw new Error('Missing NextLink');
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions