Skip to content

Commit

Permalink
f
Browse files Browse the repository at this point in the history
  • Loading branch information
yaacovCR committed Nov 26, 2024
1 parent 019b6a9 commit a6e6bfe
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/utilities/__tests__/mapSchemaConfig-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -889,17 +889,17 @@ describe('mapSchemaConfig', () => {
);
});

it('allows adding a named type via addNamedType() and retrieving the new list via getNamedTypes', () => {
it('allows adding a named type via setNamedType() and retrieving the new list via getNamedTypes', () => {
const sdl = 'type SomeType';

const schema = buildSchema(sdl);
const schemaConfig = schema.toConfig();

expectSchemaMapping(
schemaConfig,
({ addNamedType, getNamedTypes }) => ({
({ setNamedType, getNamedTypes }) => ({
[SchemaElementKind.SCHEMA]: (config) => {
addNamedType(
setNamedType(
new GraphQLObjectType({ name: 'AnotherType', fields: {} }),
);
return {
Expand Down
4 changes: 2 additions & 2 deletions src/utilities/extendSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,13 @@ export function extendSchemaImpl(
}

return mapSchemaConfig(schemaConfig, (context) => {
const { getNamedType, addNamedType, getNamedTypes } = context;
const { getNamedType, setNamedType, getNamedTypes } = context;
return {
[SchemaElementKind.SCHEMA]: (config) => {
for (const typeNode of typeDefs) {
const type =
stdTypeMap.get(typeNode.name.value) ?? buildNamedType(typeNode);
addNamedType(type);
setNamedType(type);
}

const operationTypes = {
Expand Down
6 changes: 3 additions & 3 deletions src/utilities/mapSchemaConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ type SchemaElementKind =

export interface MappedSchemaContext {
getNamedType: (typeName: string) => GraphQLNamedType;
addNamedType: (type: GraphQLNamedType) => void;
setNamedType: (type: GraphQLNamedType) => void;
getNamedTypes: () => ReadonlyArray<GraphQLNamedType>;
}

Expand Down Expand Up @@ -184,7 +184,7 @@ export function mapSchemaConfig(
): GraphQLSchemaNormalizedConfig {
const configMapperMap = configMapperMapFn({
getNamedType,
addNamedType,
setNamedType,
getNamedTypes,
});

Expand Down Expand Up @@ -249,7 +249,7 @@ export function mapSchemaConfig(
return type;
}

function addNamedType(type: GraphQLNamedType): void {
function setNamedType(type: GraphQLNamedType): void {
mappedTypeMap.set(type.name, type);
}

Expand Down

0 comments on commit a6e6bfe

Please sign in to comment.