Skip to content
This repository was archived by the owner on Sep 11, 2019. It is now read-only.
This repository was archived by the owner on Sep 11, 2019. It is now read-only.

Class methods are lost when spreading over context #76

@vjpr

Description

@vjpr
query {
  getLatestComic {
    transcript
    year
    month
    day
    link
    news
  }
}
{
  "data": {
    "getLatestComic": null
  },
  "errors": [
    {
      "message": "context.getLatestComic is not a function",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "getLatestComic"
      ]
    }
  ]
}

Server log:

Error: context.getComicById is not a function
    at Object.checkResultAndHandleErrors xxx/packages/xxx-graphql/node_modules/.registry.npmjs.org/graphql-tools/2.18.0/node_modules/graphql-tools/src/stitching/errors.ts:84:7)
    at Object.<anonymous> xxx/packages/xxx-graphql/node_modules/.registry.npmjs.org/graphql-tools/2.18.0/node_modules/graphql-tools/src/stitching/delegateToSchema.ts:97:14)
    at step xxx/packages/xxx-graphql/node_modules/.registry.npmjs.org/graphql-tools/2.18.0/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:40:23)
    at Object.next xxx/packages/xxx-graphql/node_modules/.registry.npmjs.org/graphql-tools/2.18.0/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:21:53)
    at fulfilled xxx/packages/xxx-graphql/node_modules/.registry.npmjs.org/graphql-tools/2.18.0/node_modules/graphql-tools/dist/stitching/delegateToSchema.js:12:58)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)

I tried this:

  const XKCD = require('@gramps/data-source-xkcd').default

  const gramps = require('@gramps/gramps').default
  const GraphQLOptions = gramps({
    dataSources: [XKCD],
  })

  router.post(
    '/graphql-gramps',
    koaBody(),
    graphqlKoa(ctx => {
      console.log({ctx})
      return GraphQLOptions(ctx.req)
    }),
  )

I can see all the functions in graphiql, but running them causes this error.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions