question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error with the graphql-anywhere package when compiling with TypeScript

See original GitHub issue

Intended outcome: Proper TypeScript compilation without any errors

Actual outcome:

The compiler throws the following error messages:

ERROR in /Users/robotics/github/ftc-tournament-frontend/node_modules/graphql-anywhere/src/graphql.ts
[tsl] ERROR in /Users/robotics/github/ftc-tournament-frontend/node_modules/graphql-anywhere/src/graphql.ts(2,3)
      TS2305: Module '"/Users/robotics/github/ftc-tournament-frontend/node_modules/graphql-anywhere/src/graphql"' has no exported member 'DocumentNode'.

ERROR in /Users/robotics/github/ftc-tournament-frontend/node_modules/graphql-anywhere/src/graphql.ts
[tsl] ERROR in /Users/robotics/github/ftc-tournament-frontend/node_modules/graphql-anywhere/src/graphql.ts(3,3)
      TS2305: Module '"/Users/robotics/github/ftc-tournament-frontend/node_modules/graphql-anywhere/src/graphql"' has no exported member 'SelectionSetNode'.

ERROR in /Users/robotics/github/ftc-tournament-frontend/node_modules/graphql-anywhere/src/graphql.ts
[tsl] ERROR in /Users/robotics/github/ftc-tournament-frontend/node_modules/graphql-anywhere/src/graphql.ts(4,3)
      TS2305: Module '"/Users/robotics/github/ftc-tournament-frontend/node_modules/graphql-anywhere/src/graphql"' has no exported member 'FieldNode'.

ERROR in /Users/robotics/github/ftc-tournament-frontend/node_modules/graphql-anywhere/src/graphql.ts
[tsl] ERROR in /Users/robotics/github/ftc-tournament-frontend/node_modules/graphql-anywhere/src/graphql.ts(5,3)
      TS2305: Module '"/Users/robotics/github/ftc-tournament-frontend/node_modules/graphql-anywhere/src/graphql"' has no exported member 'FragmentDefinitionNode'.

ERROR in /Users/robotics/github/ftc-tournament-frontend/node_modules/graphql-anywhere/src/graphql.ts
[tsl] ERROR in /Users/robotics/github/ftc-tournament-frontend/node_modules/graphql-anywhere/src/graphql.ts(6,3)
      TS2305: Module '"/Users/robotics/github/ftc-tournament-frontend/node_modules/graphql-anywhere/src/graphql"' has no exported member 'InlineFragmentNode'.

ERROR in /Users/robotics/github/ftc-tournament-frontend/node_modules/graphql-anywhere/src/graphql.ts
[tsl] ERROR in /Users/robotics/github/ftc-tournament-frontend/node_modules/graphql-anywhere/src/graphql.ts(148,42)
      TS2339: Property 'name' does not exist on type 'never'.

ERROR in /Users/robotics/github/ftc-tournament-frontend/node_modules/graphql-anywhere/src/graphql.ts
[tsl] ERROR in /Users/robotics/github/ftc-tournament-frontend/node_modules/graphql-anywhere/src/graphql.ts(151,58)
      TS2339: Property 'name' does not exist on type 'never'.

How to reproduce the issue: Here is my tsconfig.json if that helps:

{
  "compilerOptions": {
    "module": "es6", 
    "target": "es6",
    "moduleResolution": "node",
    "rootDir": "./src",
    "outDir": "./dist/",
    "allowSyntheticDefaultImports": true,
    "experimentalDecorators": true,
    "sourceMap": true,
    "jsx": "react"
  },
  "exclude": [
    "node_modules"
  ]
}

Here is the are the package.json dependencies that I am using:

{
"devDependencies": {
    "@types/jquery": "^3.2.15",
    "@types/react": "^16.0.15",
    "@types/react-dom": "^16.0.2",
    "@types/react-redux": "^5.0.10",
    "@types/react-responsive": "^3.0.0",
    "@types/react-router": "^4.0.15",
    "@types/react-router-redux": "^5.0.8",
    "@types/redux": "^3.6.0",
    "@types/redux-thunk": "^2.1.0",
    "@types/route-parser": "^0.1.1",
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.2",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-flow": "^6.23.0",
    "babel-preset-react": "^6.24.1",
    "copy-webpack-plugin": "^4.1.1",
    "css-loader": "^0.28.7",
    "dotenv": "^4.0.0",
    "extract-text-webpack-plugin": "^3.0.1",
    "gts": "^0.4.0",
    "html-webpack-plugin": "^2.30.1",
    "less": "^3.0.0-alpha.3",
    "less-loader": "^4.0.5",
    "optimize-css-assets-webpack-plugin": "^3.2.0",
    "raw-loader": "^0.5.1",
    "react-hot-loader": "^3.1.1",
    "resolve-url-loader": "^2.1.1",
    "rimraf": "^2.6.2",
    "source-map-loader": "^0.2.2",
    "style-loader": "^0.19.0",
    "ts-loader": "^3.0.3",
    "typescript": "^2.6.2",
    "webpack": "^3.7.1",
    "webpack-dev-server": "^2.9.2",
    "whatwg-fetch": "^2.0.3"
  },
  "dependencies": {
    "apollo-cache-inmemory": "^1.1.5",
    "apollo-client": "^2.2.0",
    "apollo-link-http": "^1.3.2",
    "graphql": "^0.12.3",
    "graphql-anywhere": "^4.1.1",
    "graphql-tag": "^2.6.1",
    "history": "^4.7.2",
    "react": "^16.0.0",
    "react-apollo": "^2.0.4",
    "react-dom": "^16.0.0",
    "react-redux": "^5.0.6",
    "react-responsive": "^3.0.0",
    "react-router": "^4.2.0",
    "react-router-redux": "^5.0.0-alpha.8",
    "redux": "^3.7.2",
    "redux-thunk": "^2.2.0"
  }
}

Version

  • apollo-client@2.2.0
  • apollo-cache-inmemory@1.1.5

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
jtag05commented, Sep 13, 2018

I ran into this and after banging my head against my keyboard all morning realized it was occurring due to having resolve.modules in my webpack config set to [ './src', 'node_modules' ]. Changing it to [ path.resolve(__dirname, '../src'), 'node_modules' ], fixes the issue. Long story short, your webpack is resolving the graphql-anywhere/src/graphql.ts as the graphql package.

3reactions
brapifracommented, Feb 15, 2018

I don’t think this is a valid solution. You are just skipping the type checking, which is the core purpose of TypeScript.

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript with Apollo Client - Apollo GraphQL Docs
Given that a GraphQL server's schema is strongly typed, we can generate TypeScript definitions automatically using a tool like GraphQL Code Generator. We'll ......
Read more >
GraphQL error handling to the max with Typescript, codegen ...
A GraphQL API will always return a 200 OK Status Code, even in case of error. You'll get a 5xx error in case...
Read more >
graphql-anywhere - npm
Run a GraphQL query anywhere, without a GraphQL server or a schema. Just pass in one resolver. Use it together with graphql-tag.
Read more >
Apollo Client Error | Type 'RestLink' is not assignable to type ...
Now I am trying to use apolloClient with both graphql and rest api in typescript. Therefore, I applied apollo ...
Read more >
A guide through The Wild Wild West of setting up a mono repo ...
This is because utils 's package.json defines its entry point via the main field to point to dist/index . When the TypeScript compiler...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found