Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

apollo-server-types dependency is missing in apollo-datasource-rest #6391

Closed
Grmiade opened this issue May 5, 2022 · 2 comments · Fixed by #6393
Closed

apollo-server-types dependency is missing in apollo-datasource-rest #6391

Grmiade opened this issue May 5, 2022 · 2 comments · Fixed by #6393

Comments

@Grmiade
Copy link

Grmiade commented May 5, 2022

When we try to generate our TS code without skipLibCheck, we have this error: Cannot find module 'apollo-server-types' or its corresponding type declarations
The .d.ts file generated by https://github.com/apollographql/apollo-server/blob/main/packages/apollo-datasource-rest/src/RESTDataSource.ts needs apollo-server-types.
We should declare apollo-server-types as dependency in the apollo-datasource-rest package.

import { Request, RequestInit, Response, BodyInit, Headers, URL, URLSearchParams, URLSearchParamsInit, fetch } from 'apollo-server-env';
import type { ValueOrPromise } from 'apollo-server-types';
import { DataSource, DataSourceConfig } from 'apollo-datasource';
import { HTTPCache } from './HTTPCache';
import { ApolloError } from 'apollo-server-errors';
declare module 'apollo-server-env/dist/fetch' {
    interface RequestInit {
        cacheOptions?: CacheOptions | ((response: Response, request: Request) => CacheOptions | undefined);
    }
}
export declare type RequestOptions = RequestInit & {
    path: string;
    params: URLSearchParams;
    headers: Headers;
    body?: Body;
};
export interface CacheOptions {
    ttl?: number;
}
export declare type Body = BodyInit | object;
export { Request };
export declare abstract class RESTDataSource<TContext = any> extends DataSource {
    private httpFetch?;
    httpCache: HTTPCache;
    context: TContext;
    memoizedResults: Map<string, Promise<any>>;
    constructor(httpFetch?: typeof fetch | undefined);
    initialize(config: DataSourceConfig<TContext>): void;
    baseURL?: string;
    protected cacheKeyFor(request: Request): string;
    protected willSendRequest?(request: RequestOptions): ValueOrPromise<void>;
    protected resolveURL(request: RequestOptions): ValueOrPromise<URL>;
    protected cacheOptionsFor?(response: Response, request: Request): CacheOptions | undefined;
    protected didReceiveResponse<TResult = any>(response: Response, _request: Request): Promise<TResult>;
    protected didEncounterError(error: Error, _request: Request): void;
    protected parseBody(response: Response): Promise<object | string>;
    protected errorFromResponse(response: Response): Promise<ApolloError>;
    protected get<TResult = any>(path: string, params?: URLSearchParamsInit, init?: RequestInit): Promise<TResult>;
    protected post<TResult = any>(path: string, body?: Body, init?: RequestInit): Promise<TResult>;
    protected patch<TResult = any>(path: string, body?: Body, init?: RequestInit): Promise<TResult>;
    protected put<TResult = any>(path: string, body?: Body, init?: RequestInit): Promise<TResult>;
    protected delete<TResult = any>(path: string, params?: URLSearchParamsInit, init?: RequestInit): Promise<TResult>;
    private fetch;
    protected trace<TResult>(request: Request, fn: () => Promise<TResult>): Promise<TResult>;
}
//# sourceMappingURL=RESTDataSource.d.ts.map
@glasser
Copy link
Member

glasser commented May 5, 2022

Good catch.

If you're able to suggest a change we could make to our CI to avoid these issues in the future, I'd appreciate it! (Though a lot of it will get simpler as we reduce the number of packages soon.)

@Grmiade
Copy link
Author

Grmiade commented May 5, 2022

I will check if we can make the CI aware of that 👌

glasser added a commit that referenced this issue May 5, 2022
Some packages were depending on other packages that were only declared
as transitive dependencies. Clean this up by adding appropriate
dependencies (or in one case, just re-declaring ValueOrPromise and
dropping the apollo-server-types dependency).

The peer dep one is a bit funny.  But "Y has a peer dep on Z" means
"when you install Y you need to install Z", and so if X depends on Y,
then when you install X you need to install Z... so sure, that means X
needs to have a peer dep on Z too, I guess.

Fixes #6389.
Fixes #6390.
Fixes #6391.
Fixes #6392.
glasser added a commit that referenced this issue May 5, 2022
Some packages were depending on other packages that were only declared
as transitive dependencies. Clean this up by adding appropriate
dependencies (or in one case, just re-declaring ValueOrPromise and
dropping the apollo-server-types dependency).

The peer dep one is a bit funny.  But "Y has a peer dep on Z" means
"when you install Y you need to install Z", and so if X depends on Y,
then when you install X you need to install Z... so sure, that means X
needs to have a peer dep on Z too, I guess.

Fixes #6389.
Fixes #6390.
Fixes #6391.
Fixes #6392.
glasser added a commit that referenced this issue May 5, 2022
Some packages were depending on other packages that were only declared
as transitive dependencies. Clean this up by adding appropriate
dependencies (or in one case, just re-declaring ValueOrPromise and
dropping the apollo-server-types dependency).

The peer dep one is a bit funny.  But "Y has a peer dep on Z" means
"when you install Y you need to install Z", and so if X depends on Y,
then when you install X you need to install Z... so sure, that means X
needs to have a peer dep on Z too, I guess.

Fixes #6389.
Fixes #6390.
Fixes #6391.
Fixes #6392.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants