Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError caused by tsconfig-paths #1226

Closed
EmiyaYang opened this issue Oct 23, 2019 · 2 comments
Closed

TypeError caused by tsconfig-paths #1226

EmiyaYang opened this issue Oct 23, 2019 · 2 comments

Comments

@EmiyaYang
Copy link

Error Report

Just follow the tutorial demo but meet this error.

# error
ts-node -r tsconfig-paths/register src/service.ts

# solve the error above but can't resolve alias path
ts-node -r src/service.ts
TypeError: graphql_1.parse is not a function
    at Object.<anonymous> (D:\Project\web\blog-service\node_modules\graphql-tools\src\stitching\introspectSchema.ts:7:48)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Object.require.extensions.(anonymous function) [as .js] (D:\Code\nodejs\node_global\node_modules\ts-node\src\index.ts:485:14)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (D:\Project\web\blog-service\node_modules\graphql-tools\src\stitching\index.ts:2:1)

Source Code

// src/server.ts
import Koa from "koa";

import server from "./graphql";

const app = new Koa();

server.applyMiddleware({ app });
src/graphql/index.ts
import { ApolloServer, gql } from "apollo-server-koa";

const typeDefs = gql`
  # Comments in GraphQL strings (such as this one) start with the hash (#) symbol.

  # This "Book" type defines the queryable fields for every book in our data source.
  type Book {
    title: String
    author: String
  }

  # The "Query" type is special: it lists all of the available queries that
  # clients can execute, along with the return type for each. In this
  # case, the "books" query returns an array of zero or more Books (defined above).
  type Query {
    books: [Book]
  }
`;

const books = [
  {
    title: "Harry Potter and the Chamber of Secrets",
    author: "J.K. Rowling"
  },
  {
    title: "Jurassic Park",
    author: "Michael Crichton"
  }
];

// Resolvers define the technique for fetching the types defined in the
// schema. This resolver retrieves books from the "books" array above.
const resolvers = {
  Query: {
    books: () => books
  }
};

// The ApolloServer constructor requires two parameters: your schema
// definition and your set of resolvers.
export default new ApolloServer({ typeDefs, resolvers });
@EmiyaYang
Copy link
Author

Switching to module-alias solves the problem. But I wanna keep tsconfig-paths.

@EmiyaYang EmiyaYang changed the title TypeError affected by tsconfig-paths TypeError caused by tsconfig-paths Oct 23, 2019
@yaacovCR
Copy link
Collaborator

yaacovCR commented Apr 1, 2020

This seems to be an ApolloServer error rather than a graphql-tools error. Closing for now, please reopen if you have more info. Possibly fixed by work along the lines of #1320 ?

@yaacovCR yaacovCR closed this as completed Apr 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants