Comments (17)
I needed this as well to show posts related to tags, so i created this (rather ugly but working) temporary solution in angular 2.
https://gist.github.com/emolr/f2eaf46612ca7bbb47b6a814180da719
It does the job for now, but it is pretty slow compared to a single request, but it works, so I'll spend the extra time on a good loading animation. It might help someone needing the same functionality until it's implemented
My temporary approach have some limitations though.
When i began implementing search i found that i can't both have my search filter: {id_in: ['1', '2']}
while using my tag posts lookup ids as they work on the same filter argument.
So dream scenario would be something like filter: {AND: [id_in: ['1','2'], tagId_in: ['73', '23']]}
I would then expect it to return only the posts which has related tags with id 73
& 23
and id 1
og 2
, and if both post 1
and 2
has tags 73
and 23
the query would return both posts
from prisma1.
Very good point. This is already WIP. 🎉
from prisma1.
I'd really like this too - and is core to the kind of structure I'm wishing to manage within GraphQL. Here's some details my use-case…
I am representing a deep tree structure, with each node called say "Item
" that has a collection of child Item
's and a single parent Item
.
I'd like to be able query for:
- any
item
with a parent ID ofx
. - any
item
with a parent ID ofundefined
. - return the item with the
children
items including a specified depth of grand-children into the tree.
Thanks!
from prisma1.
Ahh that was nasty, those two missing braces 😄 thanks @marktani!
from prisma1.
Meanwhile @philcockfield you might be able to filter client-side: https://github.com/RelateNow/relate/blob/9dc89b460410b878bc2574af6043f79f86a1f5b3/containers/Users.js#L16
from prisma1.
{
allUsers(filter: {
OR: [{
retreats_some: {
id_not: "dummy"
}
}, {
tracks_some: {
id_not: "dummy"
}
}]
}) {
givenName
}
}
You need to pass the different conditions as elements of the list argument OR
.
from prisma1.
Hey guys - any clue as to whether this is something that might be implemented in the near-ish future? I need to make a decision somewhat soon as to whether to use Graph.cool, and this is a blocker for me.
Thanks!
from prisma1.
Hey @philcockfield! We're already working on this feature. We're expecting to release this in January. Hope that works for you?
from prisma1.
That's awesome @schickling. I really want to stick with graphcool.
What is the query parameters going to look like. Can you post your current API design/intentions? Even if they my change 😃
from prisma1.
@sedubois - thanks for that stop-gap for filtering on the client. To be clear, that's pulling the entire data-set, then just running filters client side right?
That will certainly let me proceed with GraphCool for everything else, then refactor this when this feature is complete (in Jan)
from prisma1.
@philcockfield yes, should work while you don't have too much data.
from prisma1.
We are starting the implementation of this feature this week.
Feedback is highly appreciated at https://gist.github.com/sorenbs/dec072b8b4df0ab6cbd441861a53eaf9
from prisma1.
This is now possible using both the Simple and the Relay API. 🎉
You can read more about this feature here: https://www.graph.cool/docs/reference/simple-api/filtering-by-field-xookaexai0#relation-filters
from prisma1.
Thanks @schickling for that documentation!
Let's say I have a User model and a Track model, with a one-to-many tracks
relationship. How would I query all users which have at least one track?
from prisma1.
This works but is a bit smelly:
{
allUsers(filter: {
tracks_some: {
id_not: "dummy"
}
}) {
givenName
}
}
from prisma1.
Something like that is the way to go. A different solution:
{
allUsers(filter: {
tracks_some: {
# query all that have been created in the past (2017-02-06-16:13:39 is now)
createdAt_lt: "2017-02-06-16:13:39"
}
}) {
givenName
}
}
from prisma1.
OK. Now I actually have a second relation retreats
with model Retreat. How do I select all users who have at least one track or at least one retreat? This gives an empty list:
{
allUsers(filter: {
OR: [{
retreats_some: {
id_not: "dummy"
}
tracks_some: {
id_not: "dummy"
}
}]
}) {
givenName
}
}
from prisma1.
Related Issues (20)
- Self-relation column order? HOT 1
- Prisma1 with Apple M1 HOT 7
- Mutations with disconnect=true on an relation that is not connected to anything fails with an error HOT 1
- Circular dependency while mocking the Prisma client using both approach singelton and context
- host.docker.internal not working on prismagraphql/prisma:1.34 on docker-compose (1.29.2) docker 20.10.9 CentOS 8.4.2105 HOT 1
- Intermittent P1001 - "Can't reach database server..." HOT 1
- `updatedAt` field not changing after running a connect operation via the update mutation HOT 1
- Prisma 1.34 documentation errors HOT 1
- Invalid Issue Documentation link HOT 1
- log4j - CVE-2021-4428 HOT 2
- The type of `where` part of `delete` function is wrong when using `@@unique`
- Prisma 1 Cloud was sunset on September 1st, 2022 HOT 3
- Error prisma1 deploy HOT 1
- Cascade delete not set on one-to-many relation HOT 1
- prisma1 introspect does not return anything
- updatedFields always returns an empty array HOT 1
- Prisma1 deploy throws 504 Gateway Time-out randomly HOT 2
- "Join" where result would have been a big data set throws an error (performance) HOT 1
- Issues adding or modifying records in Admin
- Prisma 1 was deprecated on Sept, 1st 2022 — Upgrade to the latest version of Prisma
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from prisma1.