Share on
·

GraphQL Schema Linting: Ensuring Consistency Across Subgraphs

Eric Murphy·

At Inigo, we understand the importance of keeping your GraphQL schemas clean, efficient, and standardized. That's why we're excited to announce that we've added GraphQL schema linting checks to our dev tools.

Our customers, many of whom manage multiple subgraphs, have expressed the need for a tool that can help maintain uniformity and prevent potential issues before they arise. The introduction of schema linting in Inigo addresses this need head-on. By automatically analyzing and validating the structure and syntax of your GraphQL schemas, our linting checks ensure that all your subgraphs adhere to the same set of standards, regardless of the number of development teams involved.

What sets Inigo's linting feature apart is its seamless integration into the GraphQL developer workflow and CI/CD pipelines. This means that you can catch and fix errors early in the development process, reducing the risk of introducing breaking changes and ensuring a smooth and consistent experience for your end users.

What is Schema Linting?

GraphQL schema linting is the process of analyzing and validating the structure and syntax of a GraphQL schema to ensure it adheres to best practices and standards. Like code linting in programming languages, schema linting helps identify potential issues, inconsistencies, or deviations from conventions before they cause problems in a GraphQL API.

Linting can check for various aspects of a schema, such as:

  1. Type Definitions: Ensuring that all types are defined correctly and used consistently.
  2. Field Naming: Verifying that field names follow a specified naming convention (e.g., camelCase).
  3. Deprecations: Identifying deprecated fields or types that should be removed or replaced.
  4. Directive Usage: Checking that directives are applied correctly and consistently.
  5. Schema Organization: Ensuring that the schema is organized logically and maintainable.

Using a schema linter allows developers to maintain a clean, efficient, and error-free GraphQL schema, which is crucial for building robust and scalable GraphQL APIs.

Schema Linting Rules

Schema Linting Rules Inigo includes a standard set of schema linting rules out of the box. These rules cover the most common schema standardization scenarios that GraphQL teams face. The following rules are listed in our Checks doc:

Linting Rules

If there are additional linting rules that your team needs, please reach out to us in Slack to discuss!

Enabling Schema Linting Rules

Schema linting rules are defined in a Checks YAML file (doc) that is applied using inigo apply. Here is an example Checks that defines FIELD_NAMES_CAMEL_CASE and REST_FIELD_NAMES linting rules:

Schema Checks with Linting Rules

In the Checks YAML, you can set the linting rules with the level of debug, info, warning, or error. For the error level, any schema changes will not be applied unless overridden.

Ignore Linting Rules with @lint Directive

For more granularity with applying linting rules (doc), the @lint directive can be used for types, fields, and enums. Here is an example of using @lint on a type:

Ignore Linting Rules

Inversely, you can also ignore all linting rules except for a subset of the rules, as shown below:

Ignore Except Linting Rules

Conclusion

In conclusion, integrating GraphQL schema linting into Inigo marks a significant step forward in our commitment to delivering top-notch API development tools. The seamless integration of linting into the developer workflow and CI/CD pipelines further enhances the efficiency and reliability of your API development, allowing you to catch potential issues early and avoid costly errors down the line. With Inigo's GraphQL schema linting, you can foster collaboration among different development teams, reduce the risk of breaking changes, and ultimately deliver a better experience to your GraphQL API consumers.

Ready to take the next steps with Inigo? You can:

  1. Get started for free at app.inigo.io
  2. Book a demo today at inigo.io/demo
  3. Ask questions on our Slack channel
Ready to accelerate your GraphQL adoption?
Start Inigo for free
*No credit card needed
Join our newsletter