0

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 Answer 1

1

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) {},
    },
  },
});
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.