feat: Adding basic GraphQL elements (company,user,sessions)

This commit is contained in:
Josepablo C
2024-08-06 12:19:53 -06:00
parent ae920ca2c7
commit 6b4c475a38
7 changed files with 385 additions and 39 deletions

View File

@@ -1,6 +1,6 @@
'use strict';
const { DateResolver, DateTimeResolver } = require('graphql-scalars');
const { Account, User, Company } = require('../../Domain');
const { Account, User, Company, getUserById, getCompanyById, findUsersPage, findCompaniesPage } = require('../../Domain');
//////////////////////////////////////////////
// Queries
@@ -20,12 +20,34 @@ async function company( args, context ) {
return company;
}
//////////////////////////////////////////////
async function companyById( args, context ) {
return getCompanyById( args.id );
}
async function userById( args, context ) {
return getUserById( args.id );
}
async function findCompanies( args, context ) {
const { filters, elements, page } = args;
return findCompaniesPage( filters, elements, page );
}
async function findUsers( args, context ) {
const { filters, elements, page } = args;
return findUsersPage( filters, elements, page );
}
/////////////////////////////////////////////////
// Mutations
//////////////////////////////////////////////
/////////////////////////////////////////////////
module.exports = {
account,
profile,
company
company,
companyById,
userById,
findCompanies,
findUsers
};

View File

@@ -2,6 +2,12 @@ type Query {
account : Account!
profile : User!
company : Company!
companyById( id : Int! ) : PublicCompany
userById( id : Int! ) : PublicUser
findCompanies( filters : FindCompanyFilterInput!, elements: Int!, page: Int! ) : PublicCompanyFound!
findUsers( filters : FindUserFilterInput!, elements: Int!, page: Int! ) : PublicUserFound!
}
scalar DateTime
@@ -15,7 +21,6 @@ type Account {
user : User!
sessions( limit: Int , offset : Int ) : [Session]!
sessionsCount : Int!
}
type LocationCategory{
@@ -35,7 +40,6 @@ type Location{
address_line2 : String
categories : [LocationCategory]!
categoriesCount : Int!
}
type TruckType{
@@ -51,6 +55,8 @@ type CompanyCategory{
type Company {
id : Int!
owner : User!
staff : [User]!
type : String!
is_hidden : Boolean!
is_active : Boolean!
@@ -60,14 +66,9 @@ type Company {
createdAt : DateTime!
locations( limit: Int , offset : Int ) : [Location]!
locationsCount : Int!
categories : [LocationCategory]!
categoriesCount : Int!
locations : [Location]!
categories : [CompanyCategory]!
truck_types : [TruckType]!
truck_typesCount : Int!
}
type User {
@@ -84,5 +85,62 @@ type User {
is_active : Boolean!
locations( limit: Int , offset : Int ) : [Location]!
locationsCount : Int!
}
type PublicCompany {
id : Int!
owner : PublicUser!
staff : [PublicUser]!
type : String!
name : String!
description : String
createdAt : DateTime!
locations : [Location]!
categories : [CompanyCategory]!
truck_types : [TruckType]!
}
type PublicCompanyFound {
count : Int!
list : [PublicCompany]!
}
input FindCompanyFilterInput {
name : String
type : String
state : String
city : String
truck_type : String
categories : String
}
type PublicUser {
id : Int!
company : Company
phone : String
email : String!
name : String!
last_name : String!
job_role : String!
createdAt : DateTime!
locations( limit: Int , offset : Int ) : [Location]!
}
type PublicUserFound {
count : Int!
list : [PublicUser]!
}
input FindUserFilterInput {
email : String
name : String
last_name : String
employee_id : String
company_name : String
job_role : String
}