Apollo client make GET request

I would like to use the apollo client to make a graphql request but as GET like:

this.apollo.query( {
query: TYPE_AHEAD,
variables: {
uuid
}
}).pipe(…);

{
typeAhead(value: “lageris”) {
result
}
}

graphql?query=%7B%0A%20%20typeAhead%28value%3A%20%22lageris%22%29%20%7B%0A%20%20%20%20result%0A%20%20%7D%0A%7D%0A

@mibto if you’re asking how to make GET requests with Apollo Client, when you setup your ApolloClient instance, pass in an a new HttpLink instance with the property useGETForQueries set to true. Something like:

import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";

const link = new HttpLink({ 
  uri: '/graphql',
  useGETForQueries: true,
});

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

@hwillson thanks! that is exactly what i was looking for.

1 Like