Socket
Socket
Sign inDemoInstall

apollo-codegen

Package Overview
Dependencies
104
Maintainers
3
Versions
102
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.19.0 to 0.19.1

.github/ISSUE_TEMPLATE.md

20

lib/compiler/index.js

@@ -5,8 +5,2 @@ "use strict";

const graphql_2 = require("../utilities/graphql");
function argumentsFromAST(args) {
return (args &&
args.map(arg => {
return { name: arg.name.value, value: graphql_2.valueFromValueNode(arg.value) };
}));
}
function compileToIR(schema, document, options = {}) {

@@ -122,5 +116,2 @@ if (options.addTypename) {

const alias = selectionNode.alias ? selectionNode.alias.value : undefined;
const args = selectionNode.arguments && selectionNode.arguments.length > 0
? argumentsFromAST(selectionNode.arguments)
: undefined;
const fieldDef = graphql_2.getFieldDef(this.schema, parentType, selectionNode);

@@ -137,2 +128,13 @@ if (!fieldDef) {

const responseKey = alias || name;
const args = selectionNode.arguments && selectionNode.arguments.length > 0
? selectionNode.arguments.map(arg => {
const name = arg.name.value;
const argDef = fieldDef.args.find(argDef => argDef.name === arg.name.value);
return {
name,
value: graphql_2.valueFromValueNode(arg.value),
type: (argDef && argDef.type) || undefined
};
})
: undefined;
let field = {

@@ -139,0 +141,0 @@ kind: 'Field',

@@ -103,3 +103,3 @@ "use strict";

isDeprecated,
deprecationReason }, selectionSet ? this.transformSelectionSetToLegacyIR(selectionSet) : {});
deprecationReason }, (selectionSet ? this.transformSelectionSetToLegacyIR(selectionSet) : {}));
});

@@ -106,0 +106,0 @@ }

@@ -577,3 +577,3 @@ "use strict";

if (property.isOptional) {
property.typeName = `Optional<${property.typeName}>`;
property.typeName = `Swift.Optional<${property.typeName}>`;
}

@@ -591,3 +591,3 @@ });

});
for (const { propertyName, typeName, description } of properties) {
for (const { name, propertyName, typeName, description } of properties) {
this.printNewlineIfNeeded();

@@ -599,7 +599,7 @@ this.comment(description);

this.withinBlock(() => {
this.printOnNewline(`return graphQLMap["${propertyName}"] as! ${typeName}`);
this.printOnNewline(`return graphQLMap["${name}"] as! ${typeName}`);
});
this.printOnNewline('set');
this.withinBlock(() => {
this.printOnNewline(`graphQLMap.updateValue(newValue, forKey: "${propertyName}")`);
this.printOnNewline(`graphQLMap.updateValue(newValue, forKey: "${name}")`);
});

@@ -606,0 +606,0 @@ });

{
"name": "apollo-codegen",
"version": "0.19.0",
"version": "0.19.1",
"description": "Generate API code or type annotations based on a GraphQL schema and query documents",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -9,2 +9,3 @@ import {

GraphQLOutputType,
GraphQLInputType,
GraphQLScalarType,

@@ -23,3 +24,2 @@ GraphQLEnumType,

SelectionNode,
ArgumentNode,
isSpecifiedScalarType

@@ -54,11 +54,2 @@ } from 'graphql';

function argumentsFromAST(args: ArgumentNode[]): Argument[] {
return (
args &&
args.map(arg => {
return { name: arg.name.value, value: valueFromValueNode(arg.value) };
})
);
}
export interface Operation {

@@ -94,2 +85,3 @@ operationId?: string;

value: any;
type?: GraphQLInputType;
}

@@ -171,4 +163,4 @@

fragmentSpread.isConditional = fragment.selectionSet.possibleTypes.some(type =>
!fragmentSpread.selectionSet.possibleTypes.includes(type)
fragmentSpread.isConditional = fragment.selectionSet.possibleTypes.some(
type => !fragmentSpread.selectionSet.possibleTypes.includes(type)
);

@@ -179,3 +171,3 @@

selections: fragment.selectionSet.selections
}
};
}

@@ -301,7 +293,2 @@

const args =
selectionNode.arguments && selectionNode.arguments.length > 0
? argumentsFromAST(selectionNode.arguments)
: undefined;
const fieldDef = getFieldDef(this.schema, parentType, selectionNode);

@@ -323,2 +310,15 @@ if (!fieldDef) {

const args =
selectionNode.arguments && selectionNode.arguments.length > 0
? selectionNode.arguments.map(arg => {
const name = arg.name.value;
const argDef = fieldDef.args.find(argDef => argDef.name === arg.name.value);
return {
name,
value: valueFromValueNode(arg.value),
type: (argDef && argDef.type) || undefined
};
})
: undefined;
let field: Field = {

@@ -354,3 +354,3 @@ kind: 'Field',

const typeNode = selectionNode.typeCondition;
const type = typeNode ? typeFromAST(this.schema, typeNode) as GraphQLCompositeType : parentType;
const type = typeNode ? (typeFromAST(this.schema, typeNode) as GraphQLCompositeType) : parentType;
const possibleTypesForTypeCondition = this.possibleTypesForType(type).filter(type =>

@@ -357,0 +357,0 @@ possibleTypes.includes(type)

@@ -1,2 +0,9 @@

import { GraphQLSchema, GraphQLType, GraphQLObjectType, GraphQLCompositeType, DocumentNode } from 'graphql';
import {
GraphQLSchema,
GraphQLType,
GraphQLObjectType,
GraphQLCompositeType,
GraphQLInputType,
DocumentNode
} from 'graphql';

@@ -88,2 +95,3 @@ import { compileToIR, CompilerContext, SelectionSet, Field, FragmentSpread } from './';

value: any;
type?: GraphQLInputType;
}

@@ -160,3 +168,5 @@

const fields: LegacyField[] = this.transformFieldsToLegacyIR(collectAndMergeFields(typeCase.default, false));
const fields: LegacyField[] = this.transformFieldsToLegacyIR(
collectAndMergeFields(typeCase.default, false)
);

@@ -225,3 +235,3 @@ const inlineFragments: LegacyInlineFragment[] = typeCase.variants.flatMap(variant => {

deprecationReason,
...selectionSet ? this.transformSelectionSetToLegacyIR(selectionSet) : {}
...(selectionSet ? this.transformSelectionSetToLegacyIR(selectionSet) : {})
} as LegacyField;

@@ -228,0 +238,0 @@ });

@@ -819,3 +819,3 @@ import * as path from 'path';

if (property.isOptional) {
property.typeName = `Optional<${property.typeName}>`;
property.typeName = `Swift.Optional<${property.typeName}>`;
}

@@ -850,3 +850,3 @@ });

for (const { propertyName, typeName, description } of properties) {
for (const { name, propertyName, typeName, description } of properties) {
this.printNewlineIfNeeded();

@@ -858,7 +858,7 @@ this.comment(description);

this.withinBlock(() => {
this.printOnNewline(`return graphQLMap["${propertyName}"] as! ${typeName}`);
this.printOnNewline(`return graphQLMap["${name}"] as! ${typeName}`);
});
this.printOnNewline('set');
this.withinBlock(() => {
this.printOnNewline(`graphQLMap.updateValue(newValue, forKey: "${propertyName}")`);
this.printOnNewline(`graphQLMap.updateValue(newValue, forKey: "${name}")`);
});

@@ -865,0 +865,0 @@ });

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc