I am changing the format of my schema from this:
var OldSchema = new GraphQLSchema({
query: queryType,
mutation: mutationType
});
to this:
typeDef = `
type Query {
posts: [Post]
author: Author
}
`;
const NewSchema = makeExecutableSchema({
typeDefs: [typeDef],
resolvers: resolvers
});
Since I have a lot of fields, and I want to transfer them from the old format to the new format one by one, I am using the function mergeSchemas from graphql-tools:
export const RootSchema = mergeSchemas({
schemas: [NewSchema, OldSchema]
});
When I try to create a query ( which only get fields from the OldSchema ), I get the error **There can be only one fragment named "duty".
This is how my query looks:
query {
person {
...personFragment
}
}
fragment conceptFragment on Person {
jobs {
... on techJob {
...activities
}
... on carpentryJob {
...skillSet
}
}
}
fragment activities on techJob {
duties {
...duty
}
}
fragment duty on Duties {
id
}
fragment skillSet on carpentryJob {
skills {
...dutiesSkill
}
}
fragment dutiesSkill on Skill {
duties {
...duty
}
}
I know the error is happening in the parsing and it seems that the Validation of the query is happening for the OldSchema and for the RootSchema, but the RootSchema is the one that fails.