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

extend type Mutation/Query does not work - [Error: "X" defined in resolvers, but not in schema] #994

Closed
1 of 4 tasks
puzzledbytheweb opened this issue Oct 30, 2018 · 2 comments
Labels
blocking Prevents production or dev due to perf, bug, build error, etc.. docs Focuses on documentation changes

Comments

@puzzledbytheweb
Copy link

puzzledbytheweb commented Oct 30, 2018

  • has-reproduction
  • feature
  • docs
  • blocking

Hi everyone!
I am using graphql-tools: ^4.0.3, graphql: ^14.0.2, apollo-server: ^2.1.0

This is the error I am having:
[Error: "createUser" defined in resolvers, but not in schema]

This is the way I am creating my typeDefs:


import Scalars from "../scalars/scalars.graphql";
import Query from "../types/Query/Query.graphql";
import Mutation from "../types/Mutation/Mutation.graphql";

import Review from "./Review/ReviewSchema.graphql";
import ReviewQueries from "./Review/ReviewQueries.graphql";
import ReviewMutations from "./Review/ReviewMutations.graphql";

import UserMutations from "./User/UserMutations.graphql";
import User from "./User/UserSchema.graphql";
import UserQueries from "./User/UserQueries.graphql";

// Construct a schema, using GraphQL schema language
const typeDefs = [
    Query,
    Mutation,
    User,
    UserQueries,
    UserMutations,
    MongoResult,
    Review,
    ReviewQueries,
    ReviewMutations,
    Scalars
];

export default typeDefs;

This is how I am merging my resolvers:

import merge from "lodash/merge";

import Scalars from "./scalars/Scalars";

import Mutation from "./types/Mutation/Mutation";
import Query from "./types/Query/Query";

// Merge resolvers
const resolvers = merge(Mutation, Query, Scalars);

// Provide resolver functions for your schema fields
export default resolvers;

What am I missing?
These problems started when I started using these keywords:

ReviewMutations.graphql:

extend type Mutation {
    createReview(ReviewToBeCreated: ReviewInput!): Review
    destroyReview(idOfReviewToBeDestroyed: ID!): MongoResult
    updateReview(
        idOfReviewToBeUpdated: ID!
        fieldsToUpdate: ReviewInput
    ): MongoResult
}

ReviewQueries.graphql:

extend type Query {
    getReview(id: ID!): Review
    getManyReviews(emailOfBusiness: String!): [Review]
}

Same usage in UserQueries and UserMutation.

This is how I am creating the Apollo Server:

        const server = new ApolloServer({
            schema: makeExecutableSchema({ typeDefs, resolvers }),
            context: ({ ctx }) => ctx
        });

I've seen these issues:
apollographql/apollo-server#1158,
#750,

I've spent too much time trying to solve this issue to no avail, please help me!

If you need some more info please tell me ;)

Thanks in advance!

@ghost ghost added blocking Prevents production or dev due to perf, bug, build error, etc.. docs Focuses on documentation changes labels Oct 30, 2018
@puzzledbytheweb
Copy link
Author

puzzledbytheweb commented Oct 30, 2018

This issue was not caused by graphql-tools, I tried to "recycle" the code created for User resolvers by copying and pasting to Review resolvers to make minor alterations after, but something must have been wrongly done and that error was thrown.

I have gone back using git (praised version control!) and now I'm doing everything step by step instead of trying to save time (which has instead wasted too much of it).

Sorry if this just ends up poluting this great project issues tab...

Thanks!

@ghost
Copy link

ghost commented Jan 17, 2019

what did you do to extend mutation?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocking Prevents production or dev due to perf, bug, build error, etc.. docs Focuses on documentation changes
Projects
None yet
Development

No branches or pull requests

1 participant