Skip to content

Commit

Permalink
NEBULA-701 Add includeCookies field to apollo-server (#6014)
Browse files Browse the repository at this point in the history
Co-authored-by: David Glasser <glasser@davidglasser.net>
  • Loading branch information
SilverMaiden and glasser committed Jan 25, 2022
1 parent 1a703a7 commit c801a81
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 5 deletions.
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;
// 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

0 comments on commit c801a81

Please sign in to comment.