Allow Got to be customised via Options
ferronrsmith opened this issue · comments
It would be nice to able to pass additional params to the got i.e agents/custom retry mechanism. Also passing in our own got
object would be nice.
Can you please give some examples?
const query = {
operation: {
name: 'users',
fields: ['name', 'age', 'id']
}
}
const options = {
headers: {
"Authorization": "Bearer <token>"
},
debug: false
gotOptions: {
agent: {
http: new HttpAgent(),
https: new HttpsAgent()
},
retry: 5
}
}
gotQL.query('mygraphqlendpoint.com.br/api', query, options)
.then(response => console.log(response.data))
.catch(console.error)
Also being able to pass in a custom got
instance would be nice. https://www.npmjs.com/package/got#instances
Awesome, will take a look into it and implement in the next version. I expect to be able to implement it this month, but I'm kinda busy on some other stuff, so probably this will come next month or so.
Thanks for the contribution :)
So that you know @ferronrsmith, I've already added this to my todo list around the week of August 19th. So I'll start working on this and #6 altogether. Should be finished and deployed sometime around Aug 20th or even in the same day ;)
Thanks !
Is this feature currently working? I am getting the error Error when executing query: The 'body', 'json' and 'form' options are mutually exclusive
whenever I try to add a custom gotInstance to my options. Am I implementing this incorrectly?
const options = {
gotInstance: got.extend({
timeout: 100
})
}
gotQL.query('https://myendpoint/graphql', query, options)
Hey! Thanks for the commenting
It should be running without any problems, can you please open an issue about this so I can link all the solutions? I'll try to reproduce your code and check if that happens
Looking into it!