Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
makeInputType(),
remove(['id'])
);
composeType('RootMutation',
add('createUser', composeType('User').queryById)
);
//----------- ROOT CONSTRUCTOR (in progress, not ready)
composeType('RootQuery',
add('user', composeType('User').queryById),
add('userList', composeType('User').queryList),
add('userConnection', composeType('User').queryConnection),
add('superUser', composeType('SuperUser').queryById)
);
//----------- INTERFACES
composeInterface('Timestable',
description('Timestable interface for types, which have fields with creation and modification time'),
add('createdAt', {
type: GraphQLDate,
}),
add('updatedAt', {
type: GraphQLDate,
}),
addTypeResolver( // too bad name, need another
(value, info) => {
cloneType('User'),
makeInputType(),
remove(['id'])
);
composeType('RootMutation',
add('createUser', composeType('User').queryById)
);
//----------- ROOT CONSTRUCTOR (in progress, not ready)
composeType('RootQuery',
add('user', composeType('User').queryById),
add('userList', composeType('User').queryList),
add('userConnection', composeType('User').queryConnection),
add('superUser', composeType('SuperUser').queryById)
);
//----------- INTERFACES
composeInterface('Timestable',
description('Timestable interface for types, which have fields with creation and modification time'),
add('createdAt', {
type: GraphQLDate,
}),
add('updatedAt', {
type: GraphQLDate,
}),
addTypeResolver( // too bad name, need another
//----------- ROOT CONSTRUCTOR (in progress, not ready)
composeType('RootQuery',
add('user', composeType('User').queryById),
add('userList', composeType('User').queryList),
add('userConnection', composeType('User').queryConnection),
add('superUser', composeType('SuperUser').queryById)
);
//----------- INTERFACES
composeInterface('Timestable',
description('Timestable interface for types, which have fields with creation and modification time'),
add('createdAt', {
type: GraphQLDate,
}),
add('updatedAt', {
type: GraphQLDate,
}),
addTypeResolver( // too bad name, need another
(value, info) => {
const type = value._type ? composeStorage.Types.get(value._type) : null;
if (type) {
return type;
}
}
),
addTypeResolver(otherTypeResolver),
);
myName: 'name',
surname: 'lastname',
}),
restrict({
hasAccess: (source, args, context, info) => {
return context.isAdmin;
},
fields: ['name', 'dob'],
}),
restrict({
hasAccess: (source, args, context, info) => {
return context.isOwner;
},
fields: ['stats'],
}),
add('time',
{
type: GraphQLString,
resolve: (source, args, context, info) => {
return JSON.stringify(Date.now());
},
}
),
changeValue({
name: ({ source, args, context, info }) => `${source.name} modified`,
}),
// example of custom type-middleware
next => typeConfig => {
const gqType = next(typeConfig);
return gqType;
},
composeType('SuperUser',
cloneType('User'),
add('isSuperUserType',
{
type: GraphQLBoolean,
resolve: () => true,
}
)
);
//---------- FIELD RESOLVERS
composeType('User',
add(
'friends',
composeField(
// custom field middleware
next => fieldConfig => {
const gqField = next(fieldConfig);
return gqField;
},
description('List of friends'),
addArg('gender', {}),
composeResolve(
argEval(({ source }) => ({ frendId: source._id })),
resolveList('User'),
// example of custom resolve-middleware
next => resolveParams => {
return next(resolveParams).then(payload => payload.map( someFn ));
}),
// example of custom type-middleware
next => typeConfig => {
const gqType = next(typeConfig);
return gqType;
},
);
//---------- INHERITANCE
composeType('SuperUser',
cloneType('User'),
add('isSuperUserType',
{
type: GraphQLBoolean,
resolve: () => true,
}
)
);
//---------- FIELD RESOLVERS
composeType('User',
add(
'friends',
composeField(
// custom field middleware
add('user', composeType('User').queryById),
add('userList', composeType('User').queryList),
add('userConnection', composeType('User').queryConnection),
add('superUser', composeType('SuperUser').queryById)
);
//----------- INTERFACES
composeInterface('Timestable',
description('Timestable interface for types, which have fields with creation and modification time'),
add('createdAt', {
type: GraphQLDate,
}),
add('updatedAt', {
type: GraphQLDate,
}),
addTypeResolver( // too bad name, need another
(value, info) => {
const type = value._type ? composeStorage.Types.get(value._type) : null;
if (type) {
return type;
}
}
),
addTypeResolver(otherTypeResolver),
);
composeType('UserInput',
cloneType('User'),
makeInputType(),
remove(['id'])
);
composeType('RootMutation',
add('createUser', composeType('User').queryById)
);
//----------- ROOT CONSTRUCTOR (in progress, not ready)
composeType('RootQuery',
add('user', composeType('User').queryById),
add('userList', composeType('User').queryList),
add('userConnection', composeType('User').queryConnection),
add('superUser', composeType('SuperUser').queryById)
);
//----------- INTERFACES
composeInterface('Timestable',
description('Timestable interface for types, which have fields with creation and modification time'),
add('createdAt', {
type: GraphQLDate,
}),
add('updatedAt', {
type: GraphQLDate,
}),
composeType('UserInput',
cloneType('User'),
makeInputType(),
remove(['id'])
);
composeType('RootMutation',
add('createUser', composeType('User').queryById)
);
//----------- ROOT CONSTRUCTOR (in progress, not ready)
composeType('RootQuery',
add('user', composeType('User').queryById),
add('userList', composeType('User').queryList),
add('userConnection', composeType('User').queryConnection),
add('superUser', composeType('SuperUser').queryById)
);
//----------- INTERFACES
composeInterface('Timestable',
description('Timestable interface for types, which have fields with creation and modification time'),
add('createdAt', {
type: GraphQLDate,
}),
add('updatedAt', {
type: GraphQLDate,
}
),
);
//---------- MUTATIONS (in progress, not ready)
composeType('UserInput',
cloneType('User'),
makeInputType(),
remove(['id'])
);
composeType('RootMutation',
add('createUser', composeType('User').queryById)
);
//----------- ROOT CONSTRUCTOR (in progress, not ready)
composeType('RootQuery',
add('user', composeType('User').queryById),
add('userList', composeType('User').queryList),
add('userConnection', composeType('User').queryConnection),
add('superUser', composeType('SuperUser').queryById)
);
//----------- INTERFACES