-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
plugins: Use dynamic import instead of manual intermediate functions
We want to avoid loading usage reporting protobuf until as late as possible. Previously we had a specific file src/plugins/index.ts full of little wrapper functions that call `require`. Now we use dynamic `import` (which is compiled to CJS as `require` by tsc) instead. We use "exports" in package.json to let you do deep imports from particular files (only). Note that this still only supports CJS!
- Loading branch information
Showing
17 changed files
with
139 additions
and
220 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 2 additions & 4 deletions
6
packages/server/src/__tests__/plugin/cacheControl/cacheControlPlugin.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 2 additions & 3 deletions
5
packages/server/src/__tests__/plugin/cacheControl/collectCacheControlHints.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 3 additions & 5 deletions
8
packages/server/src/__tests__/plugin/schemaReporting/index.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
packages/server/src/__tests__/standalone/standaloneSpecific.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// TODO(AS4): Document this file | ||
// TODO(AS4): Decide where it is imported from. | ||
import type { BaseContext, ApolloServerPlugin } from '..'; | ||
import type { | ||
InternalApolloServerPlugin, | ||
InternalPluginId, | ||
} from '../internalPlugin'; | ||
|
||
function disabledPlugin<TContext extends BaseContext>( | ||
id: InternalPluginId, | ||
): ApolloServerPlugin<TContext> { | ||
const plugin: InternalApolloServerPlugin<TContext> = { | ||
__internal_plugin_id__() { | ||
return id; | ||
}, | ||
}; | ||
return plugin; | ||
} | ||
|
||
export function ApolloServerPluginCacheControlDisabled< | ||
TContext extends BaseContext, | ||
>(): ApolloServerPlugin<TContext> { | ||
return disabledPlugin('CacheControl'); | ||
} | ||
|
||
export function ApolloServerPluginInlineTraceDisabled< | ||
TContext extends BaseContext, | ||
>(): ApolloServerPlugin<TContext> { | ||
return disabledPlugin('InlineTrace'); | ||
} | ||
|
||
export function ApolloServerPluginLandingPageDisabled< | ||
TContext extends BaseContext, | ||
>(): ApolloServerPlugin<TContext> { | ||
return disabledPlugin('LandingPageDisabled'); | ||
} | ||
|
||
export function ApolloServerPluginUsageReportingDisabled< | ||
TContext extends BaseContext, | ||
>(): ApolloServerPlugin<TContext> { | ||
return disabledPlugin('UsageReporting'); | ||
} |
Oops, something went wrong.