-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'project-breakup' into feature/defer
# Conflicts: # apollo-ios-codegen/Sources/GraphQLCompiler/ApolloCodegenFrontendBundle.swift
- Loading branch information
Showing
13 changed files
with
1,743 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
apollo-ios-codegen/Sources/GraphQLCompiler/ApolloCodegenFrontendBundle.swift
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
apollo-ios-codegen/Sources/GraphQLCompiler/JavaScript/dist/ApolloCodegenFrontend.bundle.js
This file was deleted.
Oops, something went wrong.
194 changes: 194 additions & 0 deletions
194
...-ios-codegen/Sources/GraphQLCompiler/JavaScript/src/__tests__/referencedFragmentsTests.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,194 @@ | ||
import { | ||
compileDocument, | ||
parseOperationDocument, | ||
loadSchemaFromSources, | ||
mergeDocuments, | ||
} from "../index" | ||
import { | ||
CompilationResult | ||
} from "../compiler/index" | ||
import { | ||
FragmentDefinition, | ||
OperationDefinition | ||
} from "../compiler/ir" | ||
import { | ||
Source, | ||
GraphQLSchema, | ||
DocumentNode | ||
} from "graphql"; | ||
import { emptyValidationOptions } from "../__testUtils__/validationHelpers"; | ||
|
||
describe("operation with referencedFragments", () => { | ||
const operationADocument: DocumentNode = parseOperationDocument( | ||
new Source( ` | ||
query OperationA { | ||
...FragmentA | ||
...FragmentC | ||
} | ||
`, "OperationA", { line: 1, column: 1 }), | ||
false | ||
); | ||
|
||
const fragmentADocument: DocumentNode = parseOperationDocument( | ||
new Source( ` | ||
fragment FragmentA on Query { | ||
a | ||
...FragmentB | ||
} | ||
`, "FragmentA", { line: 1, column: 1 }), | ||
false | ||
); | ||
|
||
const fragmentBDocument: DocumentNode = parseOperationDocument( | ||
new Source( ` | ||
fragment FragmentB on Query { | ||
b | ||
} | ||
`, "FragmentB", { line: 1, column: 1 }), | ||
false | ||
); | ||
|
||
const fragmentCDocument: DocumentNode = parseOperationDocument( | ||
new Source( ` | ||
fragment FragmentC on Query { | ||
c | ||
} | ||
`, "FragmentC", { line: 1, column: 1 }), | ||
false | ||
); | ||
|
||
const schema: GraphQLSchema = loadSchemaFromSources([new Source(` | ||
type Query { | ||
a: String! | ||
b: String! | ||
c: String! | ||
} | ||
`, | ||
"Test Schema", { line: 1, column: 1 })]); | ||
|
||
const document: DocumentNode = mergeDocuments([ | ||
operationADocument, | ||
fragmentADocument, | ||
fragmentBDocument, | ||
fragmentCDocument]) | ||
|
||
const compilationResult: CompilationResult = compileDocument(schema, document, false, emptyValidationOptions); | ||
|
||
const operationA: OperationDefinition = compilationResult.operations.find(function(element) { | ||
return element.name == 'OperationA' | ||
}) as OperationDefinition | ||
|
||
const fragmentA: FragmentDefinition = compilationResult.fragments.find(function(element) { | ||
return element.name == 'FragmentA' | ||
}) as FragmentDefinition | ||
|
||
const fragmentB: FragmentDefinition = compilationResult.fragments.find(function(element) { | ||
return element.name == 'FragmentB' | ||
}) as FragmentDefinition | ||
|
||
const fragmentC: FragmentDefinition = compilationResult.fragments.find(function(element) { | ||
return element.name == 'FragmentC' | ||
}) as FragmentDefinition | ||
|
||
it("compilation result OperationA should have referencedFragments including only directly referenced fragments.", () => { | ||
expect(operationA.referencedFragments).toEqual([fragmentA, fragmentC]) | ||
}); | ||
|
||
it("compilation result FragmentA should have referencedFragments including only directly referenced fragments.", () => { | ||
expect(fragmentA.referencedFragments).toEqual([fragmentB]) | ||
}); | ||
|
||
}); | ||
|
||
describe("operation with referencedFragments on child entity selection sets", () => { | ||
const operationADocument: DocumentNode = parseOperationDocument( | ||
new Source( ` | ||
query OperationA { | ||
a { | ||
...FragmentA | ||
} | ||
...FragmentC | ||
} | ||
`, "OperationA", { line: 1, column: 1 }), | ||
false | ||
); | ||
|
||
const fragmentADocument: DocumentNode = parseOperationDocument( | ||
new Source( ` | ||
fragment FragmentA on A { | ||
A | ||
b { | ||
...FragmentB | ||
} | ||
} | ||
`, "FragmentA", { line: 1, column: 1 }), | ||
false | ||
); | ||
|
||
const fragmentBDocument: DocumentNode = parseOperationDocument( | ||
new Source( ` | ||
fragment FragmentB on B { | ||
B | ||
} | ||
`, "FragmentB", { line: 1, column: 1 }), | ||
false | ||
); | ||
|
||
const fragmentCDocument: DocumentNode = parseOperationDocument( | ||
new Source( ` | ||
fragment FragmentC on Query { | ||
c | ||
} | ||
`, "FragmentC", { line: 1, column: 1 }), | ||
false | ||
); | ||
|
||
const schema: GraphQLSchema = loadSchemaFromSources([new Source(` | ||
type Query { | ||
a: A! | ||
b: B! | ||
c: String! | ||
} | ||
type A { | ||
A: String! | ||
b: B! | ||
} | ||
type B { | ||
B: String! | ||
} | ||
`, | ||
"Test Schema", { line: 1, column: 1 })]); | ||
|
||
const document: DocumentNode = mergeDocuments([ | ||
operationADocument, | ||
fragmentADocument, | ||
fragmentBDocument, | ||
fragmentCDocument]) | ||
|
||
const compilationResult: CompilationResult = compileDocument(schema, document, false, emptyValidationOptions); | ||
|
||
const operationA: OperationDefinition = compilationResult.operations.find(function(element) { | ||
return element.name == 'OperationA' | ||
}) as OperationDefinition | ||
|
||
const fragmentA: FragmentDefinition = compilationResult.fragments.find(function(element) { | ||
return element.name == 'FragmentA' | ||
}) as FragmentDefinition | ||
|
||
const fragmentB: FragmentDefinition = compilationResult.fragments.find(function(element) { | ||
return element.name == 'FragmentB' | ||
}) as FragmentDefinition | ||
|
||
const fragmentC: FragmentDefinition = compilationResult.fragments.find(function(element) { | ||
return element.name == 'FragmentC' | ||
}) as FragmentDefinition | ||
|
||
it("compilation result OperationA should have referencedFragments including only directly referenced fragments.", () => { | ||
expect(operationA.referencedFragments).toEqual([fragmentA, fragmentC]) | ||
}); | ||
|
||
it("compilation result FragmentA should have referencedFragments including only directly referenced fragments.", () => { | ||
expect(fragmentA.referencedFragments).toEqual([fragmentB]) | ||
}); | ||
|
||
}); |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.