You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using HotChocolate(v12) with EF Core Azure Cosmos DB Provider (Microsoft.EntityFrameworkCore.Cosmos 6.0.8).
I am trying to use Projection and Filtering, but I see below problem with query formation,
Lets take below model as example
public class Student
{
public string id { get; set; }
public Name name { get; set; }
public List<Subject> subjects { get; set; }
}
public class Name
{
public string fName { get; set; }
public string lName { get; set; }
}
public class Subject
{
public string subjectId { get; set; }
public string name { get; set; }
}
and I have query class as below
public class Query
{
[GraphQLName("getStudent")]
[UseProjection]
[UseFiltering]
public IQueryable<Student> GetStudent([Service] StudentDbContext dbContext)
{
return dbContext.StudentData.AsNoTracking();
}
}
Refer below query formation in different scenarios
query {
getStudent(where:{
or:[{ id: { eq: "1" } }, { id: { eq: "2" } }]
}){
id
}
}
In this case, it is forming the right query, so no issues here.
info: Microsoft.EntityFrameworkCore.Database.Command
Container='Student', Partition='?', Parameters=[@__p_0=?, @__p_1=?]
SELECT VALUE {"Id" : c["id"]}
FROM root c
WHERE ((c["id"] = @__p_0) OR (c["id"] = @__p_1))
query {
getStudent(where:{
or:[{ id: { eq: "1" } }, { id: { eq: "2" } }]
}){
id
name {
fName
}
}
}
but for this query, somehow it is selecting all fields.
info: Microsoft.EntityFrameworkCore.Database.Command
Container='Student', Partition='?', Parameters=[@__p_0=?, @__p_1=?]
SELECT c["id"], c, c["name"]["fname"]
FROM root c
WHERE ((c["id"] = @__p_0) OR (c["id"] = @__p_1))
query {
getStudent(where:{
or:[{ id: { eq: "1" } }, { id: { eq: "2" } }]
}){
id
name {
fName
}
subjects {
name
}
}
}
In above query scenario, i don't see 'subjects' array is being considered in the query and also it is selecting all properties.
info: Microsoft.EntityFrameworkCore.Database.Command
Container='Student', Partition='?', Parameters=[@__p_0=?, @__p_1=?]
SELECT c["id"], c, c["name"]["fname"]
FROM root c
WHERE ((c["id"] = @__p_0) OR (c["id"] = @__p_1))
Is this the expected behavior?
or am I missing anything here?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
I am using HotChocolate(v12) with EF Core Azure Cosmos DB Provider (Microsoft.EntityFrameworkCore.Cosmos 6.0.8).
I am trying to use Projection and Filtering, but I see below problem with query formation,
Lets take below model as example
and I have query class as below
Refer below query formation in different scenarios
Is this the expected behavior?
or am I missing anything here?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions