Skip to content

Types is overwriting instead merging #31

Description

@gabrielxavier-hotmart

Hi,

I using grahpQL Modules and all my schema.graphql are separeted in modules.
My problem is:
I have one type in one module, after this, i declare this type again injecting other property.
But when i generat the interfase only the last type is considered.
Example

In Doctor Module:
type Doctor {
id: ID!
name: String!
birth: String
}

In Specialty Module:
type Doctor {
specialties: [Specialty]
}

Bu when i generate interfaces:
export interface GQLDoctor {
specialties?: Array<GQLSpecialty | null>;
}

I use this function to merge schemas:

const genSchema = async () => {
	const schemas: GraphQLSchema[] = [];
	const folders = readdirSync(join(__dirname, "../modules")).filter(f => !f.includes("."));

	folders.forEach(folder => {
		const typeDefs = importSchema(join(__dirname, ../modules/${folder}/schema.graphql`));
		schemas.push(makeExecutableSchema({ typeDefs }));
	});
	await generateTypeScriptTypes(
		mergeSchemas({ schemas }),
		join(__dirname, "../types/schemas.d.ts")
	);
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions