Skip to content
This repository has been archived by the owner on Oct 2, 2024. It is now read-only.

Commit

Permalink
Merge pull request #252 from comigor/bugfix/multiple-query-inclusion-…
Browse files Browse the repository at this point in the history
…in-document-query

bugfix > multiple query inclusion in documnet
  • Loading branch information
comigor authored Jan 16, 2021
2 parents 951dedd + 0066e8a commit 2745d16
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 99 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# CHANGELOG

## 6.18.3
- fix for the case when multiple documents were included in request https://github.com/comigor/artemis/issues/251

## 6.18.2
- Merging beta into master

Expand Down
13 changes: 8 additions & 5 deletions lib/generator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -217,17 +217,20 @@ Iterable<QueryDefinition> generateDefinitions(
context: context,
);

DocumentNode(
final filteredDefinition = DocumentNode(
definitions: document.definitions
// filtering unused operations
.where((e) => e is! OperationDefinitionNode || e == operation)
.toList(),
).accept(visitor);
.where((e) {
return e is! OperationDefinitionNode || e == operation;
}).toList(),
);

filteredDefinition.accept(visitor);

return QueryDefinition(
name: name,
operationName: operationName,
document: document,
document: filteredDefinition,
classes: [
...canonicalVisitor.enums
.where((e) => context.usedEnums.contains(e.name)),
Expand Down
4 changes: 2 additions & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: artemis
version: 6.18.2
version: 6.18.3

description: Build dart types from GraphQL schemas and queries (using Introspection Query).
homepage: https://github.com/comigor/artemis
Expand All @@ -9,7 +9,7 @@ environment:

dependencies:
build_config: ^0.4.5
build: ^1.6.0
build: ^1.6.1
code_builder: ^3.5.0
collection: ^1.14.13
dart_style: ^1.3.10
Expand Down
92 changes: 0 additions & 92 deletions test/query_generator/multiple_operations_per_file_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -302,67 +302,6 @@ class MutDataMutation extends GraphQLQuery<MutData$Mutation, MutDataArguments> {
directives: [],
selectionSet: null)
]))
])),
OperationDefinitionNode(
type: OperationType.query,
name: NameNode(value: 'QueData'),
variableDefinitions: [
VariableDefinitionNode(
variable: VariableNode(name: NameNode(value: 'intsNonNullable')),
type: ListTypeNode(
type: NamedTypeNode(
name: NameNode(value: 'Int'), isNonNull: false),
isNonNull: true),
defaultValue: DefaultValueNode(value: null),
directives: []),
VariableDefinitionNode(
variable: VariableNode(name: NameNode(value: 'stringNullable')),
type: NamedTypeNode(
name: NameNode(value: 'String'), isNonNull: false),
defaultValue: DefaultValueNode(value: null),
directives: [])
],
directives: [],
selectionSet: SelectionSetNode(selections: [
FieldNode(
name: NameNode(value: 'que'),
alias: null,
arguments: [
ArgumentNode(
name: NameNode(value: 'intsNonNullable'),
value:
VariableNode(name: NameNode(value: 'intsNonNullable'))),
ArgumentNode(
name: NameNode(value: 'stringNullable'),
value:
VariableNode(name: NameNode(value: 'stringNullable')))
],
directives: [],
selectionSet: SelectionSetNode(selections: [
FieldNode(
name: NameNode(value: 's'),
alias: null,
arguments: [],
directives: [],
selectionSet: null),
FieldNode(
name: NameNode(value: 'i'),
alias: null,
arguments: [],
directives: [],
selectionSet: null),
FieldNode(
name: NameNode(value: 'list'),
alias: null,
arguments: [
ArgumentNode(
name: NameNode(value: 'intsNonNullable'),
value: VariableNode(
name: NameNode(value: 'intsNonNullable')))
],
directives: [],
selectionSet: null)
]))
]))
]);
Expand Down Expand Up @@ -402,37 +341,6 @@ class QueDataQuery extends GraphQLQuery<QueData$Query, QueDataArguments> {
@override
final DocumentNode document = DocumentNode(definitions: [
OperationDefinitionNode(
type: OperationType.mutation,
name: NameNode(value: 'MutData'),
variableDefinitions: [
VariableDefinitionNode(
variable: VariableNode(name: NameNode(value: 'input')),
type: NamedTypeNode(
name: NameNode(value: 'Input'), isNonNull: true),
defaultValue: DefaultValueNode(value: null),
directives: [])
],
directives: [],
selectionSet: SelectionSetNode(selections: [
FieldNode(
name: NameNode(value: 'mut'),
alias: null,
arguments: [
ArgumentNode(
name: NameNode(value: 'input'),
value: VariableNode(name: NameNode(value: 'input')))
],
directives: [],
selectionSet: SelectionSetNode(selections: [
FieldNode(
name: NameNode(value: 's'),
alias: null,
arguments: [],
directives: [],
selectionSet: null)
]))
])),
OperationDefinitionNode(
type: OperationType.query,
name: NameNode(value: 'QueData'),
Expand Down

0 comments on commit 2745d16

Please sign in to comment.