<p>apollo-link 1.2.5/1.2.6으둜 인해 typescript 컴파일 였λ₯˜κ°€ λ°œμƒν•¨</p>

에 λ§Œλ“  2019λ…„ 01μ›” 16일  Β·  39μ½”λ©˜νŠΈ  Β·  좜처: apollographql/apollo-link

이 PRκ³Ό ν•¨κ»˜ μ†Œκ°œλœ λ‚΄μš©:
https://github.com/apollographql/apollo-link/pull/804

ExecutionResult<TData> λŠ” μ΅œμ‹  μœ ν˜• 슀크립트 μ»΄νŒŒμΌλŸ¬μ—μ„œ 였λ₯˜λ₯Ό λ°œμƒμ‹œν‚΅λ‹ˆλ‹€.

λ‚΄ νƒ€μ΄ν”„μŠ€ν¬λ¦½νŠΈ 였λ₯˜:

../node_modules/apollo-link/lib/types.d.ts:22:56 - error TS2315: Type 'ExecutionResult' is not generic.

22 }, C = Record<string, any>, E = Record<string, any>> = ExecutionResult<TData> & {
                                                          ~~~~~~~~~~~~~~~~~~~~~~


Found 1 error.

κ°€μž₯ μœ μš©ν•œ λŒ“κΈ€

15.0.0 -> 14.6.0μ—μ„œ graphql을 λ‹€μš΄κ·Έλ ˆμ΄λ“œν•˜λ©΄ λ¬Έμ œκ°€ ν•΄κ²°λ˜λŠ” κ²ƒμœΌλ‘œ λ‚˜νƒ€λ‚¬μŠ΅λ‹ˆλ‹€.

λͺ¨λ“  39 λŒ“κΈ€

μ’‹μ•„, μ½”λ“œκ°€ μ—¬μ „νžˆ ConfirmedTyped에 μžˆλŠ” 것 κ°™μœΌλ―€λ‘œ #804에 λ„μž…λœ μ½”λ“œλŠ” μ—¬μ „νžˆ μ •ν™•ν•΄μ•Ό ν•©λ‹ˆλ‹€.

https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/graphql/execution/execute.d.ts#L43

/**
 * The result of GraphQL execution.
 *
 *   - `errors` is included when any errors occurred as a non-empty array.
 *   - `data` is the result of a successful execution of the query.
 */
export interface ExecutionResult<TData = ExecutionResultDataDefault> {
    errors?: ReadonlyArray<GraphQLError>;
    data?: TData;
}

@types/graphql이 μ΅œμ‹  μƒνƒœμΈμ§€ 확인해야 ν•©λ‹ˆλ‹€.

@syndesis λŠ” 10κ°œμ›” 된 @types/graphql 0.12.6을 μ‚¬μš©ν•˜κ³  μžˆμŒμ„ λ°œκ²¬ν–ˆμŠ΅λ‹ˆλ‹€. https://www.npmjs.com/package/@types/graphql

μ§€κΈˆ μ΅œμ†Œ 버전 μš”κ΅¬ 사항을 ν™•μΈν•˜λ €κ³  ν•©λ‹ˆλ‹€.

μ΅œμ‹  graphql libκ°€ ν•„μš”ν•œ 경우 μΆ©λΆ„νžˆ κ³΅μ •ν•˜μ§€λ§Œ λ‹€λ₯Έ 라이브러리 μ’…μ†μ„±μœΌλ‘œ 인해 이전 버전에 μžˆμ„ μˆ˜λ„ μžˆμŠ΅λ‹ˆλ‹€.

@gaberudy μš°λ¦¬λŠ” μ§€κΈˆ #contributing in slackμ—μ„œ μ±„νŒ… μ€‘μž…λ‹ˆλ‹€. μ°Έμ—¬ν•˜κ³  μ‹Άλ‹€λ©΄

@gaberudy 당신은 λ˜ν•œ apollo-link-dedup을 μ‚¬μš©ν•˜κ³  μžˆμŠ΅λ‹ˆκΉŒ?

graphql-tools νŒ¨ν‚€μ§€λ₯Ό κ°€μ Έμ˜¬ λ•Œλ„ λ™μΌν•œ λ¬Έμ œκ°€ λ°œμƒν•©λ‹ˆλ‹€. 😒

package.jsonμ—μ„œ λ‹€μŒκ³Ό 같이 resolutions μ„Ήμ…˜μ„ μ‚¬μš©ν•˜μ—¬ 이 문제λ₯Ό ν•΄κ²°ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

"resolutions": {
    "apollo-link-dedup": "^1.0.13",
    "@types/graphql": "^14.0.0"
  }

ν•΄κ²°λ˜μ—ˆμœΌλ―€λ‘œ λ‹«μŠ΅λ‹ˆλ‹€. ν•΄κ²° 방법이 μ œμ•ˆλœ μˆ˜μ • 후에도 μ—¬μ „νžˆ λ¬Έμ œκ°€ μžˆλŠ” μ‚¬λžŒμ΄ 있으면 μ–Έμ œλ“ μ§€ λ‹€μ‹œ μ—΄ 수 μžˆμŠ΅λ‹ˆλ‹€.

package.jsonμ—μ„œ λ‹€μŒκ³Ό 같이 resolutions μ„Ήμ…˜μ„ μ‚¬μš©ν•˜μ—¬ 이 문제λ₯Ό ν•΄κ²°ν•  수 μžˆμŠ΅λ‹ˆλ‹€.

"resolutions": {
    "apollo-link-dedup": "^1.0.13",
    "@types/graphql": "^14.0.0"
  }

λΆˆν–‰νžˆλ„ 이것은 λ‚˜λ₯Ό μœ„ν•΄ 문제λ₯Ό ν•΄κ²°ν•˜μ§€ λͺ»ν–ˆμŠ΅λ‹ˆλ‹€

이 λ¬Έμ œλŠ” μ—¬μ „νžˆ ν•΄κ²°λ˜μ§€ μ•Šμ•˜μŠ΅λ‹ˆλ‹€

이것은 μ΅œμ‹  νŒ¨ν‚€μ§€λ‘œ μ—…κ·Έλ ˆμ΄λ“œν•œ ν›„ λ°œμƒν•©λ‹ˆλ‹€. μš°λ¦¬κ°€ 이것을 λ‹€μ‹œ μ—΄ 수 μžˆμŠ΅λ‹ˆκΉŒ?

μ œμ•ˆλœ ν•΄κ²° 방법이 μž‘λ™ν•˜μ§€ μ•ŠμœΌλ©° 쀑볡 제거λ₯Ό μ‚¬μš©ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.

같은 λ¬Έμ œκ°€ μžˆμŠ΅λ‹ˆλ‹€.

λ‚˜λŠ” 이미 μ‹œλ„ν–ˆλ‹€:

  • ν•΄κ²° μ†”λ£¨μ…˜.
  • apollo 및 graphql μ—…κ·Έλ ˆμ΄λ“œ

λ‹€λ₯Έ μ œμ•ˆμ΄ μžˆμŠ΅λ‹ˆκΉŒ?

이 λ¬Έμ œμ— λŒ€ν•œ μˆ˜μ • 사항이 μžˆμŠ΅λ‹ˆκΉŒ?

@qin-guan 쒅속성을 μ—…κ·Έλ ˆμ΄λ“œν•΄μ•Ό ν•˜μ§€λ§Œ 전이 쒅속성도 μ—…κ·Έλ ˆμ΄λ“œν•΄μ•Ό ν•©λ‹ˆλ‹€. κ°€μž₯ μ‰¬μš΄ 방법은 node_modules와 잠금 νŒŒμΌμ„ μ œκ±°ν•œ λ‹€μŒ λ‹€μ‹œ μ„€μΉ˜ν•˜λŠ” κ²ƒμž…λ‹ˆλ‹€. 잠금 νŒŒμΌμ„ μ œκ±°ν•˜μ§€ μ•ŠμœΌλ©΄ μ‹€μ œλ‘œ 이전 λ²„μ „μ—μ„œ 멈좜 수 μžˆμŠ΅λ‹ˆλ‹€(https://github.com/yarnpkg/yarn/issues/4986 μ°Έμ‘°).

15.0.0 -> 14.6.0μ—μ„œ graphql을 λ‹€μš΄κ·Έλ ˆμ΄λ“œν•˜λ©΄ λ¬Έμ œκ°€ ν•΄κ²°λ˜λŠ” κ²ƒμœΌλ‘œ λ‚˜νƒ€λ‚¬μŠ΅λ‹ˆλ‹€.

@PowerKiKi , @david-wb의 μ†”λ£¨μ…˜μ΄ μ €μ—κ²Œ νš¨κ³Όμ μ΄μ—ˆμŠ΅λ‹ˆλ‹€. λ‚΄ depsλ₯Ό μ—…κ·Έλ ˆμ΄λ“œν•΄λ„ μž‘λ™ν•˜μ§€ μ•Šμ•˜μŠ΅λ‹ˆλ‹€.

이 νŒ¨ν‚€μ§€λŠ” μ΅œμ‹  graphql: ^15.0.0 λ²„μ „μœΌλ‘œ μ€‘λ‹¨λ©λ‹ˆλ‹€. ν›„μžλ₯Ό μˆ˜μ •ν•˜λŠ” 방법에 λŒ€ν•œ 아이디어가 μžˆμŠ΅λ‹ˆκΉŒ?

@johannesschobel λŒ“κΈ€μ„ μž‘μ„±ν•˜κΈ° 전에 μ½μ–΄λ³΄μ‹­μ‹œμ˜€. μ§€κΈˆμ€ λ‹€μš΄κ·Έλ ˆμ΄λ“œν•΄μ•Ό ν•©λ‹ˆλ‹€.

@OmgImAlexis λ‹˜ ,
예, μ•Œμ•„μš”. 그리고 14.6.0 둜 λ‹€μš΄κ·Έλ ˆμ΄λ“œν•˜λŠ” 것과 κ΄€λ ¨λœ "ν˜„μž¬ ν•΄κ²° 방법"을 μ½μ—ˆμŠ΅λ‹ˆλ‹€. κ·ΈλŸ¬λ‚˜ λ‹€λ₯Έ νŒ¨ν‚€μ§€κ°€ 이미 15.0 에 μ˜μ‘΄ν•˜κ³  있기 λ•Œλ¬Έμ— 이것은 ν˜„μž¬ μ €μ—κ²Œ μž₯μ• λ¬Όμž…λ‹ˆλ‹€.

λͺ¨λ‘ 제일 μ’‹λ‹€

이 λ¬Έμ œλŠ” 정말 λ‚˜μ˜λ‹€. μ–΄λ–»κ²Œ 아직도 μ•ˆ κ³ μ³μ‘Œμ–΄??

이것도 방금 λ‹Ήν–ˆμŠ΅λ‹ˆλ‹€...

이 문제λ₯Ό ν•΄κ²°ν•  수 μžˆλŠ” μœ μΌν•œ 방법은 graphql을 14.6.0 둜 λ‹€μš΄κ·Έλ ˆμ΄λ“œν•˜λŠ” κ²ƒμ΄μ—ˆμŠ΅λ‹ˆλ‹€.

ν΄λΌμ΄μ–ΈνŠΈμ— λŒ€ν•œ 자체 node_modules κ°€ μžˆλŠ” ν”„λ‘œμ νŠΈ 루트 내뢀에 ν΄λΌμš°λ“œ κΈ°λŠ₯에 λŒ€ν•œ functions 디렉토리가 있기 λ•Œλ¬Έμ— 이 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€. ν΄λΌμ΄μ–ΈνŠΈλŠ” 14 μ‹œλ¦¬μ¦ˆλ₯Ό μ‚¬μš©ν•˜κ³  μ„œλ²„λŠ” 15 μ‹œλ¦¬μ¦ˆλ₯Ό μ‚¬μš©ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€.

patch-package 둜 문제λ₯Ό ν•΄κ²°ν–ˆμŠ΅λ‹ˆλ‹€.

λ‹€μŒ λ‚΄μš©μ΄ ν¬ν•¨λœ functions/patches/graphql+15.0.0.patch νŒŒμΌμ„ μΆ”κ°€ν•©λ‹ˆλ‹€.

diff --git a/node_modules/graphql/execution/execute.d.ts b/node_modules/graphql/execution/execute.d.ts
index 46a1bc6..4ddbfb5 100644
--- a/node_modules/graphql/execution/execute.d.ts
+++ b/node_modules/graphql/execution/execute.d.ts
@@ -37,15 +37,20 @@ export interface ExecutionContext {
   errors: Array<GraphQLError>;
 }

+export interface ExecutionResultDataDefault {
+  [key: string]: any;
+}
+
 /**
  * The result of GraphQL execution.
  *
  *   - `errors` is included when any errors occurred as a non-empty array.
  *   - `data` is the result of a successful execution of the query.
  */
-export interface ExecutionResult {
+// TS_SPECIFIC: TData and ExecutionResultDataDefault
+export interface ExecutionResult<TData = ExecutionResultDataDefault> {
   errors?: ReadonlyArray<GraphQLError>;
-  data?: { [key: string]: any } | null;
+  data?: TData | null;
 }

 export type ExecutionArgs = {

그런 λ‹€μŒ npx patch-package λ₯Ό postinstall 에 μΆ”κ°€ν•©λ‹ˆλ‹€.

νŒ¨μΉ˜λŠ” ts νƒ€μ΄ν•‘μ—λ§Œ 영ν–₯을 λ―ΈμΉ˜λ―€λ‘œ μ—…μŠ€νŠΈλ¦Όμ—μ„œ 문제λ₯Ό ν•΄κ²°ν•  λ•ŒκΉŒμ§€ μ²˜μŒμ—λŠ” 얼꡴이 λΆ‰μ–΄μ§€λŠ” μ•ˆμ „ν•œ μ†”λ£¨μ…˜μΈ κ²ƒμ²˜λŸΌ λ³΄μž…λ‹ˆλ‹€.

예, λ‹€μ‹œ λŒμ•„κ°€μ•Ό ν–ˆμŠ΅λ‹ˆλ‹€.

"graphql": "^14.6.0"

μ—μ„œ

"graphql": "10.0.0",

이 μž‘μ—…μ„ μˆ˜ν–‰ν•˜λ €λ©΄.

@gaberudy μš°λ¦¬λŠ” 이것에 λŒ€ν•œ μ—…λ°μ΄νŠΈλ₯Ό λ³Ό 수 μžˆμŠ΅λ‹ˆκΉŒ? 이제 μ˜€ν”ˆν•œμ§€ 3κ°œμ›”μ§Έ.

λ˜ν•œ "λ˜λŒλ €μ•Ό ν–ˆμŠ΅λ‹ˆλ‹€"λΌλŠ” λŒ“κΈ€μ΄ 계속 ν‘œμ‹œλ˜μ§€ μ•Šλ„λ‘ μž κΈ€ 수 μžˆμŠ΅λ‹ˆκΉŒ?

λ˜ν•œ 15μ—μ„œ 14.6.0으둜 λ‹€μš΄κ·Έλ ˆμ΄λ“œν•΄μ•Ό ν–ˆμŠ΅λ‹ˆλ‹€.

이것은 https://github.com/apollographql/apollo-link/pull/1263 에 μ˜ν•΄ μˆ˜μ •λ˜μ—ˆμ§€λ§Œ 아직 이에 μ˜μ‘΄ν•˜λŠ” νŒ¨ν‚€μ§€μ— μ™„μ „νžˆ μ „νŒŒλ˜μ§€ μ•Šμ•˜μŠ΅λ‹ˆκΉŒ?

@abernix λ‹˜ , 지적해 μ£Όμ…”μ„œ κ°μ‚¬ν•©λ‹ˆλ‹€. μ›λž˜ λ¬Έμ œκ°€ ν•΄κ²°λ˜κ³  μˆ˜μ •λœ 것 κ°™μŠ΅λ‹ˆλ‹€. κ·ΈλŸ¬λ‚˜ apollo-client 은(λŠ”) 그렇지 μ•Šκ³  이제 λ™μΌν•œ 였λ₯˜λ₯Ό λ˜μ§‘λ‹ˆλ‹€.μ›ƒμŒ:

@OmgImAlexis

μš°λ¦¬λŠ” 이것에 λŒ€ν•œ μ—…λ°μ΄νŠΈλ₯Ό λ³Ό 수 μžˆμŠ΅λ‹ˆκΉŒ? 이제 μ˜€ν”ˆν•œμ§€ 3κ°œμ›”μ§Έ.

2019년을 λ†“μΉœ 것 κ°™μ•„μš” ;-) 벌써 1년이 λ„˜μ—ˆμŠ΅λ‹ˆλ‹€.

μ•„λž˜μ˜ 해상도 및 쒅속성 버전은 λ‚˜λ₯Ό μœ„ν•΄ μˆ˜μ •ν–ˆμŠ΅λ‹ˆλ‹€. κ°€μž₯ μ€‘μš”ν•œ 것은 apollo-link 해상도가 ^1.2.14 μž…λ‹ˆλ‹€. μ΄λ ‡κ²Œ ν•˜λ©΄ apollo-linkλ₯Ό μ‚¬μš©ν•˜λŠ” λͺ¨λ“  νŒ¨ν‚€μ§€κ°€ μ΅œμ‹  버전을 μ‚¬μš©ν•˜λ„λ‘ κ°•μ œν•©λ‹ˆλ‹€(μ’…μ†μ„±μ—μ„œ μ§€μ •ν•˜λŠ” λ‚΄μš©μ— 관계없이). λ‚˜μ—κ²Œ 그것은 "apollo-link": "1.2.3"에 κ³ μ •λœ aws-appsync νŒ¨ν‚€μ§€μ˜€μŠ΅λ‹ˆλ‹€.

  "resolutions": {
    "apollo-link": "^1.2.14"
  },
  "dependencies": {
    "graphql": "^14.6.0",
  }

방금 이 λ¬Έμ œκ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€. λ‹€μš΄κ·Έλ ˆμ΄λ“œλ„ ν•΄μ•Ό ν–ˆλ‹€. μ–΄λ–»κ²Œ 그런 λ¬Έμ œκ°€ μ—¬μ „νžˆ 여기에 μžˆμ„ 수 μžˆμŠ΅λ‹ˆκΉŒ?

μ‹€μ œλ‘œ .. [email protected] 으둜 λ‹€μš΄ κ·Έλ ˆμ΄λ“œν•˜λ©΄ λ‚˜μ—κ²Œλ„ λ¬Έμ œκ°€ ν•΄κ²°λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

[email protected] 의 typescript에 이 일반 μœ ν˜• λ¬Έμ œκ°€ 있음

@david-wb 덕뢄에 14.6.0으둜 λ‹€μš΄κ·Έλ ˆμ΄λ“œν•œ ν›„ 잘 μž‘λ™ν•©λ‹ˆλ‹€.

ERROR in node_modules/apollo-client/core/watchQueryOptions.d.ts:56:32 - error TS2315: Type 'ExecutionResult' is not generic.       

56     refetchQueries?: ((result: ExecutionResult<T>) => RefetchQueryDescription) | RefetchQueryDescription;
                                  ~~~~~~~~~~~~~~~~~~
node_modules/apollo-client/core/LocalState.d.ts:40:23 - error TS2315: Type 'ExecutionResult' is not generic.

40         remoteResult: ExecutionResult<TData>;
                         ~~~~~~~~~~~~~~~~~~~~~~
node_modules/apollo-client/core/LocalState.d.ts:44:17 - error TS2315: Type 'ExecutionResult' is not generic.

44     }): Promise<ExecutionResult<TData>>;
                   ~~~~~~~~~~~~~~~~~~~~~~

"graphql": "^15.0.0" "graphql": "^14.6.0" 둜 λ‹€μš΄κ·Έλ ˆμ΄λ“œν•˜κ³  npm install ν•˜λ©΄ μœ„μ˜ 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.

이것은 https://github.com/apollographql/apollo-client/pull/6258μ—μ„œ ν•΄κ²°λ˜μ—ˆμŠ΅λ‹ˆλ‹€. μ—¬μ „νžˆ 이 λ¬Έμ œκ°€ λ°œμƒν•˜λŠ” 경우 [email protected] 둜 μ—…λ°μ΄νŠΈν•΄ λ³΄μ„Έμš”. 감사 ν•΄μš”!

[email protected] λ₯Ό μ‚¬μš©ν•˜λŠ” 것이 νš¨κ³Όκ°€ μ—†μ—ˆμŠ΅λ‹ˆλ‹€.

@moritzewert μ—¬μ „νžˆ ExecutionResult 였λ₯˜ λ˜λŠ” λ‹€λ₯Έ 것이 ν‘œμ‹œλ©λ‹ˆκΉŒ? μ‹€ν–‰ κ²°κ³Όλ₯Ό κ²Œμ‹œν•  수 μžˆμŠ΅λ‹ˆκΉŒ: npx envinfo<strong i="7">@latest</strong> --preset apollo

μ•ˆλ…•ν•˜μ„Έμš” @hwillson λ‹˜ ,
graphql을 14.6.0 μ—μ„œ 15.0.0 둜 μ—…κ·Έλ ˆμ΄λ“œν•œ ν›„ 이 λ¬Έμ œκ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.
였λ₯˜:

Type 'ExecutionResult' is not generic.
    21 | export declare type FetchResult<TData = {
    22 |     [key: string]: any;
  > 23 | }, C = Record<string, any>, E = Record<string, any>> = ExecutionResult<TData> & {
       |                                                        ^
    24 |     extensions?: E;
    25 |     context?: C;
    26 | };
Version: typescript 3.9.3

λ‚΄ ν™˜κ²½μ€ λ‹€μŒκ³Ό κ°™μŠ΅λ‹ˆλ‹€.

$ npx envinfo<strong i="14">@latest</strong> --preset apollo
npx: installed 1 in 1.063s

  System:
    OS: macOS 10.15.4
  Binaries:
    Node: 10.19.0 - ~/.nvm/versions/node/v10.19.0/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.1 - ~/code/frontend/node_modules/.bin/npm
  Browsers:
    Chrome: 83.0.4103.61
    Edge: 83.0.478.44
    Firefox: 76.0.1
    Safari: 13.1
  npmPackages:
    apollo-boost: ^0.4.7 => 0.4.9
    apollo-cache-inmemory: ^1.6.6 => 1.6.6
    apollo-client: ^2.6.10 => 2.6.10
    apollo-codegen: ^0.20.2 => 0.20.2
    apollo-link: ^1.2.14 => 1.2.14
    apollo-link-context: ^1.0.20 => 1.0.20
    apollo-link-http: ^1.5.17 => 1.5.17
    apollo-link-state: ^0.4.2 => 0.4.2
    apollo-link-ws: ^1.0.20 => 1.0.20

감사 ν•΄μš”!

이 νŽ˜μ΄μ§€κ°€ 도움이 λ˜μ—ˆλ‚˜μš”?
0 / 5 - 0 λ“±κΈ‰