Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there a way to use this with GraphQL requests? #123

Closed
spsaucier-bakkt opened this issue Mar 18, 2021 · 7 comments
Closed

Is there a way to use this with GraphQL requests? #123

spsaucier-bakkt opened this issue Mar 18, 2021 · 7 comments

Comments

@spsaucier-bakkt
Copy link

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?

@MaxToyberman
Copy link
Owner

Hi @spsaucier-bakkt i am not familiar with GraphQL, i don't think this library can be used with it.

@dacevedo12
Copy link

It can be used, just specify the fetch option on your http link

@mrmarktyy
Copy link

It can be used, just specify the fetch option on your http link

Thank you @dacevedo12 for the reply.
Would you mind add a snippet code around add fetch option with http link

Thanks!

@dacevedo12
Copy link

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

@jigneshpatel-dreampay
Copy link

jigneshpatel-dreampay commented Jul 26, 2022

dacevedo12

It is giving me an error for fetch: secureFetch type mismatch.

Type '(uri: string, options: ReactNativeSSLPinning.Options) => Promise<ReactNativeSSLPinning.Response>' is not assignable to type '(input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>'.

@dacevedo12
Copy link

@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

@SarviroRoman
Copy link

dacevedo12

It is giving me an error for fetch: secureFetch type mismatch.

Type '(uri: string, options: ReactNativeSSLPinning.Options) => Promise<ReactNativeSSLPinning.Response>' is not assignable to type '(input: RequestInfo, init?: RequestInit | undefined) => Promise<Response>'.

Hello, do you have a working example?
I'll be very thankful)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants