Using apollo-client module to do graphql query in vue, how to add request header

in the project built by vue, use the apollo package to do the graphql query. You want to add the request header. The document looks like this:

let apollo: ApolloClient = {
  let configuration = URLSessionConfiguration.default
  // Add additional headers as needed
  configuration.httpAdditionalHeaders = ["Authorization": "Bearer <token>"] // Replace `<token>`

  let url = URL(string: "http://localhost:8080/graphql")!

  return ApolloClient(networkTransport: HTTPNetworkTransport(url: url, configuration: configuration))
}()

well, it probably means that when creating a query client, add the networkTransport configuration parameter, this HTTPNetworkTransport is imported from where, can not be found, ah, the networkTransport configuration parameter is not entered from the ApolloClient, ah, whether the usage has been changed and the document has not been updated.
has anyone ever done this, under the guidance.
apollo-client version 2.2.5

Feb.28,2021

give up, you don't have to learn new technologies. Graphql is suitable for big companies, but for small companies, don't play with it. And now there is no easy-to-use package, to implement their own, ordinary query can also, if it is to modify the action development will be more and more difficult, tired front and back.

Menu