Ty Holbrook
10/04/2018, 7:38 PMseandeveloper
10/04/2018, 8:52 PMseandeveloper
10/04/2018, 8:52 PMseandeveloper
10/04/2018, 9:01 PMdonedgardo
10/04/2018, 10:07 PM// A `main` function so that we can use async/await
async function main() {
// Read the previously created user from the database and print their posts to the console
const postsByUser = await prisma
.user({ email: "<mailto:bob@prisma.io|bob@prisma.io>" })
.posts()
console.log(`All posts by that user: ${JSON.stringify(postsByUser)}`)
}
What if i wanted to query the posts and something else like books.
How would i do that? would it require two round trip requests
const postsByUser = await prisma
.user({ email: "<mailto:bob@prisma.io|bob@prisma.io>" })
.posts()
const booksByUser = await prisma
.user({ email: "<mailto:bob@prisma.io|bob@prisma.io>" })
.books()
We loose the info way of only one query to get all data...
{
id
posts {
id
}
books {
id
}
}
hinsxd
10/05/2018, 5:18 AMhinsxd
10/05/2018, 5:20 AMhinsxd
10/05/2018, 5:22 AMhinsxd
10/05/2018, 5:22 AMhinsxd
10/05/2018, 5:25 AMprisma-binding
but new "official examples" are using prisma-client
v1.17hinsxd
10/05/2018, 5:26 AMmakarst
10/05/2018, 9:09 AMVinnie
10/05/2018, 9:36 AMVinnie
10/05/2018, 9:36 AMVinnie
10/05/2018, 9:36 AMVinnie
10/05/2018, 9:36 AMSach97
10/05/2018, 12:23 PMval
10/05/2018, 2:40 PMtype User {
id: ID! @unique
numFollowers: Int! @default(value: "0")
}
I then try to run a query like:
return ctx.db.query.users({
orderBy: "numFollowers_DESC",
after: afterId,
first: pageSize
});
But if i run with an afterId
that's not null I don't get valid results. I sometimes get duplicates, sometimes nothingcalvin
10/05/2018, 2:56 PMO
10/05/2018, 6:31 PMFi1osof
10/05/2018, 7:02 PMStef
10/06/2018, 7:50 AMFabio Rizzello
10/06/2018, 3:15 PMGreyson
10/06/2018, 6:03 PMtype User {
id: ID! @unique
...
assets: [UserAsset!]!
}
type Asset {
assetId: String! @unique
assetType: AssetType
}
type UserAsset {
asset: Asset!
name: String!
}
Is this the proper way to go about something like this?Greyson
10/06/2018, 6:03 PMzebapy
10/06/2018, 6:41 PMaroman
10/06/2018, 7:37 PMexport const userQueries = {
async fetchUsers(_, {}, ctx) {
console.log(await ctx.db.users())
return ctx.db.users();
}
};
but on playground it tells me: "message": "Cannot return null for non-nullable field User.firstName.",
However, that console.log
I have there does log out the object. Is there something I'm missing?Nick
10/06/2018, 11:36 PMpull-request
trying to update the code
https://github.com/graphql-boilerplates/angular-fullstack-graphql/pull/140lyteq
10/07/2018, 11:58 AMgraphql-yoga
? It's seems abandoned and not updated for months:
https://github.com/prisma/graphql-yoga/issues/449signor_busi
10/07/2018, 12:23 PM