Comments (5)
The service calls made by resolves are no different than any other service calls made by the service.
Perhaps you can ask in #general how to set headers for such calls.
from graphql.
Thanks for your quick response .
The service calls are a little different. Looking at sources I found :
Enabled Feathers authentication on services for services called in
GraphQL resolver functions.
Combined changes for graphql and generator-feathers-plus
-
Summary:
-
params.provider, user & authenticated are copied from the
graphql service call into the params for every Feathers service call
in a resolver of BatchLoader. -
If you need additional props to be copied over, include their names in
options.extraAuthProps
andconvertArgsToFeathers
. -
For custom resolvers or BatchLoaders, you need to record the
convertArgsToFeathers()
call as explained in the details. -
Note you can enable authentication on a Feathers service or graphql
only if you've rungenerate authentication
first. -
Details:
-
'content' param in resolver calls now contains
provider: params.provider, user: params.user &
authenticated: params.authenticated (if any) from the /graphql call. -
In
const createdService = createService(options);
options.extraAuthProps can pass an array of additional prop names
to be copied from params to content.
This allows other auth-related props to be copied into content. -
The previous
convertArgsToFeathers(args, ast, {...})
is recoded to
const convertArgs = convertArgsToFeathers([/* prop names */]);
...
convertArgs(args, content, ast, {...})
where thepop names
would normally be the same names used in
options.extraAuthProps
. These are additional props to copy into parms
for the Feathers service call being made in the resolver function.
So, my workaround to solve my problem was;
In graphql.service.?s :
// !code: func_init // !end
let options = {
schemas,
resolvers,
extraAuthProps: ['headers']
};
// !code: func_options // !end
In service.resolvers.?s :
// !code: extra_auth_props
const convertArgs = convertArgsToFeathers(['headers']);
// !end
from graphql.
Info thanks. I assume your server does not have websicket clients.
The generated code is meant to be changed for particular circumstances like yours.
from graphql.
Thanks, eddystop :
Yes, my server has websockets clients althought currently I'm implementing the graphql and trying it with GraphiQl over rest for now.
from graphql.
I think I can close this since the elapsed time would indicate the issue is resolved.
from graphql.
Related Issues (10)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graphql.