import { GraphQLObjectType, GraphQLInputObjectType, GraphQLString, GraphQLBoolean, GraphQLInt, GraphQLList, GraphQLFloat, GraphQLNonNull, } from 'graphql'; import { ICreateResidentialComplexInput, IResidentialComplex, } from '../model/residentialComplex'; import { authorized } from '../auth'; import { createResidentialComplex, } from './residentialComplexRepository'; const residentialComplexDescription = { id: 'Id in iworks.residential_complex', numResidentialComplex: 'Should be equal to constructor.residential_complex.id db', name: 'Residential complex name', company: 'Residential complex developer company', }; const residentialComplexType = new GraphQLObjectType({ name: 'ResidentialComplexType', description: 'Residential compex', fields: () => ({ id: { type: new GraphQLNonNull(GraphQLString), description: residentialComplexDescription.id, }, }), }); const residentialComplexInputType = new GraphQLInputObjectType({ name: 'ResidentialComplexInputType', description: 'Residential complex type', fields: () => ({ numResidentialComplex: { type: new GraphQLNonNull(GraphQLInt), description: residentialComplexDescription.numResidentialComplex, }, name: { type: new GraphQLNonNull(GraphQLString), description: residentialComplexDescription.name, }, company: { type: new GraphQLNonNull(GraphQLString), description: residentialComplexDescription.company, }, }), }); export default { createResidentialComplex: { description: 'Creates a residential complex', type: residentialComplexType, args: { input: { type: new GraphQLNonNull(residentialComplexInputType) }, }, resolve: authorized( ['AM', 'CE', 'CD'], (_: any, { input }: ICreateResidentialComplexInput) => { return createResidentialComplex(input); }, ), }, };