Skip to content
This repository has been archived by the owner on Oct 11, 2022. It is now read-only.

Transform .js files with GraphQL template literals into .graphql files

License

Notifications You must be signed in to change notification settings

withspectrum/jscodeshift-graphql-files

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jscodeshift-graphql-files

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

Example

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!

Usage

# Clone the repo
git clone git@github.com:withspectrum/jscodeshift-graphql-files
# 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!

License

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

About

Transform .js files with GraphQL template literals into .graphql files

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published