Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import {
GraphQLString,
GraphQLInt,
GraphQLFloat,
GraphQLBoolean,
GraphQLID,
GraphQLList,
GraphQLNonNull,
GraphQLScalarType
} from "graphql";
import { loadSchema } from "apollo-codegen-core/lib/loading";
const schema = loadSchema(
require.resolve("../../../../__fixtures__/starwars/schema.json")
);
import { typeNameFromGraphQLType } from "../types";
describe("Scala code generation: Types", function() {
describe("#typeNameFromGraphQLType()", function() {
test("should return OptionalResult[String] for GraphQLString", function() {
expect(typeNameFromGraphQLType({ options: {} }, GraphQLString)).toBe(
"com.apollographql.scalajs.OptionalValue[String]"
);
});
test("should return String for GraphQLNonNull(GraphQLString)", function() {
expect(
typeNameFromGraphQLType(
import * as path from "path";
import {
loadSchema,
loadAndMergeQueryDocuments
} from "apollo-codegen-core/lib/loading";
import { validateQueryDocument } from "../validation";
const schema = loadSchema(
require.resolve("../../../../__fixtures__/starwars/schema.json")
);
describe("Validation", () => {
function loadQueryDocument(filename: string) {
return loadAndMergeQueryDocuments([
path.join(__dirname, "../../../../__fixtures__/starwars", filename)
]);
}
test(`should throw an error for AnonymousQuery.graphql`, () => {
const document = loadQueryDocument("AnonymousQuery.graphql");
expect(() => validateQueryDocument(schema, document)).toThrow(
"Validation of GraphQL query document failed"
);
test("handles multiline graphql comments", () => {
const miscSchema = loadSchema(
require.resolve("../../../../__fixtures__/misc/schema.json")
);
const document = parse(`
query CustomScalar {
commentTest {
multiLine
}
}
`);
const output = generateSource(
compileToIR(miscSchema, document, {
mergeInFieldsFromFragmentSpreads: true,
addTypename: true
})
import { parse } from "graphql";
import { generateSource } from "../codeGeneration";
import { loadSchema } from "apollo-codegen-core/lib/loading";
const starWarsSchema = loadSchema(
require.resolve("../../../../__fixtures__/starwars/schema.json")
);
const miscSchema = loadSchema(
require.resolve("../../../../__fixtures__/misc/schema.json")
);
import CodeGenerator from "apollo-codegen-core/lib/utilities/CodeGenerator";
import { compileToLegacyIR } from "apollo-codegen-core/lib/compiler/legacyIR";
describe("TypeScript code generation", function() {
let generator;
let compileFromSource;
let addFragment;
function setup(schema) {
const context = {
schema: schema,
operations: {},
import { parse } from "graphql";
import { generateSource } from "../codeGeneration";
import { loadSchema } from "apollo-codegen-core/lib/loading";
const starWarsSchema = loadSchema(
require.resolve("../../../../__fixtures__/starwars/schema.json")
);
const miscSchema = loadSchema(
require.resolve("../../../../__fixtures__/misc/schema.json")
);
import CodeGenerator from "apollo-codegen-core/lib/utilities/CodeGenerator";
import { compileToLegacyIR } from "apollo-codegen-core/lib/compiler/legacyIR";
describe("TypeScript code generation", function() {
let generator;
let compileFromSource;
let addFragment;
function setup(schema) {
import { parse } from "graphql";
import { generateSource } from "../codeGeneration";
import { loadSchema } from "apollo-codegen-core/lib/loading";
const starWarsSchema = loadSchema(
require.resolve("../../../../__fixtures__/starwars/schema.json")
);
const miscSchema = loadSchema(
require.resolve("../../../../__fixtures__/misc/schema.json")
);
import CodeGenerator from "apollo-codegen-core/lib/utilities/CodeGenerator";
import { compileToLegacyIR } from "apollo-codegen-core/lib/compiler/legacyIR";
function setup(schema) {
const context = {
schema: schema,
operations: {},
fragments: {},
typesUsed: {}
import { parse } from "graphql";
import { loadSchema } from "apollo-codegen-core/lib/loading";
const schema = loadSchema(
require.resolve("../../../../__fixtures__/starwars/schema.json")
);
const miscSchema = loadSchema(
require.resolve("../../../../__fixtures__/misc/schema.json")
);
import {
compileToIR,
CompilerOptions,
CompilerContext
} from "apollo-codegen-core/lib/compiler";
import {
generateSource,
generateLocalSource,
generateGlobalSource
import {
parse,
GraphQLNonNull,
GraphQLString,
GraphQLEnumType,
GraphQLList
} from "graphql";
import { loadSchema } from "apollo-codegen-core/lib/loading";
const schema = loadSchema(
require.resolve("../../../../__fixtures__/starwars/schema.json")
);
import {
compileToIR,
CompilerOptions,
CompilerContext,
SelectionSet,
Field,
Argument
} from "apollo-codegen-core/lib/compiler";
import { SwiftAPIGenerator } from "../codeGeneration";
describe("Swift code generation", () => {
let generator: SwiftAPIGenerator;
GraphQLNonNull,
GraphQLEnumType,
GraphQLCompositeType,
GraphQLObjectType
} from "graphql";
import {
generateSource,
classDeclarationForOperation,
traitDeclarationForFragment,
traitDeclarationForSelectionSet,
typeDeclarationForGraphQLType
} from "../codeGeneration";
import { loadSchema } from "apollo-codegen-core/lib/loading";
const schema = loadSchema(
require.resolve("../../../../__fixtures__/starwars/schema.json")
);
import CodeGenerator from "apollo-codegen-core/lib/utilities/CodeGenerator";
import {
compileToLegacyIR,
LegacyCompilerContext
} from "apollo-codegen-core/lib/compiler/legacyIR";
describe("Scala code generation", function() {
let generator;
let resetGenerator;
let compileFromSource;
let addFragment;
import { Source } from "graphql";
import { loadSchema } from "apollo-codegen-core/lib/loading";
import { GraphQLDocument } from "../document";
import { collectExecutableDefinitionDiagnositics } from "../diagnostics";
const schema = loadSchema(
require.resolve("../../../../__fixtures__/starwars/schema.json")
);
const validDocument = new GraphQLDocument(
new Source(`
query HeroAndFriendsNames {
hero {
name
friends {
name
}
}
}`)
);
const invalidDocument = new GraphQLDocument(
new Source(`
query HeroAndFriendsNames {