{"action":"closed","issue":{"url":"https://api.github.com/repos/prisma/graphql-yoga/issues/405","repository_url":"https://api.github.com/repos/prisma/graphql-yoga","labels_url":"https://api.github.com/repos/prisma/graphql-yoga/issues/405/labels{/name}","comments_url":"https://api.github.com/repos/prisma/graphql-yoga/issues/405/comments","events_url":"https://api.github.com/repos/prisma/graphql-yoga/issues/405/events","html_url":"https://github.com/prisma/graphql-yoga/issues/405","id":342275396,"node_id":"MDU6SXNzdWUzNDIyNzUzOTY=","number":405,"title":"Potentially incorrect IResolvers type","user":{"login":"Slessi","id":3223500,"node_id":"MDQ6VXNlcjMyMjM1MDA=","avatar_url":"https://avatars1.githubusercontent.com/u/3223500?v=4","gravatar_id":"","url":"https://api.github.com/users/Slessi","html_url":"https://github.com/Slessi","followers_url":"https://api.github.com/users/Slessi/followers","following_url":"https://api.github.com/users/Slessi/following{/other_user}","gists_url":"https://api.github.com/users/Slessi/gists{/gist_id}","starred_url":"https://api.github.com/users/Slessi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Slessi/subscriptions","organizations_url":"https://api.github.com/users/Slessi/orgs","repos_url":"https://api.github.com/users/Slessi/repos","events_url":"https://api.github.com/users/Slessi/events{/privacy}","received_events_url":"https://api.github.com/users/Slessi/received_events","type":"User","site_admin":false},"labels":[{"id":1137279672,"node_id":"MDU6TGFiZWwxMTM3Mjc5Njcy","url":"https://api.github.com/repos/prisma/graphql-yoga/labels/stale","name":"stale","color":"ffffff","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-07-18T10:46:49Z","updated_at":"2018-11-30T03:43:20Z","closed_at":"2018-11-30T03:43:20Z","author_association":"NONE","body":"In [types.ts](https://github.com/jasonkuhrt/graphql-yoga/blob/e39cf2d433b19203a7253fc34206a5e12f48996a/src/types.ts)\r\n\r\n```ts\r\nexport interface IResolvers {\r\n    [key: string]: (() => any) | IResolverObject | GraphQLScalarType;\r\n}\r\nexport declare type IResolverObject = {\r\n    [key: string]: GraphQLFieldResolver<any, any> | IResolverOptions;\r\n};\r\n```\r\n\r\nIs this correct? As I understand it, `IResolverOptions` should not be part of `IResolverObject`, and should be as follows:\r\n\r\n```ts\r\nexport interface IResolvers {\r\n    [key: string]: (() => any) | IResolverObject | GraphQLScalarType | IResolverOptions;\r\n}\r\nexport declare type IResolverObject = {\r\n    [key: string]: GraphQLFieldResolver<any, any> | IResolverOptions | IResolverObject;\r\n}\r\n```\r\n\r\nThe following does not compile for me for example:\r\n\r\n```ts\r\nimport { GraphQLServer } from \"graphql-yoga\";\r\nimport { IResolverOptions } from \"graphql-yoga/dist/types\";\r\n\r\n// ok\r\nconst MyInterface: IResolverOptions = {\r\n    __resolveType: (obj, c, e) => \"whatever\",\r\n};\r\n\r\n// not ok\r\nexport const server = new GraphQLServer({\r\n    resolvers: { MyInterface },\r\n});\r\n```\r\n\r\n```\r\n[ts] Argument of type '{ resolvers: { MyInterface: IResolverOptions; }; }' is not assignable to parameter of type 'Props<any, any, any>'.\r\n       Types of property 'resolvers' are incompatible.\r\n         Type '{ MyInterface: IResolverOptions; }' is not assignable to type 'IResolvers | undefined'.\r\n           Type '{ MyInterface: IResolverOptions; }' is not assignable to type 'IResolvers'.\r\n             Property 'MyInterface' is incompatible with index signature.\r\n               Type 'IResolverOptions' is not assignable to type '(() => any) | IResolverObject | GraphQLScalarType'.\r\n                 Type 'IResolverOptions' is not assignable to type 'GraphQLScalarType'.\r\n                   Property 'name' is missing in type 'IResolverOptions'.\r\n```\r\n\r\nThe following *does* compile, but only because it thinks its a `GraphQLFieldResolver`\r\n\r\n```ts\r\nimport { GraphQLServer } from \"graphql-yoga\";\r\n\r\nexport const server = new GraphQLServer({\r\n    resolvers: {\r\n        MyInterface: {\r\n            __resolveType: (obj, c, e) => \"whatever\",\r\n        },\r\n    },\r\n});\r\n```\r\n\r\nIf I try to use `IResolverObject` as below, the  code will compile but generate an error at runtime:\r\n\r\n> Error: MyInterface.MyInterface defined in resolvers, but not in schema\r\n\r\nWhich is true, I would only have `MyInterface` defined, not `MyInterface.MyInterface`.\r\n\r\n```ts\r\nimport { GraphQLServer } from \"graphql-yoga\";\r\nimport { IResolverObject } from \"graphql-yoga/dist/types\";\r\n\r\n// not representative of schema\r\nconst MyInterface: IResolverObject = {\r\n    MyInterface: {\r\n        __resolveType: (obj, c, e) => \"whatever\",\r\n    },\r\n};\r\n\r\nexport const server = new GraphQLServer({\r\n    resolvers: { MyInterface },\r\n});\r\n```\r\n\r\nI'd submit a PR to fix but I am unsure of what the correct implementation is\r\n\r\nEDIT: As these types seem to be mimicking `graphql-tools` I checked their types and see the same setup, so I submitted a PR there and will see what they think https://github.com/apollographql/graphql-tools/pull/896"}}
{"actor":{"display_login":"stale"}}