When generating the output.ts file with the sdkClass enabled I am unable to build the angular application.
Note: everything works when using ng serve.
The generated skd class:
@Injectable({ providedIn: 'root' })
export class MyServiceGQLService {
constructor(private MyQueryGql: MyQueryGQL) {}
myQuery(
variables?: MyQueryQueryVariables,
options?: QueryOptionsAlone<MyQueryQueryVariables>
) {
return this.myQueryGql.fetch(variables, options);
}
myQueryWatch(
variables?: MyQueryQueryVariables,
options?: WatchQueryOptionsAlone<MyQueryQueryVariables>
) {
return this.myQueryGql.watch(variables, options);
}
}
I get the following error: Module not found: Error: Can't resolve 'apollo-angular/types' in output.ts
When changing the WatchQueryOptionsAlone and QueryOptionsAlone to any. I am able to build the application.
apollo-angular/types import:
import {
MutationOptionsAlone // unused import,
QueryOptionsAlone,
SubscriptionOptionsAlone // unused import,
WatchQueryOptionsAlone
} from 'apollo-angular/types';
Package versions:
"@graphql-codegen/cli": "^1.12.1",
"@graphql-codegen/introspection": "^1.12.1",
"@graphql-codegen/typescript-apollo-angular": "^1.12.1",
"@graphql-codegen/typescript-operations": "^1.12.1",
"@graphql-codegen/typescript": "^1.12.1",
"apollo-angular": "^1.8.0",
"apollo-angular-link-http": "^1.9.0",
"apollo-cache-inmemory": "^1.6.5",
"apollo-client": "^2.6.8",
"apollo-link": "^1.2.13"
"graphql": "^14.6.0",
"graphql-tag": "^2.10.1"
codegen.yml:
overwrite: true
schema: "http://localhost:4021/graphql"
documents: "/**/*.graphql"
hooks:
afterAllFileWrite:
- prettier --write
generates:
./graphql/generated/output.ts:
plugins:
- "typescript"
- "typescript-operations"
- "typescript-apollo-angular"
config:
declarationKind: 'interface'
sdkClass: true
serviceName: 'MyQueryGQLService'
./graphql/generated/graphql.schema.json:
plugins:
- "introspection"
.graphl file:
query myQuery{
myQuery {
id
name
published
}
}
Fix #3446
Can confirm this works with the above fix #3446 (npm version: 1.12.2-alpha-667a0d68.20)
Fixed in 1.12.2! Thanks @kamilkisiela