New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

apollo-deprecated-highlight

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apollo-deprecated-highlight - npm Package Compare versions

Comparing version 1.1.6 to 1.1.7

2

lib/index.d.ts

@@ -1,2 +0,2 @@

export declare const apolloDeprecatedHighlight: () => {
export declare const ApolloDeprecatedHighlight: () => {
requestDidStart: (initialRequestContext: any) => Promise<{

@@ -3,0 +3,0 @@ executionDidStart(executionRequestContext: any): Promise<{

@@ -39,6 +39,6 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.apolloDeprecatedHighlight = void 0;
exports.ApolloDeprecatedHighlight = void 0;
var graphql_1 = require("graphql");
var utils_1 = require("./utils");
var apolloDeprecatedHighlight = function () {
var ApolloDeprecatedHighlight = function () {
return {

@@ -78,12 +78,10 @@ requestDidStart: function (initialRequestContext) { return __awaiter(void 0, void 0, void 0, function () {

return __awaiter(this, void 0, void 0, function () {
var extensions;
return __generator(this, function (_a) {
if (newDeprecations.length > 0) {
if (!requestContext.response.extensions) {
requestContext.response.extensions = {};
extensions = (0, utils_1.getExtensions)(requestContext);
if (!extensions.deprecations) {
extensions.deprecations = [];
}
if (!requestContext.response.extensions.deprecations) {
requestContext.response.extensions.deprecations = [];
}
requestContext.response.extensions.deprecations =
requestContext.response.extensions.deprecations.concat(newDeprecations);
extensions.deprecations = extensions.deprecations.concat(newDeprecations);
}

@@ -99,2 +97,2 @@ return [2 /*return*/];

};
exports.apolloDeprecatedHighlight = apolloDeprecatedHighlight;
exports.ApolloDeprecatedHighlight = ApolloDeprecatedHighlight;
export declare function getFieldDef(info: any): any;
export declare function getSchemaDirective(info: any, directiveName: string): any;
/**
* Get apollo 3 and apollo 4 response extensions
* @param requestContext
* @returns
*/
export declare function getExtensions(requestContext: any): any;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getSchemaDirective = exports.getFieldDef = void 0;
exports.getExtensions = exports.getSchemaDirective = exports.getFieldDef = void 0;
function getFieldDef(info) {

@@ -13,1 +13,31 @@ var parentTypeFields = info.parentType.getFields();

exports.getSchemaDirective = getSchemaDirective;
/**
* Get apollo 3 and apollo 4 response extensions
* @param requestContext
* @returns
*/
function getExtensions(requestContext) {
if (requestContext.response.data) {
// apollo 3
if (!requestContext.response.extensions) {
requestContext.response.extensions = {};
}
return requestContext.response.extensions;
}
else if (requestContext.response.body) {
// apollo 4
if (requestContext.response.body.singleResult) {
// single
if (!requestContext.response.body.singleResult.extensions) {
requestContext.response.body.singleResult.extensions = {};
}
return requestContext.response.body.singleResult.extensions;
}
else if (requestContext.response.body.initialResult) {
//incremental
// TODO: implement incremental
return {};
}
}
}
exports.getExtensions = getExtensions;
{
"name": "apollo-deprecated-highlight",
"version": "1.1.6",
"version": "1.1.7",
"author": "Alex <alexxiyang@gmail.com>",

@@ -9,4 +9,3 @@ "description": "Highlight the apollo graphql deprecated fields",

"test": "jest",
"build": "tsc",
"publish": "jest && npm publish --access public"
"build": "tsc"
},

@@ -13,0 +12,0 @@ "repository": {

# apollo-deprecated-highlight
Highlight the apollo graphql deprecated fields
Highlight the apollo graphql deprecated fields.
It add `deprecations` to `extensions` of graphql response like this
We know that even you mark a field in apollo-server as `@deprecated` the client-side won't be able to know it until execute introspection queries. This package is for showing the deprecations in the response so that the engineers can know which fields are deprecated when they are developing.
## How to use
```
import { ApolloDeprecatedHighlight } from 'apollo-deprecated-highlight';
// add ApolloDeprecatedHighlight() as plugin
const server = new ApolloServer({
typeDefs,
resolvers,
plugins: [ApolloDeprecatedHighlight()],
...
});
```
Then it will add `deprecations` to `extensions` of graphql respons. The response format will be
```
{
"data": {...},
"extensions": {
"deprecations": [
<deprecation1>,
<deprecation2>,
...
]
}
}
```
## Example
```
"data": {...},
"extensions":

@@ -7,0 +37,0 @@ {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc