0
votes

I attempted to create a graphQl query schema with typescript and got this error message

Argument of type '{ name: string; movie: { type: GraphQLObjectType<any, any>; args: { id: { type: GraphQLScalarType; }; }; resolve(parent: any, args: any): void; }; }' is not assignable to parameter of type 'Readonly<GraphQLObjectTypeConfig<any, any>>'. Object literal may only specify known properties, and 'movie' does not exist in type 'Readonly<GraphQLObjectTypeConfig<any, any>>'

const Query = new GraphQLObjectType({
    name: "Query",
    movie: {
        type: MovieType,
        args: { id: { type: GraphQLString } },
        resolve(parent, args) {},
    },
});
1

1 Answers

1
votes

movie is not a valid parameter to pass to GraphQLObjectType's constructor. If your intent is to add a field named movie to your Query type, you should do:

const Query = new GraphQLObjectType({
  name: "Query",
  fields: {
    movie: {
      type: MovieType,
      args: { id: { type: GraphQLString } },
      resolve(parent, args) {},
    },
  },
});