Skip to content

Commit

Permalink
Add application/graphql+json mime and media types
Browse files Browse the repository at this point in the history
Closes gh-28271
  • Loading branch information
bclozel committed Apr 1, 2022
1 parent d518a7d commit 17f7a24
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Expand Up @@ -65,6 +65,17 @@ public abstract class MimeTypeUtils {
*/
public static final String ALL_VALUE = "*/*";

/**
* Public constant mime type for {@code application/graphql+json}.
* @see <a href="https://github.com/graphql/graphql-over-http">GraphQL over HTTP spec</a>
* */
public static final MimeType APPLICATION_GRAPHQL;

/**
* A String equivalent of {@link MimeTypeUtils#APPLICATION_GRAPHQL}.
*/
public static final String APPLICATION_GRAPHQL_VALUE = "application/graphql+json";

/**
* Public constant mime type for {@code application/json}.
* */
Expand Down Expand Up @@ -165,6 +176,7 @@ public abstract class MimeTypeUtils {
static {
// Not using "parseMimeType" to avoid static init cost
ALL = new MimeType("*", "*");
APPLICATION_GRAPHQL = new MimeType("application", "graphql+json");
APPLICATION_JSON = new MimeType("application", "json");
APPLICATION_OCTET_STREAM = new MimeType("application", "octet-stream");
APPLICATION_XML = new MimeType("application", "xml");
Expand Down
12 changes: 12 additions & 0 deletions spring-web/src/main/java/org/springframework/http/MediaType.java
Expand Up @@ -95,6 +95,17 @@ public class MediaType extends MimeType implements Serializable {
*/
public static final String APPLICATION_FORM_URLENCODED_VALUE = "application/x-www-form-urlencoded";

/**
* Public constant media type for {@code application/graphql+json}.
* @see <a href="https://github.com/graphql/graphql-over-http">GraphQL over HTTP spec</a>
*/
public static final MediaType APPLICATION_GRAPHQL;

/**
* A String equivalent of {@link MediaType#APPLICATION_GRAPHQL}.
*/
public static final String APPLICATION_GRAPHQL_VALUE = "application/graphql+json";

/**
* Public constant media type for {@code application/json}.
*/
Expand Down Expand Up @@ -396,6 +407,7 @@ public class MediaType extends MimeType implements Serializable {
APPLICATION_ATOM_XML = new MediaType("application", "atom+xml");
APPLICATION_CBOR = new MediaType("application", "cbor");
APPLICATION_FORM_URLENCODED = new MediaType("application", "x-www-form-urlencoded");
APPLICATION_GRAPHQL = new MediaType("application", "graphql+json");
APPLICATION_JSON = new MediaType("application", "json");
APPLICATION_JSON_UTF8 = new MediaType("application", "json", StandardCharsets.UTF_8);
APPLICATION_NDJSON = new MediaType("application", "x-ndjson");
Expand Down

0 comments on commit 17f7a24

Please sign in to comment.