onePunchMan
12/28/2018, 8:41 AMTodd
12/28/2018, 10:21 AMPatrikk Sørensen
12/28/2018, 1:00 PMardit
12/28/2018, 5:21 PMchpeters
12/28/2018, 6:44 PMimpowski
12/28/2018, 8:55 PMSubscription
method receiveMessages
which sends me new messages when they are created and a Query
method getMessages
which utilises Connection
with cursor-based pagination.
So, when a user log in into an application, he opens chat and have some messages in cache and then receiving other other messages which he missed. We take the latest available message in cache and pass it to our getMessages
method and get everything after that message. And if we scroll back to top, it will load with the same method 10 previous messages before last message on the screen at the top.
And the problem which I’m trying to figure out is the possibility of loosing any messages on receive when some sort of disconnecting happened on the client side.
If anyone could help me out and describe the proper flow for such application I would be glad to hear it out!🙏Andres Montoya
12/29/2018, 2:06 PMCCBCodeMonkey
12/30/2018, 3:52 AMCCBCodeMonkey
12/30/2018, 3:52 AMCCBCodeMonkey
12/30/2018, 5:19 AMconst resolvers = {
Query: {
async feed(parent, { authorId }, ctx, info) {
// build filter
const authorFilter = authorId ? { author: { id: authorId } } : {}
// retrieve (potentially filtered) posts
const posts = await ctx.db.query.posts({ where: authorFilter }, `{ id }`) // second argument can also be omitted
// retrieve (potentially filtered) element count
const postsConnection = await ctx.db.query.postsConnection(
{ where: authorFilter },
`{ aggregate { count } }`,
)
return {
count: postsConnection.aggregate.count,
postIds: posts.map(post => post.id), // only pass the `postIds` down to the `Feed.posts` resolver
}
},
},
Feed: {
posts({ postIds }, args, ctx, info) {
const postIdsFilter = { id_in: postIds }
return ctx.db.query.posts({ where: postIdsFilter }, info)
},
},
}
CCBCodeMonkey
12/30/2018, 5:20 AMCCBCodeMonkey
12/30/2018, 5:46 AMextend type
in their apollo server schema to extend prisma types? It doesn't seem to work within the schema.graphql
as per this issue: https://github.com/prisma/graphql-import/issues/42
I am doing this hackity hack as workaround:
const importedTypeDefs = importSchema(path.join(__dirname, '/schema.graphql'));
// stupidly type extensions can only go in here right now..
const typeDefs = gql`
${importedTypeDefs}
extend type ExtendedType {
extendedProp: String
}
`;
CCBCodeMonkey
12/30/2018, 5:46 AMserum
12/30/2018, 10:46 AMfilterUser
, that given the name of a friend, say alice, returns all users that are friends with alice.
to achieve this, I need to be able to filter users based on the name of the friends-relation, but afaics the prisma client currently (?) doesn't allow this.
do I need to implement the filter in the resolver myself, or am I missing something here?Nick
12/30/2018, 12:16 PMjevakallio
12/30/2018, 9:05 PMM
12/31/2018, 5:22 AMOq Vinesto Riyadi
12/31/2018, 8:37 AMserum
12/31/2018, 10:06 AMtype Bla {
foos: [Foo!]!
}
type Foo {
bla: Bla!
text: String!
}
type Query {
findBlasWithFooTextContaining(search: String!): [Bla!]!
}
using the playground I now have figured out how to filter Foo
and then query for bla
. to do this in the resolver I need to use a fragment, or the prisma-bindings, afaiu. but then, the result is still a [Foo]
, instead of the intended [Bla]
.
any pointers highly appreciated!sapkra
12/31/2018, 10:53 AMBram
12/31/2018, 3:32 PMBram
12/31/2018, 3:32 PMBram
12/31/2018, 3:33 PMBram
12/31/2018, 3:33 PMBram
12/31/2018, 3:33 PM-e PRISMA_CONFIG= `
port: 4466
databases:
default:
connector: postgres
host: postgres
database: database
user: username
password: password
rawAccess: true
port: 5432
migrations: true`
Bram
12/31/2018, 3:33 PMBram
12/31/2018, 3:36 PMenvironment:
PRISMA_CONFIG: |
port: 4466
databases:
default:
connector: postgres
host: postgres
database: database
user: username
password: password
rawAccess: true
port: 5432
migrations: true
`
Bram
12/31/2018, 3:37 PMBram
12/31/2018, 3:38 PMBram
12/31/2018, 3:38 PM