GraphQL addReference on Object Array
See original GitHub issueSummary
A way to have addReference traverse down into non root Types. collection.addReference(fieldName, typeName) and the source-filesystem options only apply to a root Type.
Basic example
My Input File:
field1: 'data'
field2: ['data1', 'data2']
field3:
- sub_field1: 'data'
sub_field2: ['data1', 'data2']
This already works:
refs: {
field1: 'typeName',
field2: 'typeName'
}
This would be nice:
refs: {
field3: {
sub_field1: 'typeName'
sub_field2: 'typeName'
}
Motivation
References are already very powerful, but they are limited by only applying at the Root level.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (5 by maintainers)
Top Results From Across the Web
How to push an object into an array with GraphQL?
I would like to change the way my resolver is creating the payment cards in my DB. So now I create the wallet...
Read more >Apollo Federation Transform – GraphQL Mesh
GraphQL Mesh Documentation. ... Add Reference Resolver as a Code File ... extends (type: Boolean ); fields (type: Array of Object , required):....
Read more >Develop a GraphQL-Powered API With Symfony - Twilio
In this article, you will learn how to develop a GraphQL-powered API for an online book store with Symfony.
Read more >Data Store API - Gridsome
#Data Store API. The Data Store API lets you insert your own data into the GraphQL data layer. You will then be able...
Read more >GraphQL List - How to use arrays in GraphQL schema ...
It is often common practice in REST APIs to return a JSON response with an array of objects. In GraphQL we would like...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was experiencing the same problem @davidleininger was, and I solved it by declaring my own schema. Example:
It was not working before specifying
@reference(by: "id")
.Just to be explicit, your
Comment
type needs to have a fieldarticle
with a value that matches, in this case, theid
field on the typeArticle
.From
Comment
I am now able to find the matchingArticle
just using the fieldarticle
. Instead, to find comments from an article, I used:A bit convoluted but I could not find another way.
@hjvedvik I’m having an issue where the references aren’t getting made. I’ve added the following code to link one collection to another. I haven’t had an issue doing this in the past, but at the moment, GraphQL is just returning
null
for every reference.Looking at the schema and the docs, in the playground, everything seems to be wired up correctly, but for whatever reason, everything comes back
null
.In this case, it will return: