Hmm
02/21/2019, 9:32 PMHmm
02/21/2019, 9:33 PMHmm
02/21/2019, 9:34 PMJidé
02/21/2019, 9:36 PMHmm
02/21/2019, 9:38 PMJidé
02/21/2019, 9:39 PMconst db = new Prisma({
typeDefs: "src/generated/prisma.graphql", // the auto-generated GraphQL schema of the Prisma API
endpoint: "<https://url.to.endpoint>", // the endpoint of the Prisma API (value set in `.env`)
debug: true // log all GraphQL queries & mutations sent to the Prisma API
// secret: process.env.PRISMA_SECRET, // only needed if specified in `database/prisma.yml` (value set in `.env`)
});
const params = {
typeDefs: importSchema(path.resolve("./src/schema.graphql")), // Your custom schema
resolvers, // Your resolvers
introspection: true, // automatic in DEV but needed in PROD too
//playground: true, automatic in DEV
context: req => ({
...req,
db
})
};
const server = new ApolloServer(params);
Hmm
02/21/2019, 9:40 PMHmm
02/21/2019, 9:41 PMfunction createClient(initialState) {
return new ApolloClient({
connectToDevTools: process.browser,
ssrMode: !process.browser, // Disables forceFetch on the server (so queries are only run once)
link: new HttpLink({
uri: process.env.NODE_ENV === 'development' ? DEV_ENDPOINT : PROD_ENDPOINT,
Hmm
02/21/2019, 9:41 PMDEV_ENDPOINT
is my localhost, PROD_ENDPOINT
is the heroku linkHmm
02/21/2019, 9:42 PMJidé
02/21/2019, 9:43 PMkshenes
02/21/2019, 9:52 PMHmm
02/21/2019, 9:53 PMJidé
02/21/2019, 10:07 PMJidé
02/21/2019, 10:07 PMJidé
02/21/2019, 10:07 PMJidé
02/21/2019, 10:08 PMHmm
02/21/2019, 10:13 PMHmm
02/21/2019, 10:15 PMKen
02/21/2019, 11:12 PMtheom
02/21/2019, 11:52 PMRicky
02/22/2019, 6:51 AMFran Dios
02/22/2019, 7:10 AMusers { id posts { id } }
and then counting user.posts.length
in the frontend would work, but we cannot sort users by post amount from DB if we have pagination, right?
I think requesting users { id postsConnections { aggregate { count } } }
or similar is not supported by Prisma (in one single request), and if it was probably we cannot order by that in the same request.
Another solution would be adding a totalPosts
counter to the user and increment it every time a user writes a post, but atomic increments are not supported either so there could be issues with this as well. Therefore, what’s the recommended way to do this?Biel Simon
02/22/2019, 10:03 AMjoan
02/22/2019, 10:06 AMThe change you are trying to make would violate the required relation 'EventToParticipant' between Event and Participant
...joan
02/22/2019, 10:06 AMjoan
02/22/2019, 10:07 AMonDelete: CASCADE
to the schema?Biel Simon
02/22/2019, 10:07 AMBiel Simon
02/22/2019, 10:08 AM