Skip to content

Commit

Permalink
small adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollinaire committed Sep 2, 2018
1 parent 043baec commit 0b4d3ae
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 26 deletions.
4 changes: 2 additions & 2 deletions packages/example-movies/lib/components/movies/MoviesList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ const MoviesList = ({ results = [], currentUser, loading, loadMore, count, total

{/* load more */}

{/*totalCount > results.length ?
{ totalCount > results.length ?
<a href="#" onClick={e => {e.preventDefault(); loadMore();}}>Load More ({count}/{totalCount})</a> :
<p>No more items.</p>
*/}
}
</div>
)}
</div>
Expand Down
4 changes: 2 additions & 2 deletions packages/example-movies/lib/modules/movies/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ const Movies = createCollection({
schema: schema,

resolvers: resolvers,
//resolvers: getDefaultResolvers({typeName:'Movie'}),
// resolvers: getDefaultResolvers({typeName:'Movie'}),

mutations: mutations,
//mutations: getDefaultMutations({typeName: 'Movie'}),
// mutations: getDefaultMutations({typeName: 'Movie'}),
});

export default Movies;
8 changes: 4 additions & 4 deletions packages/example-movies/lib/modules/movies/mutations.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
Define the three default mutations:
- new (e.g.: moviesNew(document: moviesInput) : Movie )
- edit (e.g.: moviesEdit(documentId: String, set: moviesInput, unset: moviesUnset) : Movie )
- remove (e.g.: moviesRemove(documentId: String) : Movie )
- create (e.g.: createMovie(data: {document: CreateMovieDataInput!}) : MovieOutput )
- update (e.g.: updateMovie(selector: MovieSelectorUniqueInput!, data: UpdateMovieDataInput!) : MovieOutput )
- delete (e.g.: deleteMovie(selector: MovieSelectorUniqueInput!) : MovieOutput )
Each mutation has:
Expand All @@ -28,7 +28,7 @@ const mutations = {

check(user) {
if (!user) return false; //the user must be logged in
return Users.canDo(user, 'movies.new'); // the user must have the permission to do the mutation. For this, see permissions.js
return Users.canDo(user, 'movies.create'); // the user must have the permission to do the mutation. For this, see permissions.js
},

mutation(root, args, context) {
Expand Down
2 changes: 1 addition & 1 deletion packages/example-movies/lib/modules/movies/parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ function sortByYear (parameters, terms) {
};
}

addCallback('movies.parameters', sortByYear);
addCallback('movie.parameters', sortByYear);
2 changes: 1 addition & 1 deletion packages/example-movies/lib/modules/movies/permissions.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Users from 'meteor/vulcan:users';

const membersActions = [
'movies.new',
'movies.create',
'movies.update.own',
'movies.delete.own',
];
Expand Down
30 changes: 14 additions & 16 deletions packages/example-movies/lib/modules/movies/resolvers.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,35 @@
/*
Three resolvers are defined:
Two resolvers are defined:
- list (e.g.: moviesList(terms: JSON, offset: Int, limit: Int) )
- single (e.g.: moviesSingle(_id: String) )
- listTotal (e.g.: moviesTotal )
- multi (e.g.: movies (terms: JSON, offset: Int, limit: Int) )
- single (e.g.: movie (_id: String) )
*/

// basic list, single, and total query resolvers
// basic multi and single resolvers
const resolvers = {

multi: {

name: 'movies',

async resolver(root, {terms = {}}, context, info) {
let {selector, options} = await context.Movies.getParameters(terms, {}, context.currentUser);
return {results: context.Movies.find(selector, options).fetch()};
async resolver(root, args, context) {
const { input: {terms = {}} } = args;
let { selector, options } = await context.Movies.getParameters(terms, {}, context.currentUser);
movies = await context.Movies.find(selector, options);
moviesContent = movies.fetch();
moviesCount = movies.count();
return { results: moviesContent, totalCount: moviesCount };
},

},

single: {

name: 'movie',

resolver(root, args, context) {
const _id = args.input.selector.documentId || args.input.selector._id; // we keep this for backwards comp until SmartForm passes _id as a prop
const document = context.Movies.findOne({_id: _id});
return {result: context.Users.restrictViewableFields(context.currentUser, context.Movies, document)}
const _id = args.input.selector.documentId || args.input.selector._id; // we keep this for backwards comp until SmartForm passes _id as a prop
const document = context.Movies.findOne({ _id: _id });
return { result: context.Users.restrictViewableFields(context.currentUser, context.Movies, document) };
},

},
};

Expand Down

0 comments on commit 0b4d3ae

Please sign in to comment.