Skip to content

Commit

Permalink
add timeout to the client options
Browse files Browse the repository at this point in the history
  • Loading branch information
sywhb committed Mar 7, 2024
1 parent 3f717ae commit 8207c49
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { Client, fetchExchange } from 'urql'
import { graphql } from './graphql'

export interface ClientOptions {
authToken: string
baseUrl: string
timeoutMs?: number
}

const LabelFragment = graphql(`
fragment LabelFragment on Label @_unmask {
name
Expand Down Expand Up @@ -294,14 +300,15 @@ export interface SaveByURLResponse {
export class Omnivore {
_client: Client

constructor(endpoint: string, authToken: string) {
constructor(clientOptions: ClientOptions) {
this._client = new Client({
url: `${endpoint}/api/graphql`,
url: `${clientOptions.baseUrl}/api/graphql`,
exchanges: [fetchExchange],
fetchOptions: () => ({
headers: {
Authorization: authToken,
Authorization: clientOptions.authToken,
},
timeout: clientOptions.timeoutMs || 0,
}),
})
}
Expand Down

0 comments on commit 8207c49

Please sign in to comment.