UNPKG

@graphql-tools/executor

Version:

Fork of GraphQL.js' execute function

23 lines (22 loc) 616 B
import { isPromise } from '@graphql-tools/utils'; /** * A BoxedPromiseOrValue is a container for a value or promise where the value * will be updated when the promise resolves. * * A BoxedPromiseOrValue may only be used with promises whose possible * rejection has already been handled, otherwise this will lead to unhandled * promise rejections. * * @internal * */ export class BoxedPromiseOrValue { value; constructor(value) { this.value = value; if (isPromise(value)) { value.then(resolved => { this.value = resolved; }); } } }