Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: Standardize application/graphql with .graphql extension #988

Open
IvanGoncharov opened this issue Aug 4, 2022 · 6 comments
Open

RFC: Standardize application/graphql with .graphql extension #988

IvanGoncharov opened this issue Aug 4, 2022 · 6 comments

Comments

@IvanGoncharov
Copy link
Member

Based on @leebyron suggestion in #203:

I’m happy to entertain a formal RFC to add errata to the spec to explain
that .graphql is the preferred extension when saving files in the graphql
language.

I propose to submit application/graphql with .graphql as an extension to the official MIME DB:
https://www.iana.org/assignments/media-types/media-types.xhtml
application/graphql already used by community see:
https://grep.app/search?q=application/graphql

Note: technically, there are substantial benefits to having it as text/graphql (same as text/html). For example, OS will open files with a text editor, and browsers show content as text.
But since application/graphql is already in many places standardizing on text/graphql will add a lot of confusion.

It looks like the process of submitting MIME type is pretty straightforward:
https://www.iana.org/form/media-types
We just need to claim it in a spec and submit the form.

I will work on spec PR in a short while, I just want to use this issue as a talking point for discussion in https://github.com/graphql/graphql-over-http repo.

@martinbonnin
Copy link
Contributor

Should we add .graphqls as an extra extension for schema files containing only type system definitions or extensions? It's technically all the same language (GraphQL) but tools such as Apollo Kotlin will treat them differently. And looks like the form allows multiple extensions.

@LunaticMuch
Copy link

Should we add .graphqls as an extra extension for schema files containing only type system definitions or extensions?

Makes sense. .htm and .html are there as well.

@maraisr
Copy link
Contributor

maraisr commented Aug 5, 2022

Didnt we just recently move to application/graphql+json or is that more about transport mime's than the file extension's mime?

@benjie
Copy link
Member

benjie commented Aug 5, 2022

After chatting with Ivan I've raised a PR proposing changing the media type used for GraphQL responses from an HTTP API to application/graphql-response+json: graphql/graphql-over-http#215 - I think we should do this.

Despite this PR, I think text/graphql would make more sense for GraphQL source files.

@sMorm
Copy link

sMorm commented Aug 26, 2022

Should we add .graphqls as an extra extension for schema files containing only type system definitions or extensions?

+1 here. Will add that in scenarios where a codebase has graphql files that define both operations and schema definition, it can help denote the difference by using .graphqls for schema definitions. This is something we've come across in our codebases.

@NuckChorris
Copy link

I want to add: this should also register .gql as an alternate extension, since that's in common use already too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants