-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sc-27549] Switch to using DiscoveryAPI for dbt.cloud (#926)
* [sc-27549] Switch to using DiscoveryAPI for dbt.cloud * use codegen * rewrite pt 1 * pt2 * refactor * refactor * parse test * finish implementation * ignore generated files in bandit * paginate macro arguments query * finish implementation * dont include codegen as dependency * rename files * use pascalcase query names * remove unused stuff * add test * bump version * rename graphql_client to generated * add codegen.sh * address comments * refactor tests * add test input * add test input * do not ignore node columns * ignore generated files in coverage * parse run result completion time * update docs * address comments * use pyproject.toml for precommit bandit * add toml dep in precommit bandit * fix * fix time format * bump version
- Loading branch information
1 parent
8c2b533
commit 127ce75
Showing
86 changed files
with
15,984 additions
and
518 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from .generated.client import Client as DiscoveryAPIClient | ||
|
||
__all__ = [ | ||
"DiscoveryAPIClient", | ||
] |
83 changes: 83 additions & 0 deletions
83
metaphor/dbt/cloud/discovery_api/apollo-codegen-config.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
{ | ||
"schemaNamespace": "MySchema", | ||
"schemaDownload": { | ||
"downloadMethod": { | ||
"introspection": { | ||
"endpointURL": "https://metadata.cloud.getdbt.com/graphql", | ||
"httpMethod": { | ||
"POST": {} | ||
}, | ||
"includeDeprecatedInputValues": false, | ||
"outputFormat": "SDL" | ||
} | ||
}, | ||
"downloadTimeout": 60, | ||
"headers": [], | ||
"outputPath": "./schema.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", | ||
"inputObjects": "camelCase" | ||
}, | ||
"deprecatedEnumCases": "exclude", | ||
"operationDocumentFormat": [ | ||
"definition" | ||
], | ||
"pruneGeneratedFiles": false, | ||
"schemaDocumentation": "exclude", | ||
"selectionSetInitializers": { | ||
"localCacheMutations": true | ||
}, | ||
"warningsOnDeprecatedUsage": "exclude" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[tool.ariadne-codegen] | ||
schema_path = "schema.graphql" | ||
queries_path = "queries.graphql" | ||
async_client = false | ||
target_package_name = "generated" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Generate GraphQL client code | ||
|
||
## Requirements | ||
|
||
- Python >= 3.9 | ||
- `ariadne-codegen` | ||
|
||
## Usage | ||
|
||
```bash | ||
cd metaphor/dbt/cloud/discovery_api | ||
./codegen.sh | ||
``` | ||
|
||
## Existing files | ||
|
||
### `codegen.sh` | ||
|
||
Run this script to get the schema from DBT's Apollo server, and generate the corresponding GraphQL client code. | ||
|
||
### `queries.graphql` | ||
|
||
The queries we will execute from the extractor class. | ||
|
||
### `apollo-codegen-config.json` | ||
|
||
Copied from [Full Codegen Configuration Example](https://www.apollographql.com/docs/ios/code-generation/codegen-configuration/#full-codegen-configuration-example) on Apollo's site. The only modifications are: | ||
|
||
- `endpointURL` | ||
- `outputPath` | ||
|
||
### `ariadne-codegen.toml` | ||
|
||
Controls the behavior of `ariadne-codegen`. | ||
|
||
### `schema.graphql` | ||
|
||
The upstream DBT GraphQL schema. This file will be downloaded from upstream whenever `codegen.sh` is run. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/usr/bin/env bash | ||
|
||
# The tool is called `apollo-ios-cli`: https://www.apollographql.com/docs/ios/code-generation/codegen-cli/ | ||
# It does not mean it's iOS only. | ||
APOLLO_IOS_CLI_VERSION=1.14.0 | ||
|
||
wget -c \ | ||
"https://github.com/apollographql/apollo-ios/releases/download/${APOLLO_IOS_CLI_VERSION}/apollo-ios-cli.tar.gz" -O - | \ | ||
tar -xz | ||
|
||
./apollo-ios-cli fetch-schema --path ./apollo-codegen-config.json | ||
|
||
rm -f ./apollo-ios-cli | ||
|
||
poetry run ariadne-codegen --config ariadne-codegen.toml | ||
poetry run black . | ||
poetry run isort . |
Oops, something went wrong.