apollo-codegen-core
Advanced tools
Comparing version 0.29.0-register.0 to 1.0.0-alpha.80
@@ -83,1 +83,2 @@ import { GraphQLOutputType, GraphQLInputType, GraphQLObjectType, GraphQLSchema, GraphQLType, GraphQLCompositeType, DocumentNode } from "graphql"; | ||
export declare function compileToIR(schema: GraphQLSchema, document: DocumentNode, options?: CompilerOptions): CompilerContext; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -19,3 +19,3 @@ "use strict"; | ||
case graphql_1.Kind.FRAGMENT_DEFINITION: | ||
const fragment = compiler.compileFragment(definition, false); | ||
const fragment = compiler.compileFragment(definition); | ||
fragments[fragment.fragmentName] = fragment; | ||
@@ -87,6 +87,6 @@ break; | ||
rootType, | ||
selectionSet: this.compileSelectionSet(operationDefinition.selectionSet, rootType, false) | ||
selectionSet: this.compileSelectionSet(operationDefinition.selectionSet, rootType) | ||
}; | ||
} | ||
compileFragment(fragmentDefinition, isClient) { | ||
compileFragment(fragmentDefinition) { | ||
const fragmentName = fragmentDefinition.name.value; | ||
@@ -101,17 +101,16 @@ const filePath = graphql_2.filePathForNode(fragmentDefinition); | ||
type, | ||
selectionSet: this.compileSelectionSet(fragmentDefinition.selectionSet, type, isClient) | ||
selectionSet: this.compileSelectionSet(fragmentDefinition.selectionSet, type) | ||
}; | ||
} | ||
compileSelectionSet(selectionSetNode, parentType, isClient, possibleTypes = this.possibleTypesForType(parentType), visitedFragments = new Set()) { | ||
compileSelectionSet(selectionSetNode, parentType, possibleTypes = this.possibleTypesForType(parentType), visitedFragments = new Set()) { | ||
return { | ||
possibleTypes, | ||
selections: selectionSetNode.selections | ||
.map(selectionNode => wrapInBooleanConditionsIfNeeded(this.compileSelection(selectionNode, parentType, possibleTypes, visitedFragments, isClient), selectionNode, possibleTypes)) | ||
.map(selectionNode => wrapInBooleanConditionsIfNeeded(this.compileSelection(selectionNode, parentType, possibleTypes, visitedFragments), selectionNode, possibleTypes)) | ||
.filter(x => x) | ||
}; | ||
} | ||
compileSelection(selectionNode, parentType, possibleTypes, visitedFragments, isClient) { | ||
compileSelection(selectionNode, parentType, possibleTypes, visitedFragments) { | ||
switch (selectionNode.kind) { | ||
case graphql_1.Kind.FIELD: { | ||
const fieldIsClient = (selectionNode.directives || []).some(d => d.name.value == "client"); | ||
const name = selectionNode.name.value; | ||
@@ -125,11 +124,2 @@ const alias = selectionNode.alias | ||
} | ||
if (fieldDef.astNode && | ||
fieldDef.astNode.__client && | ||
!(isClient || fieldIsClient)) { | ||
throw new graphql_1.GraphQLError(`Cannot query client-side field "${name}" on type "${String(parentType)}" without @client directive`, [selectionNode]); | ||
} | ||
if (!(fieldDef.astNode && fieldDef.astNode.__client) && | ||
fieldIsClient) { | ||
throw new graphql_1.GraphQLError(`Cannot query server-side field "${name}" on type "${String(parentType)}" with @client directive`, [selectionNode]); | ||
} | ||
const fieldType = fieldDef.type; | ||
@@ -167,3 +157,3 @@ const unmodifiedFieldType = graphql_1.getNamedType(fieldType); | ||
} | ||
field.selectionSet = this.compileSelectionSet(selectionNode.selectionSet, unmodifiedFieldType, isClient || fieldIsClient); | ||
field.selectionSet = this.compileSelectionSet(selectionNode.selectionSet, unmodifiedFieldType); | ||
} | ||
@@ -181,3 +171,3 @@ return field; | ||
type, | ||
selectionSet: this.compileSelectionSet(selectionNode.selectionSet, type, isClient, possibleTypesForTypeCondition) | ||
selectionSet: this.compileSelectionSet(selectionNode.selectionSet, type, possibleTypesForTypeCondition) | ||
}; | ||
@@ -184,0 +174,0 @@ } |
@@ -79,1 +79,2 @@ import { GraphQLSchema, GraphQLType, GraphQLObjectType, GraphQLCompositeType, GraphQLInputType, DocumentNode } from "graphql"; | ||
export declare function compileToLegacyIR(schema: GraphQLSchema, document: DocumentNode, options?: CompilerOptions): LegacyCompilerContext; | ||
//# sourceMappingURL=legacyIR.d.ts.map |
@@ -9,1 +9,2 @@ import { SelectionSet, Selection, Field, BooleanCondition } from "../"; | ||
export declare function wrapInBooleanConditionsIfNeeded(selections: Selection[], conditions?: BooleanCondition[]): Selection[]; | ||
//# sourceMappingURL=collectAndMergeFields.d.ts.map |
@@ -5,1 +5,2 @@ import { SelectionSet, Fragment } from "../"; | ||
}, fragmentsReferenced?: Set<string>): Set<string>; | ||
//# sourceMappingURL=collectFragmentsReferenced.d.ts.map |
@@ -8,1 +8,2 @@ import { Operation, Fragment } from "../"; | ||
}; | ||
//# sourceMappingURL=generateOperationId.d.ts.map |
import { SelectionSet } from "../"; | ||
export declare function inlineRedundantTypeConditions(selectionSet: SelectionSet): SelectionSet; | ||
//# sourceMappingURL=inlineRedundantTypeConditions.d.ts.map |
@@ -24,1 +24,2 @@ import { GraphQLObjectType } from "graphql"; | ||
} | ||
//# sourceMappingURL=typeCase.d.ts.map |
import "./polyfills"; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import "./polyfills"; | ||
import "apollo-env"; | ||
import { DocumentNode, GraphQLSchema, OperationDefinitionNode, FragmentDefinitionNode } from "graphql"; | ||
@@ -16,1 +16,2 @@ export declare function loadSchema(schemaPath: string): GraphQLSchema; | ||
export declare function combineOperationsAndFragments(operations: Array<OperationDefinitionNode>, fragments: Record<string, FragmentDefinitionNode>, errorLogger?: (message: string) => void): DocumentNode[]; | ||
//# sourceMappingURL=loading.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
require("./polyfills"); | ||
require("apollo-env"); | ||
const localfs_1 = require("./localfs"); | ||
@@ -9,10 +9,10 @@ const common_tags_1 = require("common-tags"); | ||
const graphql_1 = require("graphql"); | ||
const errors_1 = require("./errors"); | ||
const apollo_language_server_1 = require("apollo-language-server"); | ||
function loadSchema(schemaPath) { | ||
if (!localfs_1.fs.existsSync(schemaPath)) { | ||
throw new errors_1.ToolError(`Cannot find GraphQL schema file: ${schemaPath}`); | ||
throw new apollo_language_server_1.ToolError(`Cannot find GraphQL schema file: ${schemaPath}`); | ||
} | ||
const schemaData = require(schemaPath); | ||
if (!schemaData.data && !schemaData.__schema) { | ||
throw new errors_1.ToolError("GraphQL schema file should contain a valid GraphQL introspection query result"); | ||
throw new apollo_language_server_1.ToolError("GraphQL schema file should contain a valid GraphQL introspection query result"); | ||
} | ||
@@ -19,0 +19,0 @@ return graphql_1.buildClientSchema(schemaData.data ? schemaData.data : schemaData); |
export declare const fs: any; | ||
export declare function withGlobalFS<T>(thunk: () => T): T; | ||
//# sourceMappingURL=localfs.d.ts.map |
import { LegacyCompilerContext } from "./compiler/legacyIR"; | ||
export default function serializeToJSON(context: LegacyCompilerContext): string; | ||
export declare function serializeAST(ast: any, space?: string): string; | ||
//# sourceMappingURL=serializeToJSON.d.ts.map |
@@ -7,1 +7,2 @@ declare global { | ||
export declare function maybePush<T = any>(list: T[], item: T): T[]; | ||
//# sourceMappingURL=array.d.ts.map |
@@ -41,1 +41,2 @@ export interface BasicGeneratedFile { | ||
} | ||
//# sourceMappingURL=CodeGenerator.d.ts.map |
@@ -23,1 +23,2 @@ import { GraphQLCompositeType, GraphQLObjectType, GraphQLEnumValue, GraphQLSchema, GraphQLType, ASTNode, Location, ValueNode, OperationDefinitionNode, FieldNode, GraphQLField, DocumentNode } from "graphql"; | ||
export declare function getFieldDef(schema: GraphQLSchema, parentType: GraphQLCompositeType, fieldAST: FieldNode): GraphQLField<any, any> | undefined; | ||
//# sourceMappingURL=graphql.d.ts.map |
@@ -9,4 +9,3 @@ "use strict"; | ||
function isList(type) { | ||
return (type instanceof graphql_1.GraphQLList || | ||
(type instanceof graphql_1.GraphQLNonNull && type.ofType instanceof graphql_1.GraphQLList)); | ||
return graphql_1.isListType(type) || (graphql_1.isNonNullType(type) && graphql_1.isListType(type.ofType)); | ||
} | ||
@@ -13,0 +12,0 @@ exports.isList = isList; |
@@ -6,1 +6,2 @@ export declare function join(maybeArray?: any[], separator?: string): string; | ||
export declare function commentBlockContent(commentString: string): string; | ||
//# sourceMappingURL=printing.d.ts.map |
{ | ||
"name": "apollo-codegen-core", | ||
"description": "Core generator APIs for Apollo Codegen", | ||
"version": "0.29.0-register.0+36a3f2e", | ||
"version": "1.0.0-alpha.80+1a53960", | ||
"author": "Apollo GraphQL <opensource@apollographql.com>", | ||
@@ -9,14 +9,8 @@ "license": "MIT", | ||
"type": "git", | ||
"url": "git+https://github.com/apollographql/apollo-cli.git" | ||
"url": "git+https://github.com/apollographql/apollo-tooling.git" | ||
}, | ||
"homepage": "https://github.com/apollographql/apollo-cli", | ||
"bugs": "https://github.com/apollographql/apollo-cli/issues", | ||
"homepage": "https://github.com/apollographql/apollo-tooling", | ||
"bugs": "https://github.com/apollographql/apollo-tooling/issues", | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"scripts": { | ||
"clean": "rm -rf lib", | ||
"prebuild": "npm run clean", | ||
"build": "tsc", | ||
"prepare": "npm run build" | ||
}, | ||
"engines": { | ||
@@ -27,14 +21,20 @@ "node": ">=8", | ||
"dependencies": { | ||
"@babel/generator": "7.0.0-beta.38", | ||
"@babel/parser": "^7.0.0", | ||
"@babel/types": "7.0.0-beta.38", | ||
"ast-types": "^0.11.5", | ||
"@babel/generator": "7.1.3", | ||
"@babel/parser": "^7.1.3", | ||
"@babel/types": "7.1.3", | ||
"apollo-env": "0.1.0", | ||
"apollo-language-server": "1.0.0-alpha.80+1a53960", | ||
"ast-types": "^0.11.6", | ||
"common-tags": "^1.5.1", | ||
"core-js": "^2.5.3", | ||
"recast": "^0.15.3" | ||
}, | ||
"jest": { | ||
"preset": "ts-jest", | ||
"transformIgnorePatterns": [ | ||
"/node_modules/", | ||
"/apollo-env/" | ||
], | ||
"testEnvironment": "node", | ||
"setupFiles": [ | ||
"<rootDir>/src/polyfills.ts" | ||
"<rootDir>/../apollo-env/lib/index.js" | ||
], | ||
@@ -51,5 +51,2 @@ "setupTestFrameworkScriptFile": "<rootDir>/test-utils/matchers.ts", | ||
], | ||
"transform": { | ||
"^.+\\.(ts|js)x?$": "<rootDir>../../node_modules/ts-jest/preprocessor.js" | ||
}, | ||
"moduleFileExtensions": [ | ||
@@ -61,8 +58,8 @@ "ts", | ||
"ts-jest": { | ||
"skipBabel": true, | ||
"tsConfigFile": "tsconfig.test.json" | ||
"tsConfig": "<rootDir>/tsconfig.test.json", | ||
"diagnostics": false | ||
} | ||
} | ||
}, | ||
"gitHead": "36a3f2edab15c1ba5ffdf67c7fe2b5797264a730" | ||
"gitHead": "1a53960af3bc8e081ba98f6a5537fc6ce6380082" | ||
} |
@@ -7,3 +7,3 @@ import { GraphQLSchema, buildSchema, parse } from "graphql"; | ||
const starWarsSchema = loadSchema( | ||
require.resolve("../../../common-test/fixtures/starwars/schema.json") | ||
require.resolve("../../../../__fixtures__/starwars/schema.json") | ||
); | ||
@@ -10,0 +10,0 @@ |
@@ -66,6 +66,3 @@ import { stripIndents } from "common-tags"; | ||
const inputPaths = [ | ||
path.join( | ||
__dirname, | ||
"../../../common-test/fixtures/starwars/gqlQueries.js" | ||
) | ||
path.join(__dirname, "../../../../__fixtures__/starwars/gqlQueries.js") | ||
]; | ||
@@ -72,0 +69,0 @@ |
@@ -151,3 +151,3 @@ import { | ||
case Kind.FRAGMENT_DEFINITION: | ||
const fragment = compiler.compileFragment(definition, false); | ||
const fragment = compiler.compileFragment(definition); | ||
fragments[fragment.fragmentName] = fragment; | ||
@@ -252,4 +252,3 @@ break; | ||
operationDefinition.selectionSet, | ||
rootType, | ||
false | ||
rootType | ||
) | ||
@@ -259,6 +258,3 @@ }; | ||
compileFragment( | ||
fragmentDefinition: FragmentDefinitionNode, | ||
isClient: boolean | ||
): Fragment { | ||
compileFragment(fragmentDefinition: FragmentDefinitionNode): Fragment { | ||
const fragmentName = fragmentDefinition.name.value; | ||
@@ -281,4 +277,3 @@ | ||
fragmentDefinition.selectionSet, | ||
type, | ||
isClient | ||
type | ||
) | ||
@@ -291,3 +286,2 @@ }; | ||
parentType: GraphQLCompositeType, | ||
isClient: boolean, | ||
possibleTypes: GraphQLObjectType[] = this.possibleTypesForType(parentType), | ||
@@ -305,4 +299,3 @@ visitedFragments: Set<string> = new Set() | ||
possibleTypes, | ||
visitedFragments, | ||
isClient | ||
visitedFragments | ||
), | ||
@@ -321,10 +314,6 @@ selectionNode, | ||
possibleTypes: GraphQLObjectType[], | ||
visitedFragments: Set<string>, | ||
isClient: boolean | ||
visitedFragments: Set<string> | ||
): Selection | null { | ||
switch (selectionNode.kind) { | ||
case Kind.FIELD: { | ||
const fieldIsClient = (selectionNode.directives || []).some( | ||
d => d.name.value == "client" | ||
); | ||
const name = selectionNode.name.value; | ||
@@ -343,27 +332,2 @@ const alias = selectionNode.alias | ||
if ( | ||
fieldDef.astNode && | ||
(fieldDef.astNode as any).__client && | ||
!(isClient || fieldIsClient) | ||
) { | ||
throw new GraphQLError( | ||
`Cannot query client-side field "${name}" on type "${String( | ||
parentType | ||
)}" without @client directive`, | ||
[selectionNode] | ||
); | ||
} | ||
if ( | ||
!(fieldDef.astNode && (fieldDef.astNode as any).__client) && | ||
fieldIsClient | ||
) { | ||
throw new GraphQLError( | ||
`Cannot query server-side field "${name}" on type "${String( | ||
parentType | ||
)}" with @client directive`, | ||
[selectionNode] | ||
); | ||
} | ||
const fieldType = fieldDef.type; | ||
@@ -419,4 +383,3 @@ const unmodifiedFieldType = getNamedType(fieldType); | ||
selectionNode.selectionSet as SelectionSetNode, | ||
unmodifiedFieldType, | ||
isClient || fieldIsClient | ||
unmodifiedFieldType | ||
); | ||
@@ -440,3 +403,2 @@ } | ||
type, | ||
isClient, | ||
possibleTypesForTypeCondition | ||
@@ -443,0 +405,0 @@ ) |
@@ -6,3 +6,3 @@ import { parse, GraphQLSchema } from "graphql"; | ||
export const starWarsSchema = loadSchema( | ||
require.resolve("../../../../../../common-test/fixtures/starwars/schema.json") | ||
require.resolve("../../../../../../../__fixtures__/starwars/schema.json") | ||
); | ||
@@ -9,0 +9,0 @@ |
@@ -1,3 +0,2 @@ | ||
// provides flatMap | ||
import "./polyfills"; | ||
import "apollo-env"; | ||
@@ -22,3 +21,3 @@ import { fs } from "./localfs"; | ||
import { ToolError } from "./errors"; | ||
import { ToolError } from "apollo-language-server"; | ||
@@ -25,0 +24,0 @@ export function loadSchema(schemaPath: string): GraphQLSchema { |
@@ -24,6 +24,6 @@ import { | ||
GraphQLField, | ||
GraphQLList, | ||
GraphQLNonNull, | ||
DocumentNode, | ||
DirectiveNode | ||
DirectiveNode, | ||
isListType, | ||
isNonNullType | ||
} from "graphql"; | ||
@@ -45,6 +45,3 @@ | ||
export function isList(type: GraphQLType): boolean { | ||
return ( | ||
type instanceof GraphQLList || | ||
(type instanceof GraphQLNonNull && type.ofType instanceof GraphQLList) | ||
); | ||
return isListType(type) || (isNonNullType(type) && isListType(type.ofType)); | ||
} | ||
@@ -51,0 +48,0 @@ |
{ | ||
"extends": "../../tsconfig.base", | ||
"compilerOptions": { | ||
"declaration": true, | ||
"outDir": "lib" | ||
"rootDir": "./src", | ||
"outDir": "./lib" | ||
}, | ||
"include" : [ "src/**/*" ], | ||
"exclude": [ "**/__tests__/*" ] | ||
"include": ["./src/**/*"], | ||
"exclude": ["**/__tests__/*", "**/__mocks__/*"], | ||
"references": [{ "path": "../apollo-language-server" }] | ||
} |
{ | ||
"extends": "../../tsconfig.base", | ||
"compilerOptions": { | ||
"allowJs": true | ||
}, | ||
"include" : [ "src/**/*" ], | ||
"exclude": [ "**/__tests__/*" ] | ||
"extends": "../../tsconfig.test.base", | ||
"include": ["**/__tests__/*", "**/__mocks__/*"] | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
276779
96
2
1
8
5882
+ Addedapollo-env@0.1.0
+ Added@babel/generator@7.1.3(transitive)
+ Added@babel/types@7.1.3(transitive)
+ Addedapollo-env@0.1.0(transitive)
+ Addedcore-js@3.39.0(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)
- Removedcore-js@^2.5.3
- Removed@babel/generator@7.0.0-beta.38(transitive)
- Removed@babel/types@7.0.0-beta.38(transitive)
- Removedcore-js@2.6.12(transitive)
Updated@babel/generator@7.1.3
Updated@babel/parser@^7.1.3
Updated@babel/types@7.1.3
Updatedast-types@^0.11.6