Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: Adding full codegen config example #3193

Merged
merged 1 commit into from Aug 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
92 changes: 89 additions & 3 deletions docs/source/code-generation/codegen-configuration.mdx
Expand Up @@ -404,7 +404,6 @@ The top-level properties are:
| Property Name | Description |
| ------------- | ----------- |
| [`additionalInflectionRules`](https://www.apollographql.com/docs/ios/docc/documentation/apollocodegenlib/apollocodegenconfiguration/outputoptions/additionalinflectionrules) | Any non-default rules for pluralization or singularization of type names. |
| [`queryStringLiteralFormat`](https://www.apollographql.com/docs/ios/docc/documentation/apollocodegenlib/apollocodegenconfiguration/outputoptions/querystringliteralformat) | Formatting of the GraphQL query string literal that is included in each generated operation object. |
| [`deprecatedEnumCases`](https://www.apollographql.com/docs/ios/docc/documentation/apollocodegenlib/apollocodegenconfiguration/outputoptions/deprecatedenumcases) | Annotate generated Swift enums with the Swift `@available` attribute for GraphQL enum cases annotated with the built-in [`@deprecated` directive](https://spec.graphql.org/draft/#sec--deprecated). |
| [`schemaDocumentation`](https://www.apollographql.com/docs/ios/docc/documentation/apollocodegenlib/apollocodegenconfiguration/outputoptions/schemadocumentation) | Include or exclude [schema documentation](https://spec.graphql.org/draft/#sec-Descriptions) in the generated files. |
| [`selectionSetInitializers`](https://www.apollographql.com/docs/ios/docc/documentation/apollocodegenlib/apollocodegenconfiguration/outputoptions/selectionsetinitializers) | Generate initializers for your generated selection set models. |
Expand All @@ -424,7 +423,6 @@ The top-level properties are:
"singularRegex": "animal"
}
}],
"queryStringLiteralFormat": "multiline",
"deprecatedEnumCases": "include",
"schemaDocumentation": "include",
"selectionSetInitializers" : {
Expand Down Expand Up @@ -457,7 +455,6 @@ let configuration = ApolloCodegenConfiguration(
replacementRegex: "animals"
)
],
queryStringLiteralFormat: .multiline,
deprecatedEnumCases: .include,
schemaDocumentation: .include,
selectionSetInitializers: [
Expand Down Expand Up @@ -666,3 +663,92 @@ let configuration = ApolloCodegenConfiguration(
```

</MultiCodeBlock>

## Full Codegen Configuration Example

Below is an example that illustrates an `apollo-codegen-config.json` where every available option is configured in some way to show its usage and formatting:

```json title="apollo-codegen-config.json"
{
"schemaNamespace" : "MySchema",
"schemaDownload": {
"downloadMethod": {
"introspection": {
"endpointURL": "https://server.com",
"httpMethod": {
"POST": {}
},
"includeDeprecatedInputValues": false,
"outputFormat": "SDL"
}
},
"downloadTimeout": 60,
"headers": [],
"outputPath": "./graphql/"
},
"experimentalFeatures" : {
"clientControlledNullability" : true,
"legacySafelistingCompatibleOperations" : true
},
"operationManifest" : {
"generateManifestOnCodeGeneration" : false,
"path" : "/operation/identifiers/path",
"version" : "persistedQueries"
},
"input" : {
"operationSearchPaths" : [
"/search/path/**/*.graphql"
],
"schemaSearchPaths" : [
"/path/to/schema.graphqls"
]
},
"output" : {
"operations" : {
"absolute" : {
"accessModifier" : "internal",
"path" : "/absolute/path"
}
},
"schemaTypes" : {
"moduleType" : {
"embeddedInTarget" : {
"accessModifier" : "public",
"name" : "SomeTarget"
}
},
"path" : "/output/path"
},
"testMocks" : {
"swiftPackage" : {
"targetName" : "SchemaTestMocks"
}
}
},
"options" : {
"additionalInflectionRules" : [
{
"pluralization" : {
"replacementRegex" : "animals",
"singularRegex" : "animal"
}
}
],
"cocoapodsCompatibleImportStatements" : true,
"conversionStrategies" : {
"enumCases" : "none",
"fieldAccessors" : "camelCase"
},
"deprecatedEnumCases" : "exclude",
"operationDocumentFormat" : [
"definition"
],
"pruneGeneratedFiles" : false,
"schemaDocumentation" : "exclude",
"selectionSetInitializers" : {
"localCacheMutations" : true
},
"warningsOnDeprecatedUsage" : "exclude"
}
}
```