DEV Community

loading...

Discussion on: How YOU can build a Web API using GraphQL .Net Core and Entity Framework

Collapse
tdesaules profile image
Thibault DESAULES

Hi !

Just a question... I'm stuck on a stupid query :
I want to add something like that :

type Book {
id: ID
name: String,
genre: String,
published: Date,
Author: Author,
ref: Book
}

adding data like :
new Book
{
ID = 2,
Name = "IT",
Published = true,
AuthorId = authorDbEntry.Entity.Id,
Genre = "Mystery",
RefID = 1
},

that I should query like:
{
books {
name,
author {
name
},
ref {
name
}
}
}

Collapse
softchris profile image
Chris Noring Author

yea you would need an entry in the Query part supporting books, You would also need a specific resolver class for author and ref as they are complex objects that you mean to resolve from numbers into pure objects. Have a look here aka.ms/graphql-workshop-dotnet. Imagine books is reviews from my example

Collapse
tdesaules profile image
Thibault DESAULES

Thank you look exactly what I need with the "PersonResolver" i still have an id error when it try to resolved :/ need to figured it out