diff --git a/packages/@sanity/migrate/src/fetch-utils/__test__/sanityRequestOptions.test.ts b/packages/@sanity/migrate/src/fetch-utils/__test__/sanityRequestOptions.test.ts new file mode 100644 index 00000000000..077a988c8e6 --- /dev/null +++ b/packages/@sanity/migrate/src/fetch-utils/__test__/sanityRequestOptions.test.ts @@ -0,0 +1,24 @@ +import {expect, test} from 'vitest' + +import {endpoints} from '../endpoints' +import {toFetchOptions} from '../sanityRequestOptions' + +test('toFetchOptions', () => { + expect( + toFetchOptions({ + projectId: 'xyz', + apiVersion: 'v2025-01-31', + apiHost: 'api.sanity.io', + endpoint: endpoints.data.query('my-dataset'), + }), + ).toEqual({ + init: { + headers: { + 'Content-Type': 'application/json', + 'User-Agent': '@sanity/migrate@3.72.1', + }, + method: 'GET', + }, + url: 'https://xyz.api.sanity.io//v2025-01-31/query/my-dataset?perspective=raw', + }) +}) diff --git a/packages/@sanity/migrate/src/fetch-utils/endpoints.ts b/packages/@sanity/migrate/src/fetch-utils/endpoints.ts index c5fa7713a5f..345278a1c0b 100644 --- a/packages/@sanity/migrate/src/fetch-utils/endpoints.ts +++ b/packages/@sanity/migrate/src/fetch-utils/endpoints.ts @@ -20,7 +20,7 @@ export const endpoints = { global: false, method: 'GET', path: `/query/${dataset}`, - searchParams: [], + searchParams: [['perspective', 'raw']], }), export: (dataset: string, documentTypes?: string[]): Endpoint => ({ global: false,