Skip to content
This repository was archived by the owner on Oct 16, 2025. It is now read-only.

Commit 5763a42

Browse files
committed
chore: tidy generated outputs and brand readme
1 parent e681719 commit 5763a42

File tree

10 files changed

+47
-28
lines changed

10 files changed

+47
-28
lines changed

README.md

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,23 @@
11
# openiap-gql Code Generation Guide
22

3-
This repository is the single source of truth for the OpenIAP GraphQL schema. The SDL
3+
<!-- markdownlint-disable MD033 -->
4+
<p align="center">
5+
<img src="./logo.png" alt="OpenIAP GraphQL logo" width="320" />
6+
<br />
7+
<strong>OpenIAP meets GraphQL</strong>
8+
</p>
9+
<!-- markdownlint-enable MD033 -->
10+
11+
_Unified schema and multiplatform codegen toolkit for OpenIAP._
12+
13+
This repository is the single source of truth for the OpenIAP GraphQL schema. The SDL
414
files live in `src/` and are split into common (`type.graphql`, `api.graphql`), error
515
taxonomy (`error.graphql`), and platform-specific (`*-ios.graphql`, `*-android.graphql`)
616
definitions.
717

818
To keep every consumer in sync, code generation helpers are provided for
9-
TypeScript, Dart, Swift, and Kotlin. Each section below explains the tooling,
10-
commands, and output locations. Update the schema files first, then rerun the
19+
TypeScript, Dart, Swift, and Kotlin. Each section below explains the tooling,
20+
commands, and output locations. Update the schema files first, then rerun the
1121
appropriate generator for your target language.
1222

1323
---
@@ -21,15 +31,15 @@ Uses [`@graphql-codegen/cli`](https://www.the-guild.dev/graphql/codegen).
2131
3. Generate types: `npm run generate`
2232
4. Generated output: `src/generated/types.ts`
2333

24-
Configuration lives in `codegen.ts`. The script merges every SDL file and
34+
Configuration lives in `codegen.ts`. The script merges every SDL file and
2535
emits a schema-first type layer that mirrors the documented shapes.
2636

2737
---
2838

2939
## Dart
3040

3141
Uses [`graphql_codegen`](https://pub.dev/packages/graphql_codegen) with
32-
`build_runner`. A ready-to-use package scaffold is located in
42+
`build_runner`. A ready-to-use package scaffold is located in
3343
`generators/dart/`.
3444

3545
1. Install Dart 3.0+.
@@ -40,30 +50,30 @@ Uses [`graphql_codegen`](https://pub.dev/packages/graphql_codegen) with
4050
6. Generated output: `generators/dart/lib/generated/`
4151

4252
The `pubspec.yaml` and `build.yaml` already point the generator at the shared
43-
schema files in `../src`. Customize package name, output path, and scalars as
53+
schema files in `../src`. Customize package name, output path, and scalars as
4454
needed for your application.
4555

4656
---
4757

4858
## Swift
4959

5060
Relies on the official [Apollo iOS CLI](https://www.apollographql.com/docs/ios/)
51-
for schema codegen. A helper script is provided in `generators/swift/`.
61+
for schema codegen. A helper script is provided in `generators/swift/`.
5262

5363
1. Install the CLI (one time): `brew install apollo-ios-cli`
5464
2. Run the helper: `generators/swift/generate-swift.sh`
5565
3. Generated output: `generators/swift/Generated/`
5666

5767
The script passes every SDL file to the CLI and emits an embedded module named
58-
`OpenIAPGraphQL`. Adjust the script flags to fit your Xcode project (e.g.
68+
`OpenIAPGraphQL`. Adjust the script flags to fit your Xcode project (e.g.
5969
`--module-type swiftPackage` or supply operation files via `--operation-paths`).
6070

6171
---
6272

6373
## Kotlin
6474

6575
Recommended tooling is [Apollo Kotlin](https://www.apollographql.com/docs/kotlin).
66-
Use the Gradle plugin inside your Android project to consume the schema. Add a
76+
Use the Gradle plugin inside your Android project to consume the schema. Add a
6777
codegen module (e.g. `:openiap-graphql`) and configure it as follows:
6878

6979
```kotlin
@@ -93,14 +103,14 @@ dependencies {
93103
```
94104

95105
Then run `./gradlew :openiap-graphql:generateApolloSources` to regenerate the
96-
models. Keep your query/mutation documents under `src/main/graphql` inside that
106+
models. Keep your query/mutation documents under `src/main/graphql` inside that
97107
module.
98108

99109
---
100110

101111
## Workflow Tips
102112

103-
- Treat the SDL files in `src/` as the canonical schema. Commit schema updates
113+
- Treat the SDL files in `src/` as the canonical schema. Commit schema updates
104114
before shipping generated code.
105115
- Regenerate types whenever you change schema shape or add operations in your
106116
client projects.

logo.png

2.27 MB
Loading

scripts/fix-generated-types.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,6 @@ const wrapReturns = (interfaceName) => {
152152
wrapReturns('Query');
153153
wrapReturns('Mutation');
154154

155+
content = content.replace(/^\s*_placeholder\??: [^;]+;\n/gm, '');
156+
155157
writeFileSync(targetPath, content);

scripts/generate-dart-types.mjs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,16 @@ const dartKeywords = new Set([
5353
'yield',
5454
]);
5555

56-
const escapeDartName = (name) => (dartKeywords.has(name) ? `_${name}` : name);
56+
const dartKeywordOverrides = new Map([
57+
['deferred', 'deferred'],
58+
]);
59+
60+
const escapeDartName = (name) => {
61+
if (dartKeywordOverrides.has(name)) {
62+
return dartKeywordOverrides.get(name);
63+
}
64+
return dartKeywords.has(name) ? `_${name}` : name;
65+
};
5766

5867
const toCamelCase = (value, upper = false) => {
5968
const tokens = value
@@ -157,6 +166,8 @@ lines.push(
157166
"// Run `npm run generate` after updating any *.graphql schema file.",
158167
'// ============================================================================',
159168
'',
169+
'// ignore_for_file: unused_element, unused_field',
170+
'',
160171
"import 'dart:async';",
161172
'',
162173
);
@@ -253,7 +264,9 @@ const printOperationInterface = (operationType) => {
253264
const interfaceName = `${operationType.name}Resolver`;
254265
addDocComment(lines, operationType.description ?? `GraphQL root ${operationType.name.toLowerCase()} operations.`);
255266
lines.push(`abstract class ${interfaceName} {`);
256-
const fields = Object.values(operationType.getFields()).sort((a, b) => a.name.localeCompare(b.name));
267+
const fields = Object.values(operationType.getFields())
268+
.filter((field) => field.name !== '_placeholder')
269+
.sort((a, b) => a.name.localeCompare(b.name));
257270
for (const field of fields) {
258271
addDocComment(lines, field.description, ' ');
259272
const { type, nullable } = getDartType(field.type);

scripts/generate-kotlin-types.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,9 @@ const printOperationInterface = (operationType) => {
269269
const interfaceName = `${operationType.name}Resolver`;
270270
addDocComment(lines, operationType.description ?? `GraphQL root ${operationType.name.toLowerCase()} operations.`);
271271
lines.push(`public interface ${interfaceName} {`);
272-
const fields = Object.values(operationType.getFields()).sort((a, b) => a.name.localeCompare(b.name));
272+
const fields = Object.values(operationType.getFields())
273+
.filter((field) => field.name !== '_placeholder')
274+
.sort((a, b) => a.name.localeCompare(b.name));
273275
for (const field of fields) {
274276
addDocComment(lines, field.description, ' ');
275277
const { type, nullable } = getKotlinType(field.type);

scripts/generate-swift-types.mjs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,9 @@ const printOperationProtocol = (operationType) => {
280280
const protocolName = `${operationType.name}Resolver`;
281281
addDocComment(lines, operationType.description ?? `GraphQL root ${operationType.name.toLowerCase()} operations.`);
282282
lines.push(`public protocol ${protocolName} {`);
283-
const fields = Object.values(operationType.getFields()).sort((a, b) => a.name.localeCompare(b.name));
283+
const fields = Object.values(operationType.getFields())
284+
.filter((field) => field.name !== '_placeholder')
285+
.sort((a, b) => a.name.localeCompare(b.name));
284286
if (fields.length === 0) {
285287
lines.push(' // No operations defined.');
286288
}

src/generated/Types.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,6 @@ public sealed interface ReceiptValidationResult
729729
* GraphQL root mutation operations.
730730
*/
731731
public interface MutationResolver {
732-
suspend fun _placeholder(): Boolean?
733732
/**
734733
* Acknowledge a non-consumable purchase or subscription
735734
*/
@@ -796,7 +795,6 @@ public interface MutationResolver {
796795
* GraphQL root query operations.
797796
*/
798797
public interface QueryResolver {
799-
suspend fun _placeholder(): Boolean?
800798
/**
801799
* Get current StoreKit 2 entitlements (iOS 15+)
802800
*/
@@ -863,7 +861,6 @@ public interface QueryResolver {
863861
* GraphQL root subscription operations.
864862
*/
865863
public interface SubscriptionResolver {
866-
suspend fun _placeholder(): Boolean?
867864
/**
868865
* Fires when the App Store surfaces a promoted product (iOS only)
869866
*/

src/generated/Types.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,6 @@ public enum ReceiptValidationResult {
615615

616616
/// GraphQL root mutation operations.
617617
public protocol MutationResolver {
618-
func _placeholder() async throws -> Bool?
619618
/// Acknowledge a non-consumable purchase or subscription
620619
func acknowledgePurchaseAndroid(purchaseToken: String) async throws -> VoidResult
621620
/// Initiate a refund request for a product (iOS 15+)
@@ -650,7 +649,6 @@ public protocol MutationResolver {
650649

651650
/// GraphQL root query operations.
652651
public protocol QueryResolver {
653-
func _placeholder() async throws -> Bool?
654652
/// Get current StoreKit 2 entitlements (iOS 15+)
655653
func currentEntitlementIOS(skus: [String]? = nil) async throws -> [EntitlementIOS]
656654
/// Retrieve products or subscriptions from the store
@@ -685,7 +683,6 @@ public protocol QueryResolver {
685683

686684
/// GraphQL root subscription operations.
687685
public protocol SubscriptionResolver {
688-
func _placeholder() async throws -> Bool?
689686
/// Fires when the App Store surfaces a promoted product (iOS only)
690687
func promotedProductIOS() async throws -> String
691688
/// Fires when a purchase fails or is cancelled

src/generated/types.dart

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
// Run `npm run generate` after updating any *.graphql schema file.
44
// ============================================================================
55

6+
// ignore_for_file: unused_element, unused_field
7+
68
import 'dart:async';
79

810
// MARK: - Enums
@@ -106,7 +108,7 @@ enum PurchaseState {
106108
purchased('PURCHASED'),
107109
failed('FAILED'),
108110
restored('RESTORED'),
109-
_deferred('DEFERRED'),
111+
deferred('DEFERRED'),
110112
unknown('UNKNOWN');
111113

112114
const PurchaseState(this.value);
@@ -1088,7 +1090,6 @@ abstract class ReceiptValidationResult {}
10881090

10891091
/// GraphQL root mutation operations.
10901092
abstract class MutationResolver {
1091-
Future<bool?> _placeholder();
10921093
/// Acknowledge a non-consumable purchase or subscription
10931094
Future<VoidResult> acknowledgePurchaseAndroid({
10941095
required String purchaseToken,
@@ -1138,7 +1139,6 @@ abstract class MutationResolver {
11381139

11391140
/// GraphQL root query operations.
11401141
abstract class QueryResolver {
1141-
Future<bool?> _placeholder();
11421142
/// Get current StoreKit 2 entitlements (iOS 15+)
11431143
Future<List<EntitlementIOS>> currentEntitlementIOS({
11441144
List<String>? skus,
@@ -1193,7 +1193,6 @@ abstract class QueryResolver {
11931193

11941194
/// GraphQL root subscription operations.
11951195
abstract class SubscriptionResolver {
1196-
Future<bool?> _placeholder();
11971196
/// Fires when the App Store surfaces a promoted product (iOS only)
11981197
Future<String> promotedProductIOS();
11991198
/// Fires when a purchase fails or is cancelled

src/generated/types.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ export enum IapEvent {
138138
}
139139

140140
export interface Mutation {
141-
_placeholder?: (boolean | null);
142141
/** Acknowledge a non-consumable purchase or subscription */
143142
acknowledgePurchaseAndroid: Promise<VoidResult>;
144143
/** Initiate a refund request for a product (iOS 15+) */
@@ -480,7 +479,6 @@ export enum PurchaseState {
480479
}
481480

482481
export interface Query {
483-
_placeholder?: (boolean | null);
484482
/** Get current StoreKit 2 entitlements (iOS 15+) */
485483
currentEntitlementIOS: Promise<EntitlementIos[]>;
486484
/** Retrieve products or subscriptions from the store */
@@ -698,7 +696,6 @@ export interface RequestSubscriptionPropsByPlatforms {
698696
}
699697

700698
export interface Subscription {
701-
_placeholder?: (boolean | null);
702699
/** Fires when the App Store surfaces a promoted product (iOS only) */
703700
promotedProductIOS: string;
704701
/** Fires when a purchase fails or is cancelled */

0 commit comments

Comments
 (0)