-
Notifications
You must be signed in to change notification settings - Fork 738
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SelectionSet Codegen __typename fix - Closes #2955 #2983
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,6 +46,7 @@ function filePathForNode(node: ASTNode): string | undefined { | |
} | ||
|
||
export interface CompilationResult { | ||
rootTypes: ir.RootTypeDefinition; | ||
operations: ir.OperationDefinition[]; | ||
fragments: ir.FragmentDefinition[]; | ||
referencedTypes: GraphQLNamedType[]; | ||
|
@@ -71,6 +72,17 @@ export function compileToIR( | |
const fragmentMap = new Map<String, ir.FragmentDefinition>(); | ||
const referencedTypes = new Set<GraphQLNamedType>(); | ||
|
||
const queryType = schema.getQueryType() as GraphQLNamedType; | ||
if (queryType === undefined) { | ||
throw new GraphQLError("GraphQL Schema must contain a 'query' root type definition.", { }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this we'd ever reach this stage. Since this is a spec violation it'll likely get caught by graphql-js validation before we start compiling the IR. |
||
} | ||
|
||
const rootTypes: ir.RootTypeDefinition = { | ||
queryType: queryType, | ||
mutationType: schema.getMutationType() ?? undefined, | ||
subscriptionType: schema.getSubscriptionType() ?? undefined | ||
}; | ||
|
||
for (const definitionNode of document.definitions) { | ||
if (definitionNode.kind !== Kind.OPERATION_DEFINITION) continue; | ||
|
||
|
@@ -86,7 +98,8 @@ export function compileToIR( | |
} | ||
|
||
return { | ||
operations, | ||
rootTypes: rootTypes, | ||
operations: operations, | ||
fragments: Array.from(fragmentMap.values()), | ||
referencedTypes: Array.from(referencedTypes.values()), | ||
schemaDocumentation: schema.description ?? undefined | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/usr/bin/env bash | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
output_file="$SCRIPT_DIR/ApolloCodegenFrontendBundle.swift" | ||
$( cd "$SCRIPT_DIR/Javascript" && rollup -c ) | ||
minJS=$(cat "$SCRIPT_DIR/dist/ApolloCodegenFrontend.bundle.js") | ||
printf "%s%s%s" "let ApolloCodegenFrontendBundle: String = #\"" "$minJS" "\"#" > $output_file | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nicely done! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻