1.0.7 • Published 2 years ago

gql-folder-cli v1.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Generate GraphQL Resolver Templates

Easily create a clean folder structure based on a GraphQL schema string

Just go into the folder that contains a file containing your GraphQL schema and run npx gql-folder-cli filename.js. By default, filename.js will be schema.js and variableName will be typeDefs.

The file containing your GraphQL schema should look as follows:

 export const typeDefs = `
  type User {
    id: Int!
    username: String!
  }

  type Something {
    id: Int!
    user: User
    userId: Int!
  }

  type Mutation {
    createNewUser(email: String!): User
    createSomething: Something
  }
`;

The generated folder structure will rougly look as follows:

 resolvers/
  ├─ mutations/
  │  ├─ createSomething.js
  │  ├─ index.js
  ├─ something/
  │  ├─ index.js
  │  ├─ user.js
  ├─ user/
  │  ├─ index.js
  ├─ index.js

Every file initializes the resolver functions and exports them in the index.js. The main index.js will look as follows:

  import { User } from "./user";
  import { Something } from "./something";
  import { Mutation } from "./mutations";

  export const resolvers = {
    User,
    Something,
    Mutation,
  };
1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago