1.1.15 • Published 3 years ago

apollo-deprecated-highlight v1.1.15

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

apollo deprecated highlight

circleci codecov Known Vulnerabilities

Highlight the apollo graphql deprecated fields.

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.

NOTE: This package is only for apollo 4. If you are using apollo 3 please use apollo3-deprecated-highlight

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

Here is the example project

We mark title, author and make as deprecated fields in the schema

type Book {
    title: String @deprecated(reason:"title is deprecated. Dont't use it")
    author: String @deprecated(reason:"author is deprecated. Dont't use it")
}

type Car {
    make: String @deprecated(reason:"make is deprecated. Dont't use it")
    model: String
}

You will see the deprecations in the response response example

Here is the response

"data": {...}
"extensions": {
    "deprecations": [
      {
        "field": "title",
        "reason": "title is deprecated. Dont't use it"
      },
      {
        "field": "author",
        "reason": "author is deprecated. Dont't use it"
      },
      {
        "field": "make",
        "reason": "make is deprecated. Dont't use it"
      }
    ]
  }

Friendly browser warnings

It's better use this package with apollo-deprecated-highlight-client. You can get friendly browser warnings in console like this client example

1.1.15

3 years ago

1.1.14

3 years ago

1.1.12

3 years ago

1.1.11

3 years ago

1.1.10

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago