在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):comigor/artemis开源软件地址(OpenSource Url):https://github.com/comigor/artemis开源编程语言(OpenSource Language):Dart 100.0%开源软件介绍(OpenSource Introduction):ArtemisBuild dart types from GraphQL schemas and queries Check the beta branch for the bleeding edge (and breaking) stuff. Artemis is a code generator that looks for InstallationAdd the following to your dev_dependencies:
artemis: '>=6.0.0 <7.0.0'
build_runner: ^1.10.4
json_serializable: ^3.5.0 The generated code uses the following packages in run-time: dependencies:
artemis: '>=6.0.0 <7.0.0' # only if you're using ArtemisClient!
json_annotation: ^3.1.0
equatable: ^1.2.5
meta: '>=1.0.0 <2.0.0' # only if you have non nullable fields
gql: '>=0.12.3 <1.0.0' Then run: pub packages get or flutter packages get Now Artemis will generate the API files for you by running: pub run build_runner build or flutter pub run build_runner build ConfigurationArtemis offers some configuration options to generate code. All options should be included on targets:
$default:
builders:
artemis:
options:
# custom configuration options!
It's important to remember that, by default, build will follow Dart's package layout conventions, meaning that only some folders will be considered to parse the input files. So, if you want to reference files from a folder other than targets:
$default:
sources:
- lib/**
- graphql/**
- data/**
- schema.graphql Schema mappingBy default, Artemis won't generate anything. That's because your queries/mutations should be linked to GraphQL schemas. To configure it, you need to point a targets:
$default:
builders:
artemis:
options:
schema_mapping:
- output: lib/graphql_api.dart
schema: lib/my_graphql_schema.graphql
queries_glob: lib/**.graphql Each
See examples for more information and configuration options. Custom scalarsIf your schema uses custom scalars, they must be defined on targets:
$default:
builders:
artemis:
options:
scalar_mapping:
- custom_parser_import: 'package:graphbrainz_example/coercers.dart'
graphql_type: Date
dart_type: DateTime If your custom scalar needs to import Dart libraries, you can provide it in the config as well: targets:
$default:
builders:
artemis:
options:
scalar_mapping:
- custom_parser_import: 'package:graphbrainz_example/coercers.dart'
graphql_type: BigDecimal
dart_type:
name: Decimal
imports:
- 'package:decimal/decimal.dart' Each
See examples for more information and configuration options. Articles and videosArtemisClientIf you have final client = ArtemisClient('/graphql');
final gitHubReposQuery = MyGitHubReposQuery();
final response = await client.execute(gitHubReposQuery);
Check the examples to see how to use it in details. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论