Skip to content

Commit

Permalink
fix(): fix ast definitions generation for federated graph
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilmysliwiec committed Apr 5, 2020
1 parent febdddd commit b03c5ef
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions lib/graphql-ast.explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class GraphQLAstExplorer {
let { definitions } = documentNode;
definitions = sortBy(definitions, ['kind', 'name']);

definitions.forEach(item =>
definitions.forEach((item) =>
this.lookupDefinition(
item as Readonly<TypeSystemDefinitionNode>,
tsFile,
Expand Down Expand Up @@ -107,7 +107,7 @@ export class GraphQLAstExplorer {
isExported: true,
kind: structureKind,
});
operationTypes.forEach(item => {
operationTypes.forEach((item) => {
if (!item) {
return;
}
Expand Down Expand Up @@ -164,7 +164,7 @@ export class GraphQLAstExplorer {
this.addExtendInterfaces(interfaces, parentRef as InterfaceDeclaration);
}
}
((item.fields || []) as any).forEach(element => {
((item.fields || []) as any).forEach((element) => {
this.lookupFieldDefiniton(element, parentRef, mode);
});
}
Expand All @@ -190,6 +190,10 @@ export class GraphQLAstExplorer {
if (!propertyName) {
return;
}
const federatedFields = ['_entities', '_service'];
if (federatedFields.includes(propertyName)) {
return;
}

const { name: type, required } = this.getFieldTypeDefinition(item.type);
if (!this.isRoot(parentRef.getName())) {
Expand Down Expand Up @@ -275,7 +279,7 @@ export class GraphQLAstExplorer {
if (!inputs) {
return [];
}
return inputs.map(element => {
return inputs.map((element) => {
const { name, required } = this.getFieldTypeDefinition(element.type);
return {
name: get(element, 'name.value'),
Expand Down Expand Up @@ -305,7 +309,7 @@ export class GraphQLAstExplorer {
if (!interfaces) {
return;
}
interfaces.forEach(element => {
interfaces.forEach((element) => {
const interfaceName = get(element, 'name.value');
if (interfaceName) {
parentRef.addExtends(interfaceName);
Expand All @@ -320,7 +324,7 @@ export class GraphQLAstExplorer {
if (!interfaces) {
return;
}
interfaces.forEach(element => {
interfaces.forEach((element) => {
const interfaceName = get(element, 'name.value');
if (interfaceName) {
parentRef.addImplements(interfaceName);
Expand All @@ -333,7 +337,7 @@ export class GraphQLAstExplorer {
if (!name) {
return;
}
const members = map(item.values, value => ({
const members = map(item.values, (value) => ({
name: get(value, 'name.value'),
value: get(value, 'name.value'),
}));
Expand All @@ -349,7 +353,9 @@ export class GraphQLAstExplorer {
if (!name) {
return;
}
const types: string[] = map(item.types, value => get(value, 'name.value'));
const types: string[] = map(item.types, (value) =>
get(value, 'name.value'),
);
tsFile.addTypeAlias({
name,
type: types.join(' | '),
Expand Down

0 comments on commit b03c5ef

Please sign in to comment.