Giter VIP home page Giter VIP logo

meteor-apollo-accounts's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

meteor-apollo-accounts's Issues

Add natural directives (optionally)

isAuthenticated
hasRole
permissionCheck
Permission.add('LABEL', check)

import { SchemaDirectiveVisitor } from 'graphql-tools';
import { Mongo } from 'meteor/mongo';

export const typeDefs = `
directive @isAuthenticated on FIELD | FIELD_DEFINITION
`;

class IsAuthenticatedDirective extends SchemaDirectiveVisitor {
  visitFieldDefinition(field) {
    field.isAuthenticated = true;

    const { resolve = defaultFieldResolver } = field;

    field.resolve = async function(source, args, context) {
      if (!context.userId) {
        throw new Error(`Unauthorized`);
      }

      return await resolve.apply(this, args);
    };
  }
}

export const schemaDirectives = {
  isAuthenticated: IsAuthenticatedDirective,
};

Error when overriding createUser

My code:

overrideCreateUser: (createUser, _, args, context) => {
    // Optionally override createUser if you need custom logic
    // Or simply restrict him from authenticating
    return createUser.call(null, ...args);
},

The error:

W20181002-02:38:12.299(8)? (STDERR) TypeError: undefined is not a function
W20181002-02:38:12.299(8)? (STDERR)     at Object.overrideCreateUser (imports/graphql/account/index.js:19:23)
W20181002-02:38:12.299(8)? (STDERR)     at Promise.asyncApply (packages/cultofcoders:apollo-accounts/src/Mutation/index.js:28:24)

Is this package meant as drop-in-replacement of nicolaslopezj:apollo-accounts?

The readme still refers to meteor/nicolaslopezj:apollo-accounts, implying that this package is meant as a drop-in replacement of the before mentioned.

import { makeExecutableSchema } from 'graphql-tools';
import { initAccounts } from 'meteor/nicolaslopezj:apollo-accounts';
import { load, getSchema } from 'graphql-load';

Unfortunately, it turned out to be not.

"Unknown type \"HashedPassword\".", ...
"message": "Unknown type \"CreateUserProfileInput\". Did you mean ...
"message": "Cannot query field \"createUser\" on type \"Mutation\". Did you mean ...

Would be nice if the README could be updated, and made the goals of this package, and differences in relation to meteor/nicolaslopezj:apollo-accounts, clear.

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.