From 4af61eae83274f6170071fa8944a5e28baa71e39 Mon Sep 17 00:00:00 2001 From: Kirill Shaplyko Date: Sat, 6 Jul 2024 16:19:29 +0200 Subject: [PATCH 1/3] Add types to options object --- snippets/fetching-data/find-record/own-builder.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/snippets/fetching-data/find-record/own-builder.ts b/snippets/fetching-data/find-record/own-builder.ts index bae77f1..a95c68d 100644 --- a/snippets/fetching-data/find-record/own-builder.ts +++ b/snippets/fetching-data/find-record/own-builder.ts @@ -4,6 +4,7 @@ import { pluralize } from 'ember-inflector'; import type { RequestSignature } from '@warp-drive/core-types/symbols'; import type { TypeFromInstance } from '@warp-drive/core-types/record'; import type { FindRecordOptions } from '@warp-drive/core-types/request'; +import type { UrlOptions } from '@ember-data/request-utils' type MyRequest = { url: string @@ -17,7 +18,7 @@ type MyRequest = { function findRecord(type: TypeFromInstance, id: string, options: FindRecordOptions): MyRequest { const identifier = { type, id }; - const urlOptions = { + const urlOptions: Partial = { op: 'findRecord', identifier, resourcePath: pluralize(identifier.type), From 40a2e26bf417e9ff185f1508b503049d3f7d29ea Mon Sep 17 00:00:00 2001 From: Kirill Shaplyko Date: Sat, 6 Jul 2024 17:31:32 +0200 Subject: [PATCH 2/3] Update snippets/fetching-data/find-record/own-builder.ts Co-authored-by: Ignace Maes --- snippets/fetching-data/find-record/own-builder.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/snippets/fetching-data/find-record/own-builder.ts b/snippets/fetching-data/find-record/own-builder.ts index a95c68d..deb26c5 100644 --- a/snippets/fetching-data/find-record/own-builder.ts +++ b/snippets/fetching-data/find-record/own-builder.ts @@ -4,7 +4,7 @@ import { pluralize } from 'ember-inflector'; import type { RequestSignature } from '@warp-drive/core-types/symbols'; import type { TypeFromInstance } from '@warp-drive/core-types/record'; import type { FindRecordOptions } from '@warp-drive/core-types/request'; -import type { UrlOptions } from '@ember-data/request-utils' +import type { UrlOptions } from '@ember-data/request-utils'; type MyRequest = { url: string From fa9d1ce5ac1315f2e02c9956ce54cb781880f492 Mon Sep 17 00:00:00 2001 From: Kirill Shaplyko Date: Mon, 8 Jul 2024 11:30:53 +0200 Subject: [PATCH 3/3] Update with better type --- snippets/fetching-data/find-record/own-builder.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/snippets/fetching-data/find-record/own-builder.ts b/snippets/fetching-data/find-record/own-builder.ts index deb26c5..529a883 100644 --- a/snippets/fetching-data/find-record/own-builder.ts +++ b/snippets/fetching-data/find-record/own-builder.ts @@ -1,10 +1,10 @@ // Bring your own builder import { buildBaseURL, buildQueryParams } from '@ember-data/request-utils' import { pluralize } from 'ember-inflector'; +import type { FindRecordUrlOptions } from '@ember-data/request-utils'; import type { RequestSignature } from '@warp-drive/core-types/symbols'; import type { TypeFromInstance } from '@warp-drive/core-types/record'; import type { FindRecordOptions } from '@warp-drive/core-types/request'; -import type { UrlOptions } from '@ember-data/request-utils'; type MyRequest = { url: string @@ -18,7 +18,7 @@ type MyRequest = { function findRecord(type: TypeFromInstance, id: string, options: FindRecordOptions): MyRequest { const identifier = { type, id }; - const urlOptions: Partial = { + const urlOptions: Partial = { op: 'findRecord', identifier, resourcePath: pluralize(identifier.type),