I am working in graphql using node js. I want to get the hostname of a server and use it in anywhere of file.
here is my code:
app.use('/api',graphqlHTTP((req,res)=>({
context:{
oauth_token:req.oauth_token,
host : req.headers['host'],
ip: req.ip
},
schema,
graphiql: true,
})));
I am accessing it in schema file through resolver. Like:
resolve: (parent, args, context, resolveInfo) => {
host = context.host;
}
Here I can fetch hostname. But how could I use it in any file?