cult-of-coders / meteor-apollo-accounts Goto Github PK
View Code? Open in Web Editor NEWMeteor Accounts & Apollo
License: MIT License
Meteor Accounts & Apollo
License: MIT License
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,
};
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)
Trying to get the social login working. loginWithPassword
is working fine, but when I call loginWithFacebook
, the backend is throwing an Error:
Error: GraphQL error: Meteor.userId can only be invoked in method calls or publications.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.