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

Error in typescript definitions using hapi server #3132

Closed
phenomax opened this issue Aug 7, 2019 · 7 comments
Closed

Error in typescript definitions using hapi server #3132

phenomax opened this issue Aug 7, 2019 · 7 comments

Comments

@phenomax
Copy link

phenomax commented Aug 7, 2019

Error

$ tsc -p .
node_modules/apollo-server-hapi/dist/ApolloServer.d.ts:1:8 - error TS1192: Module '"/builds/cloudnet/api/node_modules/@types/hapi/index"' has no default export.

1 import hapi from 'hapi';
         ~~~~


Found 1 error.

error Command failed with exit code 2.

Reproducible, when using import { ApolloServer } from 'apollo-server-hapi';

Used versions

  • hapi v18.1.9
  • @types/hapi v18.0.2
  • apollo-server-hapi v2.8.1
  • NodeJS v12.7.0
  • tsc v3.5.3
@markgreenwood
Copy link

Also, possibly related... when I compile typescript I get this:

> tsc

node_modules/apollo-server-hapi/dist/ApolloServer.d.ts:1:18 - error TS2307: Cannot find module 'hapi'.

1 import hapi from 'hapi';
                   ~~~~~~


Found 1 error.

because I installed @hapi/hapi, not hapi. From the hapi npm page:
image

@markgreenwood
Copy link

Changing to @hapi/hapi in ApolloServer.d.ts fixes the problem, but obviously that's not a robust solution.

@phenomax
Copy link
Author

phenomax commented Aug 9, 2019

@markgreenwood Thanks for your input. I actually missed the deprecation of the hapi package

@abernix
Copy link
Member

abernix commented Aug 27, 2019

Just as a note to those following along: A partial solution to this update started in #3089 but we reverted it in #3111. This is not just an update to a new package namespace, but also a necessity to update from Hapi 17 to Hapi 18 (AS2 currently uses Hapi 17). Another attempt in #3217 made similar updates, but the semver incompatibility of the update remains the same. 😭

See my comment in #3217 (comment) which hopefully points toward a better future approach here, but right now we can't land this without a major version bump. I certainly don't feel great that this tight version pairing has been and continues to be restrictive. We'll make this better — and we're going to need some time to get Apollo Server 3.x out the door — but for now, this is the (not so Hapi) state of affairs.

@Glazy
Copy link

Glazy commented Oct 4, 2019

So for projects wanting to use apollo-server-hapi today, what is the recommended workaround?

@wadedos
Copy link

wadedos commented Feb 9, 2020

Add your own typings though tsconfig, and declare the hapi module.

declare module 'hapi' {
    export * from '@hapi/hapi';
}

@glasser
Copy link
Member

glasser commented Oct 11, 2022

My suspicion is that we fixed this in Apollo Server 3 when we upgraded Hapi a long way.

That said, Apollo Server 4 replaces a hard-coded set of web framework integrations with a simple stable API for building integrations. As part of this, the core project no longer directly supports a Hapi integration. It should not be that hard for excited Hapi users to build and maintain a Hapi integration, and our guess is they will do a better job of it than the Apollo Server core team, who did not use Hapi at all other than to maintain the integration. There is not a Hapi integration at this time, but some interest has been expressed over at #6028. Sorry for the delay!

@glasser glasser closed this as completed Oct 11, 2022
@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.

6 participants