Socket
Socket
Sign inDemoInstall

com.github.ekryd.sortgraphql:sortgraphql-parent

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

com.github.ekryd.sortgraphql:sortgraphql-parent

A Maven plugin that sorts GraphQL Schemas


Version published
Maintainers
1
Source

sortgraphql

Build Status Coverage Status Maven Central Quality Gate Status Licence

Maven plugin to sort GraphQL Schemas.

Description

The plugin will format and sort GraphQL schemas in a predefined way. The default sort order sections are:

  • All Directives first
  • The Query type
  • The Mutation type
  • The Subscription type
  • All Scalars
  • All Interfaces
  • All Unions
  • All Input types
  • All Types (beside Query, Mutation and Subscription)
  • All Enums

Within each section, the entities are sorted alphabetically. There are some parameters to suppress the alphabetical sorting, please submit a pull request or issue if you need more options.

The plugin should be able to handle custom directives and custom scalars. The plugin should also be able to sort multiple dependent graphql schema files as long as all entities are only defined in one schema.

Goals Overview

The SortGraphQL Plugin has one goal.

  • mvn sortgraphql:sort sorts the grapql file/files

Usage

Add the plugin to your pom-file to sort the schema each time you build the project. The plugin will execute by default in the Maven validate phase. Remember to set the src/main/resources/ path


<build>
  <plugins>
    ...
    <plugin>
      <groupId>com.github.ekryd.sortgraphql</groupId>
      <artifactId>sortgraphql-maven-plugin</artifactId>
      <version>@pom.version@</version>
      <configuration>
        <schemaFile>src/main/resources/mySchema.graphqls</schemaFile>
      </configuration>
      <executions>
        <execution>
          <goals>
            <goal>sort</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
    ...
  </plugins>
</build>

Parameters

ParameterDefault valueDescriptionExample
<createBackupFile>trueShould a backup copy be created for the sorted schema.<createBackupFile>false</createBackupFile>
<backupFileExtension>.bakName of the file extension for the backup file.<backupFileExtension>.temp</backupFileExtension>
<encoding>UTF-8Encoding for the files.<encoding>ASCII</encoding>
<individualSchemas>falseBy default, if multiple schema files are specified in schema files, then those schemas will be merged together during validation. This flag specifies that each schema should be validated individually.-Dsortgraphql.individualSchemas=true

<individualSchemas>true</individualSchemas>
<schemaFile>src/main/resources/schema.graphqlsLocation of the schema file. Remember to set the src/main/resources/ path.-Dsortgraphql.schemaFile="src/main/resources/main.graphqls"

<schemaFile>src/main/resources/main.graphqls</schemaFile>
<schemaFiles><empty>Location of multiple graphql schema file that should be sorted. Overrides parameter schemaFile. The schema files can reference each other, but shared definitions are not allowed.
<schemaFiles>
<schemaFile>src/main/resources/queries.graphqls</schemaFile>
<schemaFile>src/main/resources/mutations.graphqls</schemaFile>
</schemaFiles>
<skip>falseSet this to 'true' to bypass SortGraphQL plugin.-Dsortgraphql.skip=true

<skip>true</skip>
<skipFieldArgumentSorting>falseSet this to 'true' to skip sorting the arguments for a field in a type.<skipFieldArgumentSorting>true</skipFieldArgumentSorting>
<skipUnionTypeSorting>falseSet this to 'true' to skip sorting the types in a union.<skipUnionTypeSorting>true</skipUnionTypeSorting>
<generateHashDescriptions>falseUse hash sign for descriptions, instead of keeping string literals (with quote character).<generateHashDescriptions>true</generateHashDescriptions>
<generateSchemaDefinition>falseGenerate the 'schema' definition element at the top of the schema, when generating the sorted schema file.<generateSchemaDefinition>true</generateSchemaDefinition>

Download

The plugin is hosted i Maven Central and will be downloaded automatically if you include it as a plugin in your pom file.

Version history

  • 2022-04-02: Released 1.0.0 Supports schema definitions properly.
  • 2021-10-11: Released 0.0.4 Added configuration parameters to validate individual schemas. Input types will also have directives on separate line.
  • 2021-06-06: Released 0.0.3 Added configuration parameters to customize sorting.
  • 2021-06-01: Released 0.0.2 Fully functional but with limited configuration for sorting. Try it out and tell me what you think

FAQs

Package last updated on 20 Sep 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc