How to create Field with OneToMany
See original GitHub issueI try
@OneToMany(type => Family, family => family.childhood)
@Field({type: () => Family})
family: Family[];
Error: @ObjectType Family.childhood: Validation of type failed. Resolved type for @Field must be GraphQLOutputType.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:9
Top Results From Across the Web
Hibernate One to Many Annotation Tutorial - Baeldung
This quick Hibernate tutorial will take us through an example of a one-to-many mapping using JPA annotations, an alternative to XML.
Read more >The best way to map a @OneToMany relationship with JPA ...
There are many ways to map the @OneToMany association. We can use a List or a Set. We can also define the @JoinColumn...
Read more >OneToMany not creating a column in table - Stack Overflow
I have no idea how this can happen. Maybe you need to add mapped_by in your OneToMany Annotation: @OneToMany(mappedBy = "season", fetch = ......
Read more >Best Practices for Many-To-One and One ... - Thorben Janssen
Best Practices for Many-To-One and One-To-Many Association Mappings · 1 Don't use unidirectional one-to-many associations · 2 Avoid the mapping of huge to-many ......
Read more >Many-to-one / one-to-many relations - typeorm - GitBook
Many-to-one / one-to-many is a relation where A contains multiple instances of B, but B contains only one instance of A. Let's take...
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 Free
Top 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
Seems you have circular relationship (Childhood > Family > Childhood > Family) etc. In such case, you have to define type as function. (http://siawyoung.com/coding/javascript/circular-references-graphql-type-definitions.html)
Try to modify:
to
Also change
to
And let me know if that helps.
Note that if you use array types (eg.
Family[]
) you’d have to set type manually anyway as typescript is not able to guess type of array item.@korolariya you don’t need to define function that returns your
Childhood
s. Typeorm is handling it by itself.So basically you could simply
If you’d need to add some custom logic you could do this like:
But it might not be needed propably in your case. In case you’d like to learn more about relational queries: http://typeorm.io/#/relational-query-builder