How to use the relay-runtime.getVariablesFromObject function in relay-runtime

To help you get started, we’ve selected a few relay-runtime examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ntkme / vue-relay / dist / vue-relay.esm.js View on Github external
_getFragmentVariables: function _getFragmentVariables() {
        return getVariablesFromObject( // NOTE: We pass empty operationVariables because we want to prefer
        // the variables from the fragment owner
        {}, fragments, this.$props, getFragmentOwners(fragments, this.$props));
      },
      _getQueryFetcher: function _getQueryFetcher() {
github ntkme / vue-relay / dist / vue-relay.common.js View on Github external
var props = _objectSpread2({}, restProps, {}, this.state.data);

        var rootVariables;
        var fragmentVariables;
        var fragmentOwners = relayRuntime.getFragmentOwners(fragments, restProps); // NOTE: rootVariables are spread down below in a couple of places,
        // so we compute them here from the fragment owners.
        // For extra safety, we make sure the rootVariables include the
        // variables from all owners in this fragmentSpec, even though they
        // should all point to the same owner

        forEachObject(fragments, function (__, key) {
          var fragmentOwner = fragmentOwners[key];
          var fragmentOwnerVariables = Array.isArray(fragmentOwner) ? fragmentOwner[0] && fragmentOwner[0].variables ? fragmentOwner[0].variables : {} : fragmentOwner && fragmentOwner.variables ? fragmentOwner.variables : {};
          rootVariables = _objectSpread2({}, rootVariables, {}, fragmentOwnerVariables);
        });
        fragmentVariables = relayRuntime.getVariablesFromObject( // NOTE: We pass empty operationVariables because we want to prefer
        // the variables from the fragment owner
        {}, fragments, restProps, fragmentOwners);
        fragmentVariables = _objectSpread2({}, rootVariables, {}, fragmentVariables, {}, this._refetchVariables);
        var fetchVariables = connectionConfig.getVariables(props, {
          count: paginatingVariables.count,
          cursor: paginatingVariables.cursor
        }, fragmentVariables);
        invariant(_typeof(fetchVariables) === 'object' && fetchVariables !== null, 'VueRelayPaginationContainer: Expected `getVariables()` to ' + 'return an object, got `%s` in `%s`.', fetchVariables, componentName);
        fetchVariables = _objectSpread2({}, fetchVariables, {}, this._refetchVariables);
        fragmentVariables = _objectSpread2({}, fetchVariables, {}, fragmentVariables);
        var cacheConfig = options ? {
          force: !!options.force
        } : undefined;
        var request = relayRuntime.getRequest(connectionConfig.query);
        var operation = relayRuntime.createOperationDescriptor(request, fetchVariables);
        var refetchSubscription = null;
github relay-tools / relay-hooks / src / FragmentPagination.ts View on Github external
cursor: string;
            totalCount: number;
        },
        observer: Observer,
        options: RefetchOptions,
    ): Subscription {
        //const { componentRef: _, __relayContext, ...restProps } = this.props;
        const resolver = prevResult.resolver;
        const props = prevResult.data && prevResult.data.frag ? prevResult.data.frag : {};
        const fragments = prevResult.resolver._fragments;
        let rootVariables;
        let fragmentVariables;
        const fragmentOwners = getRootVariablesForFragments(fragments, propsFragment);
        // hack 6.0.0
        if (getVariablesFromObject.length === 2) {
            fragmentVariables = getVariablesFromObject(fragments, propsFragment);
        } else {
            fragmentVariables = getVariablesFromObject(
                // NOTE: We pass empty operationVariables because we want to prefer
                // the variables from the fragment owner
                {},
                fragments,
                propsFragment,
                fragmentOwners,
            );
        }

        fragmentVariables = {
            ...rootVariables,
            ...fragmentVariables,
            ...this._refetchVariables,
        };
github ntkme / vue-relay / src / VueRelayRefetchContainer.js View on Github external
_getFragmentVariables () {
        return getVariablesFromObject(
          // NOTE: We pass empty operationVariables because we want to prefer
          // the variables from the fragment owner
          {},
          fragments,
          this.$props,
          getFragmentOwners(fragments, this.$props)
        )
      },
      _getQueryFetcher () {
github ntkme / vue-relay / src / VueRelayPaginationContainer.js View on Github external
// NOTE: rootVariables are spread down below in a couple of places,
        // so we compute them here from the fragment owners.
        // For extra safety, we make sure the rootVariables include the
        // variables from all owners in this fragmentSpec, even though they
        // should all point to the same owner
        forEachObject(fragments, (__, key) => {
          const fragmentOwner = fragmentOwners[key]
          const fragmentOwnerVariables = Array.isArray(fragmentOwner)
            ? (fragmentOwner[0] && fragmentOwner[0].variables) ? fragmentOwner[0].variables : {}
            : (fragmentOwner && fragmentOwner.variables) ? fragmentOwner.variables : {}
          rootVariables = {
            ...rootVariables,
            ...fragmentOwnerVariables
          }
        })
        fragmentVariables = getVariablesFromObject(
          // NOTE: We pass empty operationVariables because we want to prefer
          // the variables from the fragment owner
          {},
          fragments,
          restProps,
          fragmentOwners
        )
        fragmentVariables = {
          ...rootVariables,
          ...fragmentVariables,
          ...this._refetchVariables
        }
        let fetchVariables = connectionConfig.getVariables(
          props,
          {
            count: paginatingVariables.count,
github facebook / relay / packages / react-relay / ReactRelayPaginationContainer.js View on Github external
// variables from all owners in this fragmentSpec, even though they
      // should all point to the same owner
      Object.keys(fragments).forEach(key => {
        const fragmentNode = fragments[key];
        const fragmentRef = restProps[key];
        const selector = getSelector(fragmentNode, fragmentRef);
        const fragmentOwnerVariables =
          selector != null && selector.kind === 'PluralReaderSelector'
            ? selector.selectors[0]?.owner.variables ?? {}
            : selector?.owner.variables ?? {};
        rootVariables = {
          ...rootVariables,
          ...fragmentOwnerVariables,
        };
      });
      fragmentVariables = getVariablesFromObject(fragments, restProps);
      fragmentVariables = {
        ...rootVariables,
        ...fragmentVariables,
        ...this._refetchVariables,
      };
      let fetchVariables = connectionConfig.getVariables(
        props,
        {
          count: paginatingVariables.count,
          cursor: paginatingVariables.cursor,
        },
        fragmentVariables,
      );
      invariant(
        typeof fetchVariables === 'object' && fetchVariables !== null,
        'ReactRelayPaginationContainer: Expected `getVariables()` to ' +
github facebook / relay / packages / react-relay / ReactRelayRefetchContainer.js View on Github external
_getFragmentVariables(): Variables {
      return getVariablesFromObject(fragments, this.props);
    }