Skip to content

Commit

Permalink
fix: Issue 318
Browse files Browse the repository at this point in the history
  • Loading branch information
budde377 committed Nov 19, 2023
1 parent 245779a commit 0ee26d4
Show file tree
Hide file tree
Showing 11 changed files with 673 additions and 13 deletions.
4 changes: 4 additions & 0 deletions packages/graphql_codegen/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.13.8

- Fix bug in asset path resolution.

# 0.13.7

- Support `.graphqls` files
Expand Down
39 changes: 27 additions & 12 deletions packages/graphql_codegen/lib/builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -171,19 +171,34 @@ class GraphQLBuilder extends Builder {
),
);
}
return Map.fromEntries(
kGraphQLFileExtensions.map(
(e) => MapEntry(
p.join(_assetsPrefix, '{{dir}}', '{{file}}.${e}'),
[
p.join(
p.relative(config.outputDirectory, from: '/'),
'{{dir}}',
'{{file}}.${e}.dart',
)
],
return {
...Map.fromEntries(
kGraphQLFileExtensions.map(
(e) => MapEntry(
p.join(_assetsPrefix, '{{dir}}', '{{file}}.${e}'),
[
p.join(
p.relative(config.outputDirectory, from: '/'),
'{{dir}}',
'{{file}}.${e}.dart',
)
],
),
),
),
);
...Map.fromEntries(
kGraphQLFileExtensions.map(
(e) => MapEntry(
p.join(_assetsPrefix, '{{file}}.${e}'),
[
p.join(
p.relative(config.outputDirectory, from: '/'),
'{{file}}.${e}.dart',
)
],
),
),
)
};
}
}
2 changes: 1 addition & 1 deletion packages/graphql_codegen/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: |
Simple, opinionated, codegen library for GraphQL. It allows you to
generate serializers and client helpers to easily call and parse your data.
version: 0.13.7
version: 0.13.8
homepage: https://github.com/heftapp/graphql_codegen/tree/main/packages/graphql_codegen
repository: https://github.com/heftapp/graphql_codegen/tree/main/packages/graphql_codegen

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"noFlatLib": true
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type Query {
hello: String
}

query FetchHello {
hello
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type Query {
hello: String
}

query FetchHello {
hello
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type Query {
hello: String
}

query FetchHello {
hello
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
import 'package:gql/ast.dart';

class Query$FetchHello {
Query$FetchHello({
this.hello,
this.$__typename = 'Query',
});

factory Query$FetchHello.fromJson(Map<String, dynamic> json) {
final l$hello = json['hello'];
final l$$__typename = json['__typename'];
return Query$FetchHello(
hello: (l$hello as String?),
$__typename: (l$$__typename as String),
);
}

final String? hello;

final String $__typename;

Map<String, dynamic> toJson() {
final _resultData = <String, dynamic>{};
final l$hello = hello;
_resultData['hello'] = l$hello;
final l$$__typename = $__typename;
_resultData['__typename'] = l$$__typename;
return _resultData;
}

@override
int get hashCode {
final l$hello = hello;
final l$$__typename = $__typename;
return Object.hashAll([
l$hello,
l$$__typename,
]);
}

@override
bool operator ==(Object other) {
if (identical(this, other)) {
return true;
}
if (!(other is Query$FetchHello) || runtimeType != other.runtimeType) {
return false;
}
final l$hello = hello;
final lOther$hello = other.hello;
if (l$hello != lOther$hello) {
return false;
}
final l$$__typename = $__typename;
final lOther$$__typename = other.$__typename;
if (l$$__typename != lOther$$__typename) {
return false;
}
return true;
}
}

extension UtilityExtension$Query$FetchHello on Query$FetchHello {
CopyWith$Query$FetchHello<Query$FetchHello> get copyWith =>
CopyWith$Query$FetchHello(
this,
(i) => i,
);
}

abstract class CopyWith$Query$FetchHello<TRes> {
factory CopyWith$Query$FetchHello(
Query$FetchHello instance,
TRes Function(Query$FetchHello) then,
) = _CopyWithImpl$Query$FetchHello;

factory CopyWith$Query$FetchHello.stub(TRes res) =
_CopyWithStubImpl$Query$FetchHello;

TRes call({
String? hello,
String? $__typename,
});
}

class _CopyWithImpl$Query$FetchHello<TRes>
implements CopyWith$Query$FetchHello<TRes> {
_CopyWithImpl$Query$FetchHello(
this._instance,
this._then,
);

final Query$FetchHello _instance;

final TRes Function(Query$FetchHello) _then;

static const _undefined = <dynamic, dynamic>{};

TRes call({
Object? hello = _undefined,
Object? $__typename = _undefined,
}) =>
_then(Query$FetchHello(
hello: hello == _undefined ? _instance.hello : (hello as String?),
$__typename: $__typename == _undefined || $__typename == null
? _instance.$__typename
: ($__typename as String),
));
}

class _CopyWithStubImpl$Query$FetchHello<TRes>
implements CopyWith$Query$FetchHello<TRes> {
_CopyWithStubImpl$Query$FetchHello(this._res);

TRes _res;

call({
String? hello,
String? $__typename,
}) =>
_res;
}

const documentNodeQueryFetchHello = DocumentNode(definitions: [
OperationDefinitionNode(
type: OperationType.query,
name: NameNode(value: 'FetchHello'),
variableDefinitions: [],
directives: [],
selectionSet: SelectionSetNode(selections: [
FieldNode(
name: NameNode(value: 'hello'),
alias: null,
arguments: [],
directives: [],
selectionSet: null,
),
FieldNode(
name: NameNode(value: '__typename'),
alias: null,
arguments: [],
directives: [],
selectionSet: null,
),
]),
),
]);
Loading

0 comments on commit 0ee26d4

Please sign in to comment.