Skip to content

Commit 8998b90

Browse files
authored
fix: Issue 318 (heftapp#319)
1 parent 245779a commit 8998b90

14 files changed

Lines changed: 676 additions & 16 deletions

File tree

packages/graphql_codegen/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 0.13.8
2+
3+
- Fix bug in asset path resolution.
4+
15
# 0.13.7
26

37
- Support `.graphqls` files

packages/graphql_codegen/example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ packages:
329329
path: ".."
330330
relative: true
331331
source: path
332-
version: "0.13.7"
332+
version: "0.13.8"
333333
graphql_flutter:
334334
dependency: "direct main"
335335
description:

packages/graphql_codegen/lib/builder.dart

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -171,19 +171,34 @@ class GraphQLBuilder extends Builder {
171171
),
172172
);
173173
}
174-
return Map.fromEntries(
175-
kGraphQLFileExtensions.map(
176-
(e) => MapEntry(
177-
p.join(_assetsPrefix, '{{dir}}', '{{file}}.${e}'),
178-
[
179-
p.join(
180-
p.relative(config.outputDirectory, from: '/'),
181-
'{{dir}}',
182-
'{{file}}.${e}.dart',
183-
)
184-
],
174+
return {
175+
...Map.fromEntries(
176+
kGraphQLFileExtensions.map(
177+
(e) => MapEntry(
178+
p.join(_assetsPrefix, '{{dir}}', '{{file}}.${e}'),
179+
[
180+
p.join(
181+
p.relative(config.outputDirectory, from: '/'),
182+
'{{dir}}',
183+
'{{file}}.${e}.dart',
184+
)
185+
],
186+
),
185187
),
186188
),
187-
);
189+
...Map.fromEntries(
190+
kGraphQLFileExtensions.map(
191+
(e) => MapEntry(
192+
p.join(_assetsPrefix, '{{file}}.${e}'),
193+
[
194+
p.join(
195+
p.relative(config.outputDirectory, from: '/'),
196+
'{{file}}.${e}.dart',
197+
)
198+
],
199+
),
200+
),
201+
)
202+
};
188203
}
189204
}

packages/graphql_codegen/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: |
33
Simple, opinionated, codegen library for GraphQL. It allows you to
44
generate serializers and client helpers to easily call and parse your data.
55
6-
version: 0.13.7
6+
version: 0.13.8
77
homepage: https://github.com/heftapp/graphql_codegen/tree/main/packages/graphql_codegen
88
repository: https://github.com/heftapp/graphql_codegen/tree/main/packages/graphql_codegen
99

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"noFlatLib": true
3+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
type Query {
2+
hello: String
3+
}
4+
5+
query FetchHello {
6+
hello
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
type Query {
2+
hello: String
3+
}
4+
5+
query FetchHello {
6+
hello
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
type Query {
2+
hello: String
3+
}
4+
5+
query FetchHello {
6+
hello
7+
}
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
import 'package:gql/ast.dart';
2+
3+
class Query$FetchHello {
4+
Query$FetchHello({
5+
this.hello,
6+
this.$__typename = 'Query',
7+
});
8+
9+
factory Query$FetchHello.fromJson(Map<String, dynamic> json) {
10+
final l$hello = json['hello'];
11+
final l$$__typename = json['__typename'];
12+
return Query$FetchHello(
13+
hello: (l$hello as String?),
14+
$__typename: (l$$__typename as String),
15+
);
16+
}
17+
18+
final String? hello;
19+
20+
final String $__typename;
21+
22+
Map<String, dynamic> toJson() {
23+
final _resultData = <String, dynamic>{};
24+
final l$hello = hello;
25+
_resultData['hello'] = l$hello;
26+
final l$$__typename = $__typename;
27+
_resultData['__typename'] = l$$__typename;
28+
return _resultData;
29+
}
30+
31+
@override
32+
int get hashCode {
33+
final l$hello = hello;
34+
final l$$__typename = $__typename;
35+
return Object.hashAll([
36+
l$hello,
37+
l$$__typename,
38+
]);
39+
}
40+
41+
@override
42+
bool operator ==(Object other) {
43+
if (identical(this, other)) {
44+
return true;
45+
}
46+
if (!(other is Query$FetchHello) || runtimeType != other.runtimeType) {
47+
return false;
48+
}
49+
final l$hello = hello;
50+
final lOther$hello = other.hello;
51+
if (l$hello != lOther$hello) {
52+
return false;
53+
}
54+
final l$$__typename = $__typename;
55+
final lOther$$__typename = other.$__typename;
56+
if (l$$__typename != lOther$$__typename) {
57+
return false;
58+
}
59+
return true;
60+
}
61+
}
62+
63+
extension UtilityExtension$Query$FetchHello on Query$FetchHello {
64+
CopyWith$Query$FetchHello<Query$FetchHello> get copyWith =>
65+
CopyWith$Query$FetchHello(
66+
this,
67+
(i) => i,
68+
);
69+
}
70+
71+
abstract class CopyWith$Query$FetchHello<TRes> {
72+
factory CopyWith$Query$FetchHello(
73+
Query$FetchHello instance,
74+
TRes Function(Query$FetchHello) then,
75+
) = _CopyWithImpl$Query$FetchHello;
76+
77+
factory CopyWith$Query$FetchHello.stub(TRes res) =
78+
_CopyWithStubImpl$Query$FetchHello;
79+
80+
TRes call({
81+
String? hello,
82+
String? $__typename,
83+
});
84+
}
85+
86+
class _CopyWithImpl$Query$FetchHello<TRes>
87+
implements CopyWith$Query$FetchHello<TRes> {
88+
_CopyWithImpl$Query$FetchHello(
89+
this._instance,
90+
this._then,
91+
);
92+
93+
final Query$FetchHello _instance;
94+
95+
final TRes Function(Query$FetchHello) _then;
96+
97+
static const _undefined = <dynamic, dynamic>{};
98+
99+
TRes call({
100+
Object? hello = _undefined,
101+
Object? $__typename = _undefined,
102+
}) =>
103+
_then(Query$FetchHello(
104+
hello: hello == _undefined ? _instance.hello : (hello as String?),
105+
$__typename: $__typename == _undefined || $__typename == null
106+
? _instance.$__typename
107+
: ($__typename as String),
108+
));
109+
}
110+
111+
class _CopyWithStubImpl$Query$FetchHello<TRes>
112+
implements CopyWith$Query$FetchHello<TRes> {
113+
_CopyWithStubImpl$Query$FetchHello(this._res);
114+
115+
TRes _res;
116+
117+
call({
118+
String? hello,
119+
String? $__typename,
120+
}) =>
121+
_res;
122+
}
123+
124+
const documentNodeQueryFetchHello = DocumentNode(definitions: [
125+
OperationDefinitionNode(
126+
type: OperationType.query,
127+
name: NameNode(value: 'FetchHello'),
128+
variableDefinitions: [],
129+
directives: [],
130+
selectionSet: SelectionSetNode(selections: [
131+
FieldNode(
132+
name: NameNode(value: 'hello'),
133+
alias: null,
134+
arguments: [],
135+
directives: [],
136+
selectionSet: null,
137+
),
138+
FieldNode(
139+
name: NameNode(value: '__typename'),
140+
alias: null,
141+
arguments: [],
142+
directives: [],
143+
selectionSet: null,
144+
),
145+
]),
146+
),
147+
]);

0 commit comments

Comments
 (0)