Open cbeer opened 8 months ago
Here’s what I’ve learned:
lifeomic
(transforming json-schema into graphql schema). If we want to keep things relatievely the same, I think we should import this code and make required adjustments locally.graphql-mesh
could technically be a total replacement for our apollo server architecture but I am considering it here for it’s schema-generating tools, which are more robust than what apollo offers.
lifeomic
. Apollo tools cannot (the json it can work with is introspection json, generated from an existing graphql server).I found 2 possible paths for generating schemas given what we have from FOLIO. These involve 2 different “handlers”. Options can be configured in a meshrc.yml
file and a schema can be built with npm run mesh build
. If we went forward with this, we would set something up to copy this schema to the proper place in our setup after generation assuming the rest of our stack remains the same.
// package.json
"@graphql-mesh/cli": "^0.88.9",
"@graphql-mesh/json-schema": "^0.98.2",
// .meshrc.yml
sources:
- name: APIs
handler:
jsonSchema:
operations:
- type: Query
field: item
responseSample: ./samples/callnumbertype.json
responseTypeName: Item
okapi-test
with success on a limited number of tables.// package.json
"@graphql-mesh/cli": "^0.88.9",
"@graphql-mesh/postgraphile": "^0.96.6",
// .meshrc.yml
sources:
- name: FolioDB
handler:
postgraphile:
connectionString: postgres://okapi:password@localhost:5432/okapi
schemaName: ["sul_mod_circulation_storage", "sul_mod_courses"]
appendPlugins:
- './my-plugin.js'
I got further with this approach than the one above. The cool thing here is that we could remove the existing setup of linking with the FOLIO Github repositories to pull the JSON schemas. This approach relies on the graphile
library which is pretty powerful https://www.graphile.org/postgraphile/usage-library/. They offer the ability to do transforms https://the-guild.dev/graphql/mesh/docs/transforms/transforms-introduction and write custom plugins that, in theory, could do a lot of what we are doing in generate-graphql-from-json-schema.js
such as renaming and merging types.
I recommend importing the lifeomic library locally for the simplest transition. If we are more ambitious we can try prototyping an approach using mesh and graphile that would simplify our process of generating the graphql schema, eliminating the complex process of importing json-schemas from git.
We use lifeomic/json-schema-to-graphql-types to automagically convert from FOLIO's JSON schemas to graphql schemas. Unfortunately, it isn't compatible with Graphql 16, and a year later seems like it may never be.
Is there something new or better out there, or should we fork or pull the code into this repo?