Skip to content

Commit

Permalink
Use 'extensions' on GraphQL*Type
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed May 31, 2020
1 parent 7ff3b21 commit 269cacc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
7 changes: 2 additions & 5 deletions src/fake_definition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,11 @@ export function buildWithFakeDefinitions(
if (extensionSDL != null) {
schema = extendSchemaWithAST(schema, parseSDL(extensionSDL));

// FIXME: put in field extensions
for (const type of Object.values(schema.getTypeMap())) {
if (isObjectType(type) || isInterfaceType(type)) {
for (const field of Object.values(type.getFields())) {
const node = field.astNode;
if (node && node.loc && node.loc.source === extensionSDL) {
(field as any).isExtensionField = true;
}
const isExtensionField = field.astNode?.loc?.source === extensionSDL;
(field.extensions['isExtensionField'] as any) = isExtensionField;
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions src/proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,10 @@ function stripExtensionFields(schema, operationAST) {
const fieldDef = typeInfo.getFieldDef();
if (
fieldDef.name.startsWith('__') ||
(fieldDef as any).isExtensionField
)
fieldDef.extensions['isExtensionField'] === true
) {
return null;
}
},
[Kind.SELECTION_SET]: {
leave(node) {
Expand Down

0 comments on commit 269cacc

Please sign in to comment.