There are {{ data?.ships?.length || 0 }} ships.
``` -------------------------------- ### Accessing Default Apollo Client in asyncData/fetch Source: https://github.com/nuxt-modules/apollo/wiki/3.-Usage Shows how to get the default Apollo client instance within the `asyncData` or `fetch` method of a Nuxt page component. ```javascript export default { asyncData (context) { let client = context.app.apolloProvider.defaultClient } } ``` -------------------------------- ### Configure Apollo Client in Nuxt (v4) Source: https://github.com/nuxt-modules/apollo/wiki/Upgrade-Guide Update your nuxt.config.js to configure the Apollo client endpoints. This configuration replaces previous manual setup for v4. ```javascript // nuxt.config.js apollo:{ clientConfigs:{ default:{ httpEndpoint: YOUR_ENDPOINT, wsEndpoint: YOUR_WS_ENDPOINT } } } ``` -------------------------------- ### Declare TypeScript Types for GraphQL Files Source: https://github.com/nuxt-modules/apollo/blob/v5/docs/content/2.recipes/3.typescript-support.md To resolve the "Cannot find module '*.gql' or its corresponding type declarations" error when importing GraphQL files in TypeScript, create a type declaration file. This example provides declarations for both `.gql` and `.graphql` file extensions. ```typescript declare module '*.gql' { import { DocumentNode } from 'graphql' const Schema: DocumentNode export = Schema } declare module '*.graphql' { import { DocumentNode } from 'graphql' const Schema: DocumentNode export = Schema } ``` -------------------------------- ### Get Auth Token with getToken Source: https://github.com/nuxt-modules/apollo/blob/v5/docs/content/1.getting-started/4.auth-helpers.md Retrieve the auth token for a specific Apollo client. It attempts to automatically get the token from the `apollo:auth` hook. Specify the client name as an argument. ```typescript const { getToken } = useApollo() const token = getToken() const otherToken = getToken('