question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is there a way to use this with GraphQL requests?

See original GitHub issue

We’re using @apollo/client for most requests from the back-end, so we aren’t able to use the fetch methods in the documentation. Is there a way to enable SSL pinning requirements on GraphQL requests?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
dacevedo12commented, Sep 17, 2021

Sure

import { fetch as sslPinningFetch } from "react-native-ssl-pinning";

const secureFetch = async (uri, options) =>
  sslPinningFetch(uri, {
    ...options,
    pkPinning: true,
    sslPinning: {
      certs: ["sha256/your_cert_goes_here"],
    },
  });

const httpLink = createHttpLink({
  fetch: secureFetch,
  uri: `https://www.something.com/api`,
});

You can learn more about using a custom fetch at the official docs https://www.apollographql.com/docs/react/api/link/apollo-link-http/#customizing-fetch

0reactions
dacevedo12commented, Jul 26, 2022

@jigneshpatel-dreampay It’s been almost a year, so it’s very likely the type definitions have changed 😅

I’m no longer working on react native apps, but it can probably be adapted based on the snippet. It’s a matter of creating a way for apollo’s fetch to interact with ssl-pinning’s fetch function

Read more comments on GitHub >

github_iconTop Results From Across the Web

Making GraphQL Requests using HTTP Methods
To make a GraphQL request using the POST HTTP method, we pass the following properties into the JSON body of the request.
Read more >
Serving over HTTP - GraphQL
HTTP is the most common choice for client-server protocol when using GraphQL because of its ubiquity. Here are some guidelines for setting up...
Read more >
Requests and Responses - GraphQL - Dgraph
GraphQL requests can be sent via HTTP POST or HTTP GET requests. ... GET requests must be sent in the following format. The...
Read more >
graphql-request - npm
Start using graphql-request in your project by running `npm i graphql-request`. There are 1946 other projects in the npm registry using ...
Read more >
How to request a GraphQL API with Fetch or Axios - Hasura
Request Body - This is where you will be sending a JSON body to the GraphQL server. Most server implementations use JSON for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found