-
Notifications
You must be signed in to change notification settings - Fork 0
Home
This use case gets over the flow using the different GraphQL queries implemented. Briefly, we will:
- Create Sample Profiles (used to design the scenarios)
- Create Jobs (using 2 sample client profiles)
- Create Contracts (using the previously created jobs and some of the contractor profiles)
- Make Deposits (to pay for the jobs in the contracts)
- Pay Jobs
- Check Jobs and Contracts
- Get the Best Profession
- Get the Best Clients
Let's start by creating a few users using the GraphQL API:
mutation CreateSampleProfiles {
client1: createProfile(input: {firstName: "John", lastName: "Doe", profession: "Business Manager", type: CLIENT, id: "john", password: "-TestUser1"}) {
id, firstName, lastName, profession, type, balance, amountDue
}
client2: createProfile(input: {firstName: "Joe", lastName: "Doe", profession: "Operations Manager", type: CLIENT, id: "joe", password: "-TestUser1"}) {
id, firstName, lastName, profession, type, balance, amountDue
}
contractor1: createProfile(input: {firstName: "Jane", lastName: "Doe", profession: "Software Engineer", type: CONTRACTOR, id: "jane", password: "-TestUser1"}) {
id, firstName, lastName, profession, type, balance, amountDue
}
contractor2: createProfile(input: {firstName: "Jess", lastName: "Doe", profession: "Tester", type: CONTRACTOR, id: "jess", password: "-TestUser1"}) {
id, firstName, lastName, profession, type, balance, amountDue
}
contractor3: createProfile(input: {firstName: "Jennifer", lastName: "Doe", profession: "Project Manager", type: CONTRACTOR, id: "jennifer", password: "-TestUser1"}) {
id, firstName, lastName, profession, type, balance, amountDue
}
}
You can also get those profiles with a query like this:
query GetProfile {
getProfile(id: "john") {
id, firstName, lastName, profession, type, balance, amountDue, maxDeposit, createdBy, createdAt, lastModifiedBy, lastModifiedAt
}
}
Let's first login as John and create some jobs from him:
mutation CreateSampleJobsForJohn {
job1: createJob(input: {description: "Develop the PoC", price: 8000}) {
id, description, clientId, contractorId, contractId, price, paid, paymentDate, createdBy, createdAt, lastModifiedBy, lastModifiedAt
}
job2: createJob(input: {description: "Add Integration Tests", price: 2000}) {
id, description, clientId, contractorId, contractId, price, paid, paymentDate, createdBy, createdAt, lastModifiedBy, lastModifiedAt
}
}
Later same as Joe:
mutation CreateSampleJobsForJoe {
job3: createJob(input: {description: "Manage the Project", price: 5000}) {
id, description, clientId, contractorId, contractId, price, paid, paymentDate, createdBy, createdAt, lastModifiedBy, lastModifiedAt
}
}
You can also get a list of the unpaid jobs with a query like this one:
query ListUnpaidJobs {
listJobs(filter: {paid: false}) {
items {
id, description, clientId, price, paid, paymentDate, createdBy, createdAt, lastModifiedBy, lastModifiedAt
}
}
}
Now we are ready to create some contracts between the clients and contractors. Let's start with John:
mutation CreateAContract {
createContract(input: {contractorId: "jane", jobIds: ["d5dc8b86-6cef-4ff5-84f6-5e7cb7f1db2d", "1e62cc68-ffa0-4492-b433-2fa8d2903d11"], terms: "None"}) {
id, clientId, contractorId, jobIds, terms, status, createdBy, createdAt, lastModifiedBy, lastModifiedAt
}
}
And later create another for Joe:
mutation CreateAContract {
createContract(input: {contractorId: "jennifer", jobIds: ["f4eb77fe-9864-47dd-b941-d591fb5a4e12"], terms: "None"}) {
id, clientId, contractorId, jobIds, terms, status, createdBy, createdAt, lastModifiedBy, lastModifiedAt
}
}
You can also list or directly get the contracts for either of the users with the following queries:
query ListContracts {
listContracts(filter: { unterminated: true }) {
items {
id, clientId, contractorId, terms, status, jobIds, createdAt, createdBy, lastModifiedAt, lastModifiedBy
}
}
}
query GetAContract {
getContract(id: "20608d63-74b5-430f-92b3-3e695b0079f9") {
id, clientId, contractorId, terms, status, jobIds, createdAt, createdBy, lastModifiedAt, lastModifiedBy
}
}
We will make several deposits on both client profiles to have enough balance to pay for the jobs in the following step. Let's start with John:
mutation MakeADeposit {
makeProfileDeposit(input: {amount: 2500}) {
id, firstName, lastName, profession, type, balance
}
}
Let's go up to 10k so we have enough money to pay all its jobs. Let's do the same for Joe (i.e. execute the query logged as Joe) up to 5k because of the same.
We will now pay for all the jobs in all the contracts of all the clients with queries like the following:
mutation PayJob {
payJob(id: "1e62cc68-ffa0-4492-b433-2fa8d2903d11") {
id, description, clientId, contractorId, price, paid, paymentDate, createdBy, createdAt. lastModifiedBy, lastModifiedAt
}
}
We can now check the status of the contracts with queries like the following:
query GetAContract {
getContract(id: "20608d63-74b5-430f-92b3-3e695b0079f9") {
id, clientId, contractorId, jobIds, status, terms, createdBy, createdAt, lastModifiedAt, lastModifiedBy
}
}
And the jobs with:
query ListPaidJobs {
listJobs(filter: {paid: true}) {
items {
id, description, clientId, price, paid, paymentDate, createdBy, createdAt, lastModifiedBy, lastModifiedAt
}
}
}
Now that all the jobs are paid we can check the best profession with a query like this:
query GetBestProfession {
bestProfession
}
Also we can check the best clients with a query like the following:
query GetBestClients {
bestClients {
items {
id, fullName, paid
}
}
}