-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
GraphQL: How to query data from array of pointers #5894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
It works pretty much like you expect if you have a field that is a |
One option is to introduce this into the Parse GraphQL Config: {
...
classConfigs: [
{
className: "Country",
type: {
pointerArrays: [ { field: "cities", className: "City" }, { field: "states", className: "State" } ]
}
}
]
...
} Longer-term would be to introduce this knowledge directly into the database schema, although I've not assessed the drawbacks yet. |
@omairvaiyani I like this idea. I am only wondering if this information could be also useful for Parse Server overall. So maybe having this information in the parse server schema would be better? |
@davimacedo it certainly would be. I understand that the Parse Server A way around this would be to allow the current type This migration could be sped up using a simple code snippet that runs through an active database (at runtime), and updates the |
We could also leave the |
We could also have a huge problem with multi pointers in an Array (ex: I think the solution is to implement an Tasks:
Example: query JobQuery {
objects {
getJob(objectId: "sqvJTrN9no") {
title
company {
name
}
countries {
... on Country {
name
}
}
}
} Multi Pointer example: query JobQuery {
objects {
getJob(objectId: "sqvJTrN9no") {
title
company {
name
}
relatedTo {
... on Country {
name
objectId
}
... on ProfessionalCode {
readableName
code
objectId
}
}
}
} |
@Moumouls thanks for the suggestion. I think it is really the best way to solve this issue! I will take a look in your PR and revert my feedback. |
@murshudov on the Query{
objects {
getCountry(objectId: "8dDDVCHN2q") {
objectId
name
companies {
... on CompanyClass {
objectId
name
employees {
... on EmployeeClass {
objectId
name
}
}
teams {
... on TeamClass {
objectId
name
employees {
... on EmployeeClass {
objectId
name
country {
objectId
name
}
}
}
}
}
}
}
}
}
} Response{
"data": {
"objects": {
"getCountry": {
"objectId": "8dDDVCHN2q",
"name": "imACountry",
"companies": [
{
"objectId": "jk2pZjsDsv",
"name": "imACompany",
"employees": [
{
"objectId": "7KBQ8bOpZA",
"name": "imAnEmployee"
}
],
"teams": [
{
"objectId": "dRiSUajdpq",
"name": "imATeam",
"employees": [
{
"objectId": "7KBQ8bOpZA",
"name": "imAnEmployee",
"country": {
"objectId": "8dDDVCHN2q",
"name": "imACountry"
}
}
]
}
]
}
]
}
}
}
} Don't be afraid of performance when diving into objects, this example was executed in |
@Moumouls and others, thank you very much for the great effort and awesome work 👍 |
This is my query
and it returns
But I want to get country details inside this query results. Is there a way to do that?
I thought maybe something like this exists:
Result:
I don't know how to include results from getJob query into findCountry query. Any help would be appreciated 😊
The text was updated successfully, but these errors were encountered: