-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Integrations export their own ApolloServer #1161
Conversation
Note that options to
ApolloServer accepts anything that relates to the schema + engine reporting(the same across all envs), things like:
|
@evans I like this approach. Fewer imports for apollo-server variants. What's the ETA for getting this merged and tagged? |
docs/source/api/apollo-server.md
Outdated
@@ -115,7 +115,7 @@ new ApolloServer({ | |||
|
|||
## registerServer | |||
|
|||
The `registerServer` method is from `apollo-server-express`. Middleware registration has been greatly simplified with this new method. | |||
The `registerServer` method providec by all integrations. Middleware registration has been greatly simplified with this new method. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"provided". also it's a function, not a method.
Also I'm not sure that documenting something as simplifying something with a new method will age well? Maybe just be more explicit about what it does, like "This function is what lets you connect your ApolloServer to your web framework. Use it instead of the listen
method when you want to customize your app's web behavior."
or something
docs/source/api/apollo-server.md
Outdated
|
||
Pass the cors options. | ||
Pass the integration specific cors options. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"integration-specific" with hyphen. Maybe document that this is equivalent to the arguments to the cors or hapi-cors packages, with links?
docs/source/api/apollo-server.md
Outdated
|
||
* `bodyParser`: <`Object`> (express) | ||
|
||
Pass the body parser options. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Link to body-parser?
|
||
export class ApolloServer extends ApolloServerBase { | ||
async createGraphQLServerOptions(req: Request): Promise<GraphQLOptions> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does this function take a request argument rather than an options argument like the one it calls? Also what is the point of this function and why does it have a different name than graphQLServerOptions?
|
||
export class ApolloServer extends ApolloServerBase { | ||
async createGraphQLServerOptions(req: Request): Promise<GraphQLOptions> { | ||
return super.graphQLServerOptions({ req }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't this be request
rather than req
?
const gql = String.raw; | ||
|
||
export class ApolloServer extends ApolloServerBase { | ||
async createGraphQLServerOptions( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i don't get this. is it a typing thing?
@@ -22,4 +22,4 @@ export { | |||
export { graphqlConnect, graphiqlConnect } from './connectApollo'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't a-s-e need to export gql now too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…re like middleware args
This PR creates ApolloServer classes for the hapi, express, and cloudflare integrations. The constructor will continue to stay the same across all environments(ideally there would be a way to programmatically enforce this). The reasons to do this are the ApolloServer class in apollo-server brings the extra dependency on express, which does not work for serverless environments. The presumably more common path is going to be to use apollo-server-{variant}, so that should be equally as understandable/easy as the getting started experience. The arguments the context creation function will be set by the variant and be type safe, see #1110. The new typings should also solve #1140
The downside is that we won't be using the apollo-server package everywhere. I'm unconvinced this will be possible.
This PR stays backwards compatible with the dual import of apollo-server and apollo-server-express(below), however the documentation should be updated to reflect these changes.
The old way:
The new way of importing would be as follows:
apollo-server
apollo-server-express
apollo-server-hapi