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

Subscription using Typescript - Property 'Subscription' is incompatible with index signature. #95

Closed
Chabane opened this issue Aug 1, 2017 · 1 comment

Comments

@Chabane
Copy link

Chabane commented Aug 1, 2017

Hello,

I got this error when I tried to execute this code. Do you have any idea?

src/index.ts(40,49): error TS2345: Argument of type '{ typeDefs: string; resolvers: { Query: { addCell: (: any, { type }: { type: any; }) => Prom...' is not assignable to parameter of type 'IExecutableSchemaDefinition'.
Types of property 'resolvers' are incompatible.
Type '{ Query: { addCell: (
: any, { type }: { type: any; }) => Promise; }; Subscription: ...' is not assignable to type 'IResolvers'.
Property 'Subscription' is incompatible with index signature.
Type '{ newCell: { subscribe: (: any, { type }: { type: any; }) => AsyncIterator<{}>; }; }' is not assignable to type 'GraphQLScalarType | IResolverObject | (() => any)'.
Type '{ newCell: { subscribe: (
: any, { type }: { type: any; }) => AsyncIterator<{}>; }; }' is not assignable to type '() => any'.
Type '{ newCell: { subscribe: (_: any, { type }: { type: any; }) => AsyncIterator<{}>; }; }' provides no match for the signature '(): any'.

import { PubSub } from 'graphql-subscriptions';
const pubsub = new PubSub();

export const typeDefs = `

type Subscription {
  newCell: Cell
}

type Query {
  addCell(type: CellType!): Cell
}

schema {
  query: Query
  subscription: Subscription
}
`

export const resolvers = {
  Query: {
    addCell: async (_, { type }) => {
      let cell = new Cell();
      cell.type = type;
      pubsub.publish('newCell', { newCell: cell });
      return cell;
    },
  },

  Subscription: {
    newCell: {
      subscribe: () =>
        pubsub.asyncIterator('newCell')
    }
  }
};
@Chabane Chabane changed the title Subscription using Typescript Subscription using Typescript - Property 'Subscription' is incompatible with index signature. Aug 1, 2017
@Chabane
Copy link
Author

Chabane commented Aug 1, 2017

I opened an issue on graphql-tools. I close this issue.
ardatan/graphql-tools#372

@Chabane Chabane closed this as completed Aug 1, 2017
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

1 participant