Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

joshuabaker/codemod-graphql-to-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

.graphql to .js

Converts .graphql files to .js formatted with graphql-tag.

Automatically handles fragments imported using #import.

Usage

node path/to/script.js path/to/project/src

Before

#import "./FragmentEntry.graphql"

fragment article on articles_article_Entry {
  ...entry
  articleType {
    title
    slug
  }
}

After

import gql from "graphql-tag";
import FragmentEntry from "./FragmentEntry";

const FragmentArticle = gql`
  ${FragmentEntry}

  fragment article on articles_article_Entry {
    ...entry
    articleType {
      title
      slug
    }
  }
`;

export default FragmentArticle;