Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nexus-to-pothos-codemod

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nexus-to-pothos-codemod

Codemod to migrate from Nexus to Pothos

  • 0.3.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
decreased by-71.43%
Maintainers
1
Weekly downloads
 
Created
Source

Nexus to Pothos codemod

npm version PRs Welcome

This is a codemod to migrate from Nexus to Pothos

This aims to transform all the nexus types, queries and mutations to Pothos equivalents. Please note that the codemod is by no means complete. You still need some manual adjustments. Below is a list of known missing features.

You can check out the __textfixtures__ folder to see full list of supported transformations.

Why should I migrate to use Pothos?

  • Pothos has superior type safety
  • Pothos does not require you to generate types which makes type feedback much much faster
  • Pothos is actively maintained

Install

$ yarn global add nexus-to-pothos-codemod

or

$ npm install -g nexus-to-pothos-codemod

Usage

$ nexus-to-pothos-codemod ./**/*.ts --ignore-pattern="**/node_modules/**" --parser=ts

The CLI is the same as in jscodeshift except you can omit the transform file.

Alternatively, you can run the codemod using jscodeshift as follows:

$ yarn global add jscodeshift
$ yarn add nexus-to-pothos-codemod
$ jscodeshift -t node_modules/nexus-to-pothos-codemod/transform.ts --ignore-pattern="**/node_modules/**" ./**/*.js  --parser=ts

Migrating the codebase

The codemod might not be 100% accurate. You will need to do some manual adjustments. Might be good to compare the generated GraphQL schema with the old one to see if there are any differences.

What is missing?

  • Automatic import updates

  • It assumes some conventions such as async nodes((_, args, ctx) {} instead of nodes: async ((_, args, ctx) => {} which causes exceptions

  • Does not understand computed fields such as:

    export const Object = objectType({
    name: 'Object',
    definition(t) {
      objectFields.forEach(objectField => t.string(objectField));
    }
    });
    
  • Might fail on complex types

  • unionType not transformed

  • scalarType not transformed

Contributing

Contributions are more than welcome! Some useful tools for developing this are https://astexplorer.net/ and your editors builtin debugger.

Keywords

FAQs

Package last updated on 02 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc