-
-
Save annitya/b4dd1237520d6fb50c2b5f58b94bfd0d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ObjectType() | |
export default class GraphTimeseries { | |
@Field() | |
assetId: number; | |
@Field() | |
asset: GraphAsset; | |
@Field(() => [Number]) | |
eventsOwnerIds: number[] = []; | |
} | |
@Resolver(() => GraphTimeseries) | |
export default class GraphTimeseriesResolver implements ResolverInterface<GraphTimeseries> { | |
@Query(() => [GraphTimeseries]) | |
async getTimeseriesByIds(@Arg('ids', () => [Float]) ids: number[], @Ctx() source: Source) { | |
return source.getTimeseriesByIds(ids); | |
} | |
@FieldResolver() | |
async asset(@Root() timeseries: GraphTimeseries, @Ctx() source: Source) { | |
return await source.getAssetById(timeseries.assetId); | |
} | |
@FieldResolver() | |
@DependsOn('asset') | |
async eventsOwnerIds(@Root() timeseries: GraphTimeseries, @Ctx() source: Source, @Info() info) { | |
const { asset } = timeseries; // No longer undefined. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment