Transform .js files with GraphQL template literals into .graphql files
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Transform a .js file with GraphQL tagged template literals into .graphql files.


This codemod turns this file:

// User.js
const User = /* GraphQL */`
  type User {
    id: ID!

Into this .graphql file:

# User.graphql
type User {
  id: ID!

Note: It does so indistructively, it doesn't touch the original .js files at all. ⚠️ It will override an existing User.graphql file though!


# Clone the repo
git clone
# Install jscodeshift globally
npm i -g jscodeshift

# Run jscodeshift with the transform on a directory
# Note the --dry option, this means we'll only log which files would be output
jscodeshift -t ./jscodeshift-graphql-files/index.js some-dir-with-graphql-types/ --dry
# If you're happy with the resulting files do a real run without the --dry option!


Licensed under the MIT License, Copyright ©️ 2017 Maximilian Stoiber. See for more information.