2

Does anyone work with ApolloGraphQl + Rescript? I struggle with uploading files. How to implement apollo-upload-client ? As I understand I should modify httpLink using the createUploadLink, and this function change content-type in my request.

let httpLink = ApolloClient.Link.HttpLink.make(~uri=_ => Env.graphqlEndpoint, ())
........................................
let client = {
  open ApolloClient
  make(
    ~cache=Cache.InMemoryCache.make(),
    ~connectToDevTools=true,
    ~defaultOptions=DefaultOptions.make(
      ~mutate=DefaultMutateOptions.make(~awaitRefetchQueries=true, ~errorPolicy=All, ()),
      ~query=DefaultQueryOptions.make(~fetchPolicy=NetworkOnly, ~errorPolicy=All, ()),
      ~watchQuery=DefaultWatchQueryOptions.make(~fetchPolicy=NetworkOnly, ~errorPolicy=All, ()),
      (),
    ),
    ~link=ApolloClient.Link.from([authTokenContextLink, httpLink]),
    (),
  )
}

If someone helps me with it I’ll be really appreciated

1 Answer 1

1
@module("apollo-upload-client")
external createUploadLink: {"uri": string} => ApolloClient.Types.ApolloLink.t = "createUploadLink"

let uploadLink = createUploadLink({"uri": "..."})

and one of my mistakes was that I tried to use my own types for File instead of standard Js.Json.t when got the data from the input

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.