How to use the @vue/composition-api.onServerPrefetch function in @vue/composition-api

To help you get started, we’ve selected a few @vue/composition-api 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 vuejs / vue-apollo / packages / vue-apollo-composable / src / useQuery.ts View on Github external
const error = ref(null)
  const errorEvent = useEventHook()

  // Loading

  /**
   * Indicates if a network request is pending
   */
  const loading = ref(false)
  trackQuery(loading)
  const networkStatus = ref()

  // SSR
  let firstResolve: Function
  let firstReject: Function
  onServerPrefetch(() => new Promise((resolve, reject) => {
    firstResolve = resolve
    firstReject = reject
  }).then(stop).catch(stop))

  // Apollo Client
  const { resolveClient } = useApolloClient()

  // Query

  const query: Ref> = ref()
  let observer: Subscription
  let started = false

  /**
   * Starts watching the query
   */