hypertune
Version:
[Hypertune](https://www.hypertune.com/) is the most flexible platform for feature flags, A/B testing, analytics and app configuration. Built with full end-to-end type-safety, Git-style version control and local, synchronous, in-memory flag evaluation. Opt
27 lines (24 loc) • 687 B
text/typescript
import {
FieldQuery,
FragmentDefinitions,
getInlineFragment,
ObjectValueWithVariables,
} from "../shared";
export default function getFieldQueryForPath(
fragmentDefinitions: FragmentDefinitions<ObjectValueWithVariables>,
query: FieldQuery<ObjectValueWithVariables> | null,
path: string[]
): FieldQuery<ObjectValueWithVariables> | null {
if (!query || path.length === 0) {
return query;
}
if (path.length < 2) {
throw new Error(`Invalid path provided: [${path.join(", ")}]`);
}
return getFieldQueryForPath(
fragmentDefinitions,
getInlineFragment(fragmentDefinitions, query[path[0]]).selection[path[1]]
.fieldQuery,
path.slice(2)
);
}