TDR Generated GraphQL
This project generates, packages and deploys the case classes generated by the sbt-graphql project to the sonatype nexus.
These classes are used by other TDR repositories to communicate with the consignment API.
Building locally
- Add a new query file to
src/main/graphql
: - Run
sbt graphqlSchemaGen
in the consignment api project. This will generate aschema.graphql
file in thetarget/sbt-graphql
directory - Copy this
schema.graphql
file - Switch back to the
generated-graphl
repo - Paste the file into the
src/main/resources
directory - Run the following commands to allow you to check that your changes work locally before submitting them:
Scala version
sbt package publishLocal
This will place a snapshot version of the built project jar in the local .ivy cache folder: $HOME/.ivy2/local/uk.gov.nationalarchives/tdr-generated-graphql_2.13/[version number]-SNAPSHOT
Other sbt projects that have this project as a dependency can access the local snapshot version by changing the version number in their build.sbt file, for example:
... other dependencies...
"uk.gov.nationalarchives" %% "tdr-generated-graphql" % "[version number]-SNAPSHOT"
... other dependences...
Typescript version
The following commands create a symbolic link to the generated Typescript version of the schema.
- In this project:
cd ts
- In the ts directory:
npm run codegen
- In the ts directory:
npm link
- From the output of this command copy the following line:
@nationalarchives/tdr-generated-graphql
.
- From the output of this command copy the following line:
- Navigate to the project that uses the generated schema in its Typescript code. In this project navigate to the relevant npm directory and run this command in that directory:
npm link @nationalarchives/tdr-generated-graphql
See the following blog post for more information on npm link
and instructions to undo the symbolic link: https://medium.com/@alexishevia/the-magic-behind-npm-link-d94dcb3a81af
Releasing
- Commit and push the new query file that sits in
src/main/graphql
- Open a pull request, and merge to master once it has been reviewed.
- This project should be run manually in Jenkins.
To Run Jenkins Manually
- Go to the TDR Graphql Code Generation job in Jenkins.
- Click on 'Build with parameters'
- Leave STAGE option as 'intg' and paste the schema from the consignemnt api repo into the SCHEMA section.
- You can look at the console output when/after you run the jenkins build to help bug fix etc.
TDR Documentation
The full documentation for the TDR project can be found here