Last active
August 8, 2020 09:53
-
-
Save ShwetaRPawar/ece535553084391cd03d1762fa65aa40 to your computer and use it in GitHub Desktop.
Code for Prisma queries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
************************************* Get All Companies ********************************************** | |
query{ | |
companies{ | |
id | |
name | |
employees{ | |
id | |
name | |
} | |
ldDetails{ | |
id | |
} | |
ptbDetails{ | |
id | |
} | |
} | |
} | |
************************************* Create Company ********************************************** | |
mutation{ | |
createCompany(data: {name: "nonstopio", email: "contact@nonstopio.com", address:"pune"}) | |
{ | |
id | |
name | |
} | |
} | |
************************************* Get COmpany By ID ********************************************** | |
query{ | |
company(where: {id: "ckcael2ab00t90780yzf1h82a"}) | |
{ | |
id | |
name | |
} | |
} | |
************************************* Update Company ********************************************** | |
mutation{ | |
updateCompany(data:{name: "nonstopio pvt ltd", email: "contact@nonstopio.com", address:"pune"}, | |
where: {id: "ckcael2ab00t90780yzf1h82a"}) | |
{ | |
id | |
name | |
} | |
} | |
************************************* Delete Company ********************************************** | |
mutation{ | |
deleteCompany(where: {id: "ckcael2ab00t90780yzf1h82a"}) | |
{ | |
id | |
} | |
} | |
************************************* Create Employee with connect to company ID ********************************************** | |
mutation{ | |
createEmployee(data: | |
{ | |
name: "shweta", | |
emp_id: "12", | |
companyId: "12" | |
company: | |
{ | |
connect: | |
{ | |
id: "ckcafufz3014e0780p1x30rs1" | |
} | |
} | |
} | |
) | |
{ | |
id | |
name | |
emp_id | |
companyId | |
company{ | |
id | |
name | |
} | |
} | |
} | |
************************************* Create Employee with creat new Company ********************************************** | |
mutation{ | |
createEmployee(data: | |
{ | |
name: "shweta", | |
emp_id: "12", | |
company: | |
{ | |
create: | |
{ | |
name: "dream" | |
email: "dream@dream.com" | |
address: "dream city" | |
} | |
} | |
} | |
) | |
{ | |
id | |
name | |
emp_id | |
company{ | |
id | |
name | |
} | |
} | |
} | |
************************************* Pagination of Company ********************************************** | |
query{ | |
companiesConnection(orderBy:id_DESC){ | |
pageInfo{ | |
hasNextPage | |
hasPreviousPage | |
startCursor | |
endCursor | |
} | |
aggregate{ | |
count | |
} | |
__typename | |
edges{ | |
node{ | |
id | |
name | |
} | |
cursor | |
} | |
} | |
} | |
************************************* Upsert of Company ********************************************** | |
mutation{ | |
upsertCompany(where: {id: "ckcn6gj3p002607809eqmveg1"} | |
create: {name: "shweta", email:"shweta@gmail.com", address:"pune"}, | |
update: {name: "shruti", address: "Kharadi"}) | |
{ | |
id | |
name | |
} | |
} | |
************************************* Update Many companies with searching function ********************************************** | |
mutation{ | |
updateManyCompanies(data:{name:"Nonstopio Pvt LTD", address:"Kharadi, Pune"}, | |
where:{name_contains: "nonstopio"}) | |
{ | |
count | |
__typename | |
} | |
} | |
************************************* Delete Many companies with searching function ********************************************** | |
mutation{ | |
deleteManyCompanies(where: {id_in: 1}) | |
{ | |
count | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment