Graphql-code-generator: Plugin typescript does not export a valid JS object with "plugin" function.

Created on 10 Jan 2020  路  3Comments  路  Source: dotansimha/graphql-code-generator

Describe the bug

When I try to follow the getting started from the docs, I get the error:
Plugin typescript does not export a valid JS object with "plugin" function.

To Reproduce

  1. My codegen.yml
overwrite: true
schema: "./schema.graphql"
documents: null
generates:
  ./types.ts:
    plugins:
      - "typescript"
  1. My GraphQL schema:
type Query {
  resultSet(searchText: String!): ResultSet
  board(id: ID!): Board
}

type Mutation {
  createBoard: Board
  addPhotosToBoard(input: AddPhotosToBoardInput!): AddPhotosToBoardPayload
  updateBoardLayout(input: UpdateBoardLayoutInput!): UpdateBoardLayoutPayload
}

type ResultSet {
  photos: [Photo]!
}

type Photo {
  id: ID!
  owner: String!
  secret: String!
  server: Int!
  farm: Int!
  title: String!
  ispublic: Int!
  isfriend: Int!
  isfamily: Int!
}

enum TileSize {
  SMALL
  MEDIUM
  LARGE
}

type Tile {
  photo: Photo!
  size: TileSize!
}

type Board {
  id: ID!
  tiles: [Tile!]!
}

input AddPhotosToBoardInput {
  id: ID!
  photos: [PhotoInput!]!
}

input PhotoInput {
  id: ID!
  owner: String!
  secret: String!
  server: Int!
  farm: Int!
  title: String!
}

type AddPhotosToBoardPayload {
  board: Board
}

input UpdateBoardLayoutInput {
  id: ID!
  tileChanges: [TileChange!]!
}

input TileChange {
  id: ID!
  size: TileSize
}

type UpdateBoardLayoutPayload {
  board: Board
}

Expected behavior

Types should be generated.

Environment:

  • OS: Mac OSX
  • @graphql-codegen/...: 1.11.2
  • NodeJS: 10.11.0

This is related to #1703 which was closed without a solution.

waiting-for-answer

Most helpful comment

Had the same issue, this was because the quick start section did not mention @graphql-codegen/typescript installation. I can contribute to the docs if you'd like.

All 3 comments

@ashubham can you please provide a reproduction in codesandbox/repo? We couldn't reproduce this issue.

Please make sure you have @graphql-codegen/typescript installed.

Had the same issue, this was because the quick start section did not mention @graphql-codegen/typescript installation. I can contribute to the docs if you'd like.

@doronnac Thank, this could help. The current documentation is not focused in TypeScript because we support multiple platforms and environments, not only typescript.
The basic instruction is to install the plugins you are using under plugins: section.

Closing for now. @ashubham If you have a reproduction, please share with us and we'll re-open this issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

leebenson picture leebenson  路  3Comments

quolpr picture quolpr  路  3Comments

fvisticot picture fvisticot  路  3Comments

bastman picture bastman  路  3Comments

dotansimha picture dotansimha  路  3Comments