-
What I have are two sets of queries (DeviceOne and DeviceTwo) that I like to query like this {
DeviceOne
{
SomeData(id:"6bc87306-dfd2-4ecb-8ae8-1a96edf4f62e")
{
SomeInfo1
}
}
DeviceTwo
{
SomethingOtherThanSomeData(id:"75b630a5-3e9c-4e64-a15b-a9b60256a0d1")
{
SomeInfo2
}
}
} Then I was trying to merge these two queries here that talk to their separate repositories public class DeviceOneQuery
{
private readonly IDeviceOneRepository repository;
public DeviceOne(IDeviceOneRepository repository)
{
this.repository = repository;
}
public async Task<List<SomeInfo1>> SomeData(Guid deviceId)
{
return await repository.SomeData(deviceId);
}
} and public class DeviceTwoQuery
{
private readonly IDeviceTwoRepository repository;
public DeviceTwo(IDeviceTwoRepository repository)
{
this.repository = repository;
}
public async Task<List<SomeInfo2>> SomethingOtherThanSomeData(Guid deviceId)
{
return await repository.SomethingOtherThanSomeData(deviceId);
}
} found out that I can´t add more than one _ = services
.AddScoped<IDeviceOneRepository , DeviceOneRepository >()
.AddScoped<IDeviceTwoRepository , DeviceTwoRepository >()
.AddGraphQLServer()
.AddApolloFederation()
.AddQueryType<DeviceOneQuery >()
.AddQueryType<DeviceTwoQuery>() I get And then I tried to extend the queries (but can I do that or does it need to be the types I´m I totally missing the point of here? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
I got help on Slack for getting the queries into one (all methods are now shown) but now I need to figure out how to show them separately under their device types. _ = services
.AddScoped<IDeviceOneRepository , DeviceOneRepository >()
.AddScoped<IDeviceTwoRepository , DeviceTwoRepository >()
.AddGraphQLServer()
.AddApolloFederation()
.AddQueryType(d => d.Name("Query"))
.AddTypeExtension<DeviceOneQuery >()
.AddTypeExtension<DeviceTwoQuery>() and then on both queries I added with end result like this [ExtendObjectType("Query")]
public class DeviceOneQuery
{
private readonly IDeviceOneRepository repository;
public DeviceOne(IDeviceOneRepository repository)
{
this.repository = repository;
}
public async Task<List<SomeInfo1>> SomeData(Guid deviceId)
{
return await repository.SomeData(deviceId);
}
} Now I just need to figure out how to create this {
DeviceOne
{
// methods from query one
}
DeviceTwo
{
// methods from query two
}
} |
Beta Was this translation helpful? Give feedback.
I got help on Slack for getting the queries into one (all methods are now shown) but now I need to figure out how to show them separately under their device types.
and then on both queries I added
[ExtendObjectType("Query")]
with end result like this