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
23 lines (21 loc) • 652 B
text/typescript
import {
Fragment,
InlineFragment,
ObjectValueWithVariables,
ObjectExpression,
FragmentDefinitions,
} from "../types";
import nullThrows from "./nullThrows";
export default function getInlineFragment<
TFieldArguments extends ObjectValueWithVariables | ObjectExpression,
>(
fragmentDefinitions: FragmentDefinitions<TFieldArguments>,
fragment: Fragment<TFieldArguments>
): InlineFragment<TFieldArguments> {
return fragment.type === "InlineFragment"
? fragment
: nullThrows(
fragmentDefinitions[fragment.fragmentName],
`Missing fragment definition for fragment with name: "${fragment.fragmentName}".`
);
}