Skip to content

Commit

Permalink
CIF-2658 - Automate pruned schema generation with CLI tool (#164)
Browse files Browse the repository at this point in the history
* releng - Update CIF Add-on UI Schemas

* releng - Update CIF Add-on Queries

* releng - Update CIF Core Components Queries

* CIF - Automate pruned schema generation with CLI tool

* CIF-2658 - Add feedback

* CIF-2658 - Fix unit test
  • Loading branch information
herzog31 authored Mar 10, 2022
1 parent ef5bc2f commit a6a210c
Show file tree
Hide file tree
Showing 23 changed files with 92,249 additions and 12,723 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ In order to illustrate these requirements, the `localSchema()` function in [disp

## Schema documentation

As stated in the previous section, GraphQL introspection allows users to discover and browse a GraphQL schema in order to understand the types of queries it supports. When implementing a 3rd-party integration and because the Magento schema is large, it is important that one understands the parts of the Magento schema that are actually used by the CIF connector and components. To document this, we have implemented a tool that uses the GraphQL queries used by the CIF connector and components in order to create the subset of the Magento schema that MUST be implemented in order to support the CIF connector and components.
As stated in the previous section, GraphQL introspection allows users to discover and browse a GraphQL schema in order to understand the types of queries it supports. When implementing a 3rd-party integration and because the Magento schema is large, it is important that one understands the parts of the Magento schema that are actually used by the CIF add-on and core components. To document this, we have implemented a tool that uses the GraphQL queries used by the CIF add-on and components in order to create the subset of the Magento schema that MUST be implemented in order to support the CIF add-on and components.

This "pruned" schema is automatically generated and included in this repository. If needed, one can regenerate it by running `npm run doc`. Note that this requires that you have the [jq](https://github.com/stedolan/jq) tool installed on your machine.
To generate a "pruned" schema, please check the [schemas](schemas/README.md) folder.

To introspect this schema, it is automatically deployed when running `aio app deploy` in a web action called `cif-schema`. Using a GraphQL introspection tool like the included `GraphiQL`, one can then easily browse the pruned schema at the `https://adobeioruntime.net/api/v1/web/NAMESPACE/graphql-reference/cif-schema` URL. This action only supports introspection, so you cannot execute any query. It however documents all the fields and types that are currently being used by the CIF connector and components.

Expand Down
2 changes: 1 addition & 1 deletion actions/common/SchemaBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class SchemaBuilder {
}

// Remove "Mutation" root type if it doesn't have any field
if (mutationRootType && mutationRootType.fields.length == 0) {
if (!mutationRootType || (mutationRootType && mutationRootType.fields.length == 0)) {
this.removeMutationType();
}

Expand Down
85 changes: 0 additions & 85 deletions actions/documentation/generate.js

This file was deleted.

2 changes: 1 addition & 1 deletion actions/documentation/introspection.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

'use strict';

const magentoSchema = require('../resources/magento-schema-2.4.3ee.pruned.min.json');
const magentoSchema = require('../resources/pruned-schema.min.json');
const { buildClientSchema, graphql } = require('graphql');

function resolve(args) {
Expand Down
Loading

0 comments on commit a6a210c

Please sign in to comment.