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

NEBULA-701 Add includeCookies field to apollo-server #6014

Merged
merged 6 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The version headers in this history reflect the versions of Apollo Server itself
## vNEXT

- `apollo-server-core`: The inline trace plugin will now include the full query plan and subgraph traces if manually installed in an Apollo Gateway. (Previously, you technically could install this plugin in a Gateway but it would not have any real trace data.) This is recommended for development use only and not in production servers. [PR #6017](https://github.com/apollographql/apollo-server/pull/6017)
- `apollo-server-core`: The default landing page plugins now take an `includeCookies` option which allows you to specify that Explorer should send cookies to your server. [PR #6014](https://github.com/apollographql/apollo-server/pull/6014)

## v3.6.2

Expand Down
15 changes: 15 additions & 0 deletions docs/source/api/plugin/landing-pages.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,21 @@ If provided, these variables should apply to the initial query you provide in `d

An object containing initial HTTP header values to populate in the Explorer on load.

</td>
</tr>
<tr>
<td>

###### `includeCookies`

`boolean`
</td>
<td>

A boolean used to set whether Studio Explorer should include cookies in its GraphQL requests to your server.

If you omit this, the Explorer defaults `includeCookies` to `false` or the current user setting.

</td>
</tr>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,25 @@ export interface ApolloServerPluginLandingPageDefaultBaseOptions {
*/
footer?: boolean;
/**
* Folks can configure their landing page to link to Studio Explorer with a
* document, variables and headers loaded in the UI.
* Users can configure their landing page to link to Studio Explorer with a
* document loaded in the UI.
*/
document?: string;
/**
* Users can configure their landing page to link to Studio Explorer with
* variables loaded in the UI.
*/
variables?: Record<string, string>;
/**
* Users can configure their landing page to link to Studio Explorer with
* headers loaded in the UI.
*/
headers?: Record<string, string>;
/**
* Users can configure their landing page to link to Studio Explorer with the
* setting to include/exclude cookies loaded in the UI.
*/
includeCookies?: boolean;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the doc comment above document to mention this (or better, split it up so each of the four options here have a doc comment since that's how doc comments work).

Ideally you should also add this to LandingPageConfig as well as to the two lines that look like

  const { version, __internal_apolloStudioEnv__, footer, ...rest } = options;

as explained in the comment above them. Those lines should probably also have document, variables, and headers added, oops... I guess we're kind of in the "haven't quite updated the plugin yet" state for them. The model here is a bit odd but basically works.

Please also update the doc website in docs/source/api/plugin/landing-pages.md. There's a README in docs explaining how to run the docs site locally; you can also see a Netlify deployment preview on the PR checks section.

// For Apollo use only.
__internal_apolloStudioEnv__?: 'staging' | 'prod';
}
Expand All @@ -47,6 +60,7 @@ interface LandingPageConfig {
document?: string;
variables?: Record<string, string>;
headers?: Record<string, string>;
includeCookies?: boolean;
footer?: boolean;
}

Expand All @@ -56,13 +70,26 @@ export function ApolloServerPluginLandingPageLocalDefault(
// We list known keys explicitly to get better typechecking, but we pass
// through extras in case we've added new keys to the splash page and haven't
// quite updated the plugin yet.
const { version, __internal_apolloStudioEnv__, footer, ...rest } = options;
const {
version,
__internal_apolloStudioEnv__,
footer,
document,
variables,
headers,
includeCookies,
...rest
} = options;
return ApolloServerPluginLandingPageDefault(
version,
encodeConfig({
isProd: false,
apolloStudioEnv: __internal_apolloStudioEnv__,
footer,
document,
variables,
headers,
includeCookies,
...rest,
}),
);
Expand All @@ -74,14 +101,27 @@ export function ApolloServerPluginLandingPageProductionDefault(
// We list known keys explicitly to get better typechecking, but we pass
// through extras in case we've added new keys to the splash page and haven't
// quite updated the plugin yet.
const { version, __internal_apolloStudioEnv__, footer, graphRef, ...rest } =
options;
const {
version,
__internal_apolloStudioEnv__,
footer,
document,
variables,
headers,
includeCookies,
graphRef,
...rest
} = options;
return ApolloServerPluginLandingPageDefault(
version,
encodeConfig({
isProd: true,
apolloStudioEnv: __internal_apolloStudioEnv__,
footer,
document,
variables,
headers,
includeCookies,
graphRef,
...rest,
}),
Expand Down