GithubHelp home page GithubHelp logo

Comments (5)

eddyystop avatar eddyystop commented on September 29, 2024

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.

vigalo avatar vigalo commented on September 29, 2024

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 and convertArgsToFeathers.

  • 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 run generate 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 the pop 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.

eddyystop avatar eddyystop commented on September 29, 2024

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.

vigalo avatar vigalo commented on September 29, 2024

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.

eddyystop avatar eddyystop commented on September 29, 2024

I think I can close this since the elapsed time would indicate the issue is resolved.

from graphql.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.