Skip to content

Instantly share code, notes, and snippets.

@ShwetaRPawar
Last active August 8, 2020 09:53
Show Gist options
  • Save ShwetaRPawar/ece535553084391cd03d1762fa65aa40 to your computer and use it in GitHub Desktop.
Save ShwetaRPawar/ece535553084391cd03d1762fa65aa40 to your computer and use it in GitHub Desktop.
Code for Prisma queries
************************************* Get All Companies **********************************************
query{
companies{
id
name
email
employees{
id
name
}
ldDetails{
id
}
ptbDetails{
id
}
}
}
************************************* Create Company **********************************************
mutation{
createCompany(data: {name: "nonstopio", email: "contact@nonstopio.com", address:"pune"})
{
id
name
email
}
}
************************************* Get COmpany By ID **********************************************
query{
company(where: {id: "ckcael2ab00t90780yzf1h82a"})
{
id
name
email
}
}
************************************* Update Company **********************************************
mutation{
updateCompany(data:{name: "nonstopio pvt ltd", email: "contact@nonstopio.com", address:"pune"},
where: {id: "ckcael2ab00t90780yzf1h82a"})
{
id
name
email
}
}
************************************* 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
email
}
}
}
************************************* 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
email
}
}
}
************************************* Pagination of Company **********************************************
query{
companiesConnection(orderBy:id_DESC){
pageInfo{
hasNextPage
hasPreviousPage
startCursor
endCursor
}
aggregate{
count
}
__typename
edges{
node{
id
name
email
}
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
email
}
}
************************************* 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