Latest commit

History

History
177 lines (132 loc) · 19.7 KB

File metadata and controls

177 lines (132 loc) · 19.7 KB

Codegen Options

OptionData TypeDefault valueDescription
graphqlSchemaPathsList(String)(falls back to graphqlSchemas)GraphQL schema locations. You can supply multiple paths to GraphQL schemas. To include many schemas from a folder hierarchy, use the graphqlSchemas block instead.
graphqlSchemasSee graphqlSchemasAll .graphqls/.graphql files in resourcesBlock to define the input GraphQL schemas, when exact paths are too cumbersome. See table below for a list of options. See graphqlSchemas
graphqlQueryIntrospectionResultPathStringNonePath to GraphQL Introspection Query result in json format (with root object __schema or data.__schema). Sample: sample-introspection-query-result.json
outputDirStringNoneThe output target directory into which code will be generated.
jsonConfigurationFileStringEmptyPath to an external mapping configuration.
packageNameStringEmptyJava package for generated classes.
apiPackageNameStringEmptyJava package for generated api classes (Query, Mutation, Subscription).
modelPackageNameStringEmptyJava package for generated model classes (type, input, interface, enum, union).
generateBuilderBooleanTrueSpecifies whether generated model classes should have builder.
generateApisBooleanTrueSpecifies whether api classes should be generated as well as model classes.
generateDataFetchingEnvironmentArgumentInApisBooleanFalseIf true, then graphql.schema.DataFetchingEnvironment env will be added as a last argument to all methods of root type resolvers and field resolvers.
generateEqualsAndHashCodeBooleanFalseSpecifies whether generated model classes should have equals and hashCode methods defined.
generateImmutableModelsBooleanFalseSpecifies whether generated model classes should be immutable.
generateToStringBooleanFalseSpecifies whether generated model classes should have toString method defined.
apiNamePrefixStringEmptySets the prefix for GraphQL api classes (query, mutation, subscription).
apiNameSuffixStringResolverSets the suffix for GraphQL api classes (query, mutation, subscription).
apiInterfaceStrategySee ApiInterfaceStrategyINTERFACE_PER_OPERATIONSee ApiInterfaceStrategy
apiRootInterfaceStrategySee ApiRootInterfaceStrategySINGLE_INTERFACESee ApiRootInterfaceStrategy
apiNamePrefixStrategySee ApiNamePrefixStrategyCONSTANTSee ApiNamePrefixStrategy
modelNamePrefixStringEmptySets the prefix for GraphQL model classes (type, input, interface, enum, union).
modelNameSuffixStringEmptySets the suffix for GraphQL model classes (type, input, interface, enum, union).
modelValidationAnnotationString@javax.validation.
constraints.NotNull
Annotation for mandatory (NonNull) fields. Can be null/empty.
typeResolverPrefixStringEmptySets the prefix for GraphQL type resolver classes.
typeResolverSuffixStringResolverSets the suffix for GraphQL type resolver classes.
customTypesMappingMap(String,String)EmptySee CustomTypesMapping
customAnnotationsMappingMap(String,String[])EmptySee CustomAnnotationsMapping
directiveAnnotationsMappingMap(String,String[])EmptySee DirectiveAnnotationsMapping
fieldsWithResolversSet(String)EmptyFields that require Resolvers should be defined here in format: TypeName.fieldName or TypeName or @directive. E.g.: Person, Person.friends, @customResolver.
fieldsWithoutResolversSet(String)EmptyFields that DO NOT require Resolvers should be defined here in format: TypeName.fieldName or TypeName or @directive. Can be used in conjunction with generateExtensionFieldsResolvers option. E.g.: Person, Person.friends, @noResolver.
generateParameterizedFieldsResolversBooleanTrueIf true, then generate separate Resolver interface for parametrized fields. If false, then add field to the type definition and ignore field parameters.
generateExtensionFieldsResolversBooleanFalseSpecifies whether all fields in extensions (extend type and extend interface) should be present in Resolver interface instead of the type class itself.
generateModelsForRootTypesBooleanFalseSpecifies whether model classes should be generated for type Query, type Subscription, type Mutation.
useOptionalForNullableReturnTypesBooleanFalseSpecifies whether nullable return types of api methods should be wrapped into java.util.Optional<>. Lists will not be wrapped.
apiReturnTypeStringEmptyReturn type for api methods (query/mutation). For example: reactor.core.publisher.Mono, etc.
apiReturnListTypeStringEmptyReturn type for api methods (query/mutation) having list type. For example: reactor.core.publisher.Flux, etc. By default is empty, so apiReturnType will be used.
subscriptionReturnTypeStringEmptyReturn type for subscription methods. For example: org.reactivestreams.Publisher, io.reactivex.Observable, etc.
relayConfigSee RelayConfig@connection(for: ...)See RelayConfig
generateClientBooleanFalseSpecifies whether client-side classes should be generated for each query, mutation and subscription. This includes: Request classes (contain input data), ResponseProjection classes for each type (contain response fields) and Response classes (contain response data).
requestSuffixStringRequestSets the suffix for Request classes.
responseSuffixStringResponseSets the suffix for Response classes.
responseProjectionSuffixStringResponseProjectionSets the suffix for ResponseProjection classes.
parametrizedInputSuffixStringParametrizedInputSets the suffix for ParametrizedInput classes.
parentInterfacesSee parentInterfacesEmptyBlock to define parent interfaces for generated interfaces (query / mutation / subscription / type resolver). See parentInterfaces
responseProjectionMaxDepthInteger3Sets max depth when use all$() which for facilitating the construction of projection automatically, the fields on all projections are provided when it be invoked. This is a global configuration, of course, you can use all$(max) to set for each method. For self recursive types, too big depth may result in a large number of returned data!

Option graphqlSchemas

When exact paths to GraphQL schemas are too cumbersome to provide in the graphqlSchemaPaths, use the graphqlSchemas block. The parameters inside that block are the following:

Key inside graphqlSchemasData TypeDefault valueDescription
rootDirStringMain resources dirThe root directory from which to start searching for schema files.
recursiveBooleantrueWhether to recursively look into sub directories.
includePatternString.*\.graphqls?A Java regex that file names must match to be included. It should be a regex as defined by the Pattern JDK class. It will be used to match only the file name without path.
excludedFilesSet(empty set)A set of files to exclude, even if they match the include pattern. These paths should be either absolute or relative to the provided rootDir.

Option ApiInterfaceStrategy

Defines how to generate interfaces (resolvers) for each operation: Query/Mutation/Subscription. Provides ability to skip generation of separate interface class for each operation in favor of having a single "root" interface (see ApiRootInterfaceStrategy and ApiNamePrefixStrategy)

ValueDescription
INTERFACE_PER_OPERATION(default)Generate separate interface classes for each GraphQL operation.
DO_NOT_GENERATEDo not generate separate interfaces classes for GraphQL operation.

Option ApiRootInterfaceStrategy

Defines how root interface (QueryResolver / MutationResolver / SubscriptionResolver will be generated (in addition to separate interfaces for each query/mutation/subscription)

ValueDescription
INTERFACE_PER_SCHEMAGenerate multiple super-interfaces for each graphql file.
Takes into account apiNamePrefixStrategy.
E.g.: OrderServiceQueryResolver.java, ProductServiceQueryResolver.java, etc.
SINGLE_INTERFACE(default)Generate a single QueryResolver.java, MutationResolver.java, SubscriptionResolver.java for all graphql schema files.
DO_NOT_GENERATEDo not generate super interface for GraphQL operations.

Option ApiNamePrefixStrategy

Defines which prefix to use for API interfaces.

ValueDescription
FILE_NAME_AS_PREFIXWill take GraphQL file name as a prefix for all generated API interfaces + value of apiNamePrefix config option.
E.g.:
* following schemas: resources/schemas/order-service.graphql, resources/schemas/product-service.graphql
* will result in: OrderServiceQueryResolver.java, ProductServiceQueryResolver.java, etc
FOLDER_NAME_AS_PREFIXWill take parent folder name as a prefix for all generated API interfaces + value of apiNamePrefix config option. E.g.:
* following schemas: resources/order-service/schema1.graphql, resources/order-service/schema2.graphql
* will result in: OrderServiceQueryResolver.java, OrderServiceGetOrderByIdQueryResolver.java, etc
CONSTANT(default)Will take only the value of apiNamePrefix config option.

Option parentInterfaces

Following options can be defined if you want generated resolvers to extend certain interfaces. Can be handy if you are using graphql-java-tools and want your resolver classes to extend only interfaces generated by this plugin.

Note: if you want to include a GraphQL type name into the interface name, then use {{TYPE}} placeholder. E.g.: graphql.kickstart.tools.GraphQLResolver<{{TYPE}}>

Key inside parentInterfacesData TypeDefault valueDescription
queryResolverStringEmptyInterface that will be added as "extend" to all generated api Query interfaces.
mutationResolverStringEmptyInterface that will be added as "extend" to all generated api Mutation interfaces.
subscriptionResolverStringEmptyInterface that will be added as "extend" to all generated api Subscription interfaces.
resolverStringEmptyInterface that will be added as "extend" to all generated TypeResolver interfaces.

Option customTypesMapping

Can be used to supply custom mappings for scalars.

Supports following formats:

  • Map of (GraphQLObjectName.fieldName) to (JavaType). E.g.: Event.dateTime = java.util.Date
  • Map of (GraphQLType) to (JavaType). E.g.: EpochMillis = java.time.LocalDateTime

Option customAnnotationsMapping

Can be used to supply custom annotations (serializers) for scalars. @ in front of the annotation class is optional.

Supports following formats:

  • Map of (GraphQLObjectName.fieldName) to (JavaAnnotation). E.g.: Event.dateTime = @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.example.DateDeserializer.class)
  • Map of (GraphQLType) to (JavaAnnotation). E.g.: EpochMillis = @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.example.EpochMillisDeserializer.class)

Option directiveAnnotationsMapping

Can be used to supply custom annotations for directives in a following format: Map of (GraphQL.directiveName) to (JavaAnnotation). E.g.: auth = @org.springframework.security.access.annotation.Secured({{roles}}). @ in front of the annotation class is optional.

Note: In order to supply the value of directive argument to annotation, use placeholder {{directiveArgument}}. You can also use one of the formatters for directive argument value: {{val?toString}}, {{val?toArray}}, {{val?toArrayOfStrings}}.

Option relayConfig

Can be used to supply a custom configuration for Relay support. For reference see: https://www.graphql-java-kickstart.com/tools/relay/

Key inside relayConfigData TypeDefault valueDescription
directiveNameStringconnectionDirective name used for marking a field.
directiveArgumentNameStringforDirective argument name that contains a GraphQL type name.
connectionTypeStringgraphql.relay.ConnectionGeneric Connection type.

For example, the following schema:

type Query { users(first: Int, after: String): UserConnection @connection(for: "User") }

will result in generating the interface with the following method:

graphql.relay.Connection<User> users(Integer first, String after) throws Exception;

External mapping configuration

Provide a path to external file via property jsonConfigurationFile Sample content of the file:

{
"generateApis": true,
"packageName": "com.kobylynskyi.graphql.testconfigjson",
"customTypesMapping": {
"Price.amount": "java.math.BigDecimal"
}
}
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Add copy buttons to all
 blocks\n(function() {\n function addCopyButtons() {\n document.querySelectorAll('pre code').forEach(function(codeBlock) {\n if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;\n codeBlock.parentElement.setAttribute('data-copy-added', 'true');\n \n var btn = document.createElement('button');\n btn.textContent = 'Copy';\n btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';\n btn.onmouseover = function() { this.style.opacity = '1'; };\n btn.onmouseout = function() { this.style.opacity = '0.7'; };\n btn.onclick = function() {\n navigator.clipboard.writeText(codeBlock.textContent).then(function() {\n btn.textContent = 'Copied!';\n setTimeout(function() { btn.textContent = 'Copy'; }, 1500);\n });\n };\n codeBlock.parentElement.style.position = 'relative';\n codeBlock.parentElement.appendChild(btn);\n });\n }\n \n addCopyButtons();\n \n // Re-run on dynamic content\n var observer = new MutationObserver(addCopyButtons);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Add Copy Buttons to Code Blocks");
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
Skip to content

Latest commit

History

History
177 lines (132 loc) · 19.7 KB

File metadata and controls

177 lines (132 loc) · 19.7 KB

Codegen Options

OptionData TypeDefault valueDescription
graphqlSchemaPathsList(String)(falls back to graphqlSchemas)GraphQL schema locations. You can supply multiple paths to GraphQL schemas. To include many schemas from a folder hierarchy, use the graphqlSchemas block instead.
graphqlSchemasSee graphqlSchemasAll .graphqls/.graphql files in resourcesBlock to define the input GraphQL schemas, when exact paths are too cumbersome. See table below for a list of options. See graphqlSchemas
graphqlQueryIntrospectionResultPathStringNonePath to GraphQL Introspection Query result in json format (with root object __schema or data.__schema). Sample: sample-introspection-query-result.json
outputDirStringNoneThe output target directory into which code will be generated.
jsonConfigurationFileStringEmptyPath to an external mapping configuration.
packageNameStringEmptyJava package for generated classes.
apiPackageNameStringEmptyJava package for generated api classes (Query, Mutation, Subscription).
modelPackageNameStringEmptyJava package for generated model classes (type, input, interface, enum, union).
generateBuilderBooleanTrueSpecifies whether generated model classes should have builder.
generateApisBooleanTrueSpecifies whether api classes should be generated as well as model classes.
generateDataFetchingEnvironmentArgumentInApisBooleanFalseIf true, then graphql.schema.DataFetchingEnvironment env will be added as a last argument to all methods of root type resolvers and field resolvers.
generateEqualsAndHashCodeBooleanFalseSpecifies whether generated model classes should have equals and hashCode methods defined.
generateImmutableModelsBooleanFalseSpecifies whether generated model classes should be immutable.
generateToStringBooleanFalseSpecifies whether generated model classes should have toString method defined.
apiNamePrefixStringEmptySets the prefix for GraphQL api classes (query, mutation, subscription).
apiNameSuffixStringResolverSets the suffix for GraphQL api classes (query, mutation, subscription).
apiInterfaceStrategySee ApiInterfaceStrategyINTERFACE_PER_OPERATIONSee ApiInterfaceStrategy
apiRootInterfaceStrategySee ApiRootInterfaceStrategySINGLE_INTERFACESee ApiRootInterfaceStrategy
apiNamePrefixStrategySee ApiNamePrefixStrategyCONSTANTSee ApiNamePrefixStrategy
modelNamePrefixStringEmptySets the prefix for GraphQL model classes (type, input, interface, enum, union).
modelNameSuffixStringEmptySets the suffix for GraphQL model classes (type, input, interface, enum, union).
modelValidationAnnotationString@javax.validation.
constraints.NotNull
Annotation for mandatory (NonNull) fields. Can be null/empty.
typeResolverPrefixStringEmptySets the prefix for GraphQL type resolver classes.
typeResolverSuffixStringResolverSets the suffix for GraphQL type resolver classes.
customTypesMappingMap(String,String)EmptySee CustomTypesMapping
customAnnotationsMappingMap(String,String[])EmptySee CustomAnnotationsMapping
directiveAnnotationsMappingMap(String,String[])EmptySee DirectiveAnnotationsMapping
fieldsWithResolversSet(String)EmptyFields that require Resolvers should be defined here in format: TypeName.fieldName or TypeName or @directive. E.g.: Person, Person.friends, @customResolver.
fieldsWithoutResolversSet(String)EmptyFields that DO NOT require Resolvers should be defined here in format: TypeName.fieldName or TypeName or @directive. Can be used in conjunction with generateExtensionFieldsResolvers option. E.g.: Person, Person.friends, @noResolver.
generateParameterizedFieldsResolversBooleanTrueIf true, then generate separate Resolver interface for parametrized fields. If false, then add field to the type definition and ignore field parameters.
generateExtensionFieldsResolversBooleanFalseSpecifies whether all fields in extensions (extend type and extend interface) should be present in Resolver interface instead of the type class itself.
generateModelsForRootTypesBooleanFalseSpecifies whether model classes should be generated for type Query, type Subscription, type Mutation.
useOptionalForNullableReturnTypesBooleanFalseSpecifies whether nullable return types of api methods should be wrapped into java.util.Optional<>. Lists will not be wrapped.
apiReturnTypeStringEmptyReturn type for api methods (query/mutation). For example: reactor.core.publisher.Mono, etc.
apiReturnListTypeStringEmptyReturn type for api methods (query/mutation) having list type. For example: reactor.core.publisher.Flux, etc. By default is empty, so apiReturnType will be used.
subscriptionReturnTypeStringEmptyReturn type for subscription methods. For example: org.reactivestreams.Publisher, io.reactivex.Observable, etc.
relayConfigSee RelayConfig@connection(for: ...)See RelayConfig
generateClientBooleanFalseSpecifies whether client-side classes should be generated for each query, mutation and subscription. This includes: Request classes (contain input data), ResponseProjection classes for each type (contain response fields) and Response classes (contain response data).
requestSuffixStringRequestSets the suffix for Request classes.
responseSuffixStringResponseSets the suffix for Response classes.
responseProjectionSuffixStringResponseProjectionSets the suffix for ResponseProjection classes.
parametrizedInputSuffixStringParametrizedInputSets the suffix for ParametrizedInput classes.
parentInterfacesSee parentInterfacesEmptyBlock to define parent interfaces for generated interfaces (query / mutation / subscription / type resolver). See parentInterfaces
responseProjectionMaxDepthInteger3Sets max depth when use all$() which for facilitating the construction of projection automatically, the fields on all projections are provided when it be invoked. This is a global configuration, of course, you can use all$(max) to set for each method. For self recursive types, too big depth may result in a large number of returned data!

Option graphqlSchemas

When exact paths to GraphQL schemas are too cumbersome to provide in the graphqlSchemaPaths, use the graphqlSchemas block. The parameters inside that block are the following:

Key inside graphqlSchemasData TypeDefault valueDescription
rootDirStringMain resources dirThe root directory from which to start searching for schema files.
recursiveBooleantrueWhether to recursively look into sub directories.
includePatternString.*\.graphqls?A Java regex that file names must match to be included. It should be a regex as defined by the Pattern JDK class. It will be used to match only the file name without path.
excludedFilesSet(empty set)A set of files to exclude, even if they match the include pattern. These paths should be either absolute or relative to the provided rootDir.

Option ApiInterfaceStrategy

Defines how to generate interfaces (resolvers) for each operation: Query/Mutation/Subscription. Provides ability to skip generation of separate interface class for each operation in favor of having a single "root" interface (see ApiRootInterfaceStrategy and ApiNamePrefixStrategy)

ValueDescription
INTERFACE_PER_OPERATION(default)Generate separate interface classes for each GraphQL operation.
DO_NOT_GENERATEDo not generate separate interfaces classes for GraphQL operation.

Option ApiRootInterfaceStrategy

Defines how root interface (QueryResolver / MutationResolver / SubscriptionResolver will be generated (in addition to separate interfaces for each query/mutation/subscription)

ValueDescription
INTERFACE_PER_SCHEMAGenerate multiple super-interfaces for each graphql file.
Takes into account apiNamePrefixStrategy.
E.g.: OrderServiceQueryResolver.java, ProductServiceQueryResolver.java, etc.
SINGLE_INTERFACE(default)Generate a single QueryResolver.java, MutationResolver.java, SubscriptionResolver.java for all graphql schema files.
DO_NOT_GENERATEDo not generate super interface for GraphQL operations.

Option ApiNamePrefixStrategy

Defines which prefix to use for API interfaces.

ValueDescription
FILE_NAME_AS_PREFIXWill take GraphQL file name as a prefix for all generated API interfaces + value of apiNamePrefix config option.
E.g.:
* following schemas: resources/schemas/order-service.graphql, resources/schemas/product-service.graphql
* will result in: OrderServiceQueryResolver.java, ProductServiceQueryResolver.java, etc
FOLDER_NAME_AS_PREFIXWill take parent folder name as a prefix for all generated API interfaces + value of apiNamePrefix config option. E.g.:
* following schemas: resources/order-service/schema1.graphql, resources/order-service/schema2.graphql
* will result in: OrderServiceQueryResolver.java, OrderServiceGetOrderByIdQueryResolver.java, etc
CONSTANT(default)Will take only the value of apiNamePrefix config option.

Option parentInterfaces

Following options can be defined if you want generated resolvers to extend certain interfaces. Can be handy if you are using graphql-java-tools and want your resolver classes to extend only interfaces generated by this plugin.

Note: if you want to include a GraphQL type name into the interface name, then use {{TYPE}} placeholder. E.g.: graphql.kickstart.tools.GraphQLResolver<{{TYPE}}>

Key inside parentInterfacesData TypeDefault valueDescription
queryResolverStringEmptyInterface that will be added as "extend" to all generated api Query interfaces.
mutationResolverStringEmptyInterface that will be added as "extend" to all generated api Mutation interfaces.
subscriptionResolverStringEmptyInterface that will be added as "extend" to all generated api Subscription interfaces.
resolverStringEmptyInterface that will be added as "extend" to all generated TypeResolver interfaces.

Option customTypesMapping

Can be used to supply custom mappings for scalars.

Supports following formats:

  • Map of (GraphQLObjectName.fieldName) to (JavaType). E.g.: Event.dateTime = java.util.Date
  • Map of (GraphQLType) to (JavaType). E.g.: EpochMillis = java.time.LocalDateTime

Option customAnnotationsMapping

Can be used to supply custom annotations (serializers) for scalars. @ in front of the annotation class is optional.

Supports following formats:

  • Map of (GraphQLObjectName.fieldName) to (JavaAnnotation). E.g.: Event.dateTime = @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.example.DateDeserializer.class)
  • Map of (GraphQLType) to (JavaAnnotation). E.g.: EpochMillis = @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.example.EpochMillisDeserializer.class)

Option directiveAnnotationsMapping

Can be used to supply custom annotations for directives in a following format: Map of (GraphQL.directiveName) to (JavaAnnotation). E.g.: auth = @org.springframework.security.access.annotation.Secured({{roles}}). @ in front of the annotation class is optional.

Note: In order to supply the value of directive argument to annotation, use placeholder {{directiveArgument}}. You can also use one of the formatters for directive argument value: {{val?toString}}, {{val?toArray}}, {{val?toArrayOfStrings}}.

Option relayConfig

Can be used to supply a custom configuration for Relay support. For reference see: https://www.graphql-java-kickstart.com/tools/relay/

Key inside relayConfigData TypeDefault valueDescription
directiveNameStringconnectionDirective name used for marking a field.
directiveArgumentNameStringforDirective argument name that contains a GraphQL type name.
connectionTypeStringgraphql.relay.ConnectionGeneric Connection type.

For example, the following schema:

type Query { users(first: Int, after: String): UserConnection @connection(for: "User") }

will result in generating the interface with the following method:

graphql.relay.Connection<User> users(Integer first, String after) throws Exception;

External mapping configuration

Provide a path to external file via property jsonConfigurationFile Sample content of the file:

{
"generateApis": true,
"packageName": "com.kobylynskyi.graphql.testconfigjson",
"customTypesMapping": {
"Price.amount": "java.math.BigDecimal"
}
}
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Force GitHub README to respect dark mode\n(function() {\n var style = document.createElement('style');\n style.textContent = '\n .markdown-body {\n color-scheme: dark light;\n }\n .markdown-body pre { background: #161b22 !important; }\n .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; }\n .markdown-body table th, .markdown-body table td { border-color: #30363d !important; }\n .markdown-body img { background: #0d1117; }\n .markdown-body blockquote { border-left-color: #8b949e; }\n .markdown-body hr { border-color: #30363d; }\n ';\n document.head.appendChild(style);\n})();", "GitHub Dark Mode README Fix"); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

History
177 lines (132 loc) · 19.7 KB

File metadata and controls

177 lines (132 loc) · 19.7 KB

Codegen Options

OptionData TypeDefault valueDescription
graphqlSchemaPathsList(String)(falls back to graphqlSchemas)GraphQL schema locations. You can supply multiple paths to GraphQL schemas. To include many schemas from a folder hierarchy, use the graphqlSchemas block instead.
graphqlSchemasSee graphqlSchemasAll .graphqls/.graphql files in resourcesBlock to define the input GraphQL schemas, when exact paths are too cumbersome. See table below for a list of options. See graphqlSchemas
graphqlQueryIntrospectionResultPathStringNonePath to GraphQL Introspection Query result in json format (with root object __schema or data.__schema). Sample: sample-introspection-query-result.json
outputDirStringNoneThe output target directory into which code will be generated.
jsonConfigurationFileStringEmptyPath to an external mapping configuration.
packageNameStringEmptyJava package for generated classes.
apiPackageNameStringEmptyJava package for generated api classes (Query, Mutation, Subscription).
modelPackageNameStringEmptyJava package for generated model classes (type, input, interface, enum, union).
generateBuilderBooleanTrueSpecifies whether generated model classes should have builder.
generateApisBooleanTrueSpecifies whether api classes should be generated as well as model classes.
generateDataFetchingEnvironmentArgumentInApisBooleanFalseIf true, then graphql.schema.DataFetchingEnvironment env will be added as a last argument to all methods of root type resolvers and field resolvers.
generateEqualsAndHashCodeBooleanFalseSpecifies whether generated model classes should have equals and hashCode methods defined.
generateImmutableModelsBooleanFalseSpecifies whether generated model classes should be immutable.
generateToStringBooleanFalseSpecifies whether generated model classes should have toString method defined.
apiNamePrefixStringEmptySets the prefix for GraphQL api classes (query, mutation, subscription).
apiNameSuffixStringResolverSets the suffix for GraphQL api classes (query, mutation, subscription).
apiInterfaceStrategySee ApiInterfaceStrategyINTERFACE_PER_OPERATIONSee ApiInterfaceStrategy
apiRootInterfaceStrategySee ApiRootInterfaceStrategySINGLE_INTERFACESee ApiRootInterfaceStrategy
apiNamePrefixStrategySee ApiNamePrefixStrategyCONSTANTSee ApiNamePrefixStrategy
modelNamePrefixStringEmptySets the prefix for GraphQL model classes (type, input, interface, enum, union).
modelNameSuffixStringEmptySets the suffix for GraphQL model classes (type, input, interface, enum, union).
modelValidationAnnotationString@javax.validation.
constraints.NotNull
Annotation for mandatory (NonNull) fields. Can be null/empty.
typeResolverPrefixStringEmptySets the prefix for GraphQL type resolver classes.
typeResolverSuffixStringResolverSets the suffix for GraphQL type resolver classes.
customTypesMappingMap(String,String)EmptySee CustomTypesMapping
customAnnotationsMappingMap(String,String[])EmptySee CustomAnnotationsMapping
directiveAnnotationsMappingMap(String,String[])EmptySee DirectiveAnnotationsMapping
fieldsWithResolversSet(String)EmptyFields that require Resolvers should be defined here in format: TypeName.fieldName or TypeName or @directive. E.g.: Person, Person.friends, @customResolver.
fieldsWithoutResolversSet(String)EmptyFields that DO NOT require Resolvers should be defined here in format: TypeName.fieldName or TypeName or @directive. Can be used in conjunction with generateExtensionFieldsResolvers option. E.g.: Person, Person.friends, @noResolver.
generateParameterizedFieldsResolversBooleanTrueIf true, then generate separate Resolver interface for parametrized fields. If false, then add field to the type definition and ignore field parameters.
generateExtensionFieldsResolversBooleanFalseSpecifies whether all fields in extensions (extend type and extend interface) should be present in Resolver interface instead of the type class itself.
generateModelsForRootTypesBooleanFalseSpecifies whether model classes should be generated for type Query, type Subscription, type Mutation.
useOptionalForNullableReturnTypesBooleanFalseSpecifies whether nullable return types of api methods should be wrapped into java.util.Optional<>. Lists will not be wrapped.
apiReturnTypeStringEmptyReturn type for api methods (query/mutation). For example: reactor.core.publisher.Mono, etc.
apiReturnListTypeStringEmptyReturn type for api methods (query/mutation) having list type. For example: reactor.core.publisher.Flux, etc. By default is empty, so apiReturnType will be used.
subscriptionReturnTypeStringEmptyReturn type for subscription methods. For example: org.reactivestreams.Publisher, io.reactivex.Observable, etc.
relayConfigSee RelayConfig@connection(for: ...)See RelayConfig
generateClientBooleanFalseSpecifies whether client-side classes should be generated for each query, mutation and subscription. This includes: Request classes (contain input data), ResponseProjection classes for each type (contain response fields) and Response classes (contain response data).
requestSuffixStringRequestSets the suffix for Request classes.
responseSuffixStringResponseSets the suffix for Response classes.
responseProjectionSuffixStringResponseProjectionSets the suffix for ResponseProjection classes.
parametrizedInputSuffixStringParametrizedInputSets the suffix for ParametrizedInput classes.
parentInterfacesSee parentInterfacesEmptyBlock to define parent interfaces for generated interfaces (query / mutation / subscription / type resolver). See parentInterfaces
responseProjectionMaxDepthInteger3Sets max depth when use all$() which for facilitating the construction of projection automatically, the fields on all projections are provided when it be invoked. This is a global configuration, of course, you can use all$(max) to set for each method. For self recursive types, too big depth may result in a large number of returned data!

Option graphqlSchemas

When exact paths to GraphQL schemas are too cumbersome to provide in the graphqlSchemaPaths, use the graphqlSchemas block. The parameters inside that block are the following:

Key inside graphqlSchemasData TypeDefault valueDescription
rootDirStringMain resources dirThe root directory from which to start searching for schema files.
recursiveBooleantrueWhether to recursively look into sub directories.
includePatternString.*\.graphqls?A Java regex that file names must match to be included. It should be a regex as defined by the Pattern JDK class. It will be used to match only the file name without path.
excludedFilesSet(empty set)A set of files to exclude, even if they match the include pattern. These paths should be either absolute or relative to the provided rootDir.

Option ApiInterfaceStrategy

Defines how to generate interfaces (resolvers) for each operation: Query/Mutation/Subscription. Provides ability to skip generation of separate interface class for each operation in favor of having a single "root" interface (see ApiRootInterfaceStrategy and ApiNamePrefixStrategy)

ValueDescription
INTERFACE_PER_OPERATION(default)Generate separate interface classes for each GraphQL operation.
DO_NOT_GENERATEDo not generate separate interfaces classes for GraphQL operation.

Option ApiRootInterfaceStrategy

Defines how root interface (QueryResolver / MutationResolver / SubscriptionResolver will be generated (in addition to separate interfaces for each query/mutation/subscription)

ValueDescription
INTERFACE_PER_SCHEMAGenerate multiple super-interfaces for each graphql file.
Takes into account apiNamePrefixStrategy.
E.g.: OrderServiceQueryResolver.java, ProductServiceQueryResolver.java, etc.
SINGLE_INTERFACE(default)Generate a single QueryResolver.java, MutationResolver.java, SubscriptionResolver.java for all graphql schema files.
DO_NOT_GENERATEDo not generate super interface for GraphQL operations.

Option ApiNamePrefixStrategy

Defines which prefix to use for API interfaces.

ValueDescription
FILE_NAME_AS_PREFIXWill take GraphQL file name as a prefix for all generated API interfaces + value of apiNamePrefix config option.
E.g.:
* following schemas: resources/schemas/order-service.graphql, resources/schemas/product-service.graphql
* will result in: OrderServiceQueryResolver.java, ProductServiceQueryResolver.java, etc
FOLDER_NAME_AS_PREFIXWill take parent folder name as a prefix for all generated API interfaces + value of apiNamePrefix config option. E.g.:
* following schemas: resources/order-service/schema1.graphql, resources/order-service/schema2.graphql
* will result in: OrderServiceQueryResolver.java, OrderServiceGetOrderByIdQueryResolver.java, etc
CONSTANT(default)Will take only the value of apiNamePrefix config option.

Option parentInterfaces

Following options can be defined if you want generated resolvers to extend certain interfaces. Can be handy if you are using graphql-java-tools and want your resolver classes to extend only interfaces generated by this plugin.

Note: if you want to include a GraphQL type name into the interface name, then use {{TYPE}} placeholder. E.g.: graphql.kickstart.tools.GraphQLResolver<{{TYPE}}>

Key inside parentInterfacesData TypeDefault valueDescription
queryResolverStringEmptyInterface that will be added as "extend" to all generated api Query interfaces.
mutationResolverStringEmptyInterface that will be added as "extend" to all generated api Mutation interfaces.
subscriptionResolverStringEmptyInterface that will be added as "extend" to all generated api Subscription interfaces.
resolverStringEmptyInterface that will be added as "extend" to all generated TypeResolver interfaces.

Option customTypesMapping

Can be used to supply custom mappings for scalars.

Supports following formats:

  • Map of (GraphQLObjectName.fieldName) to (JavaType). E.g.: Event.dateTime = java.util.Date
  • Map of (GraphQLType) to (JavaType). E.g.: EpochMillis = java.time.LocalDateTime

Option customAnnotationsMapping

Can be used to supply custom annotations (serializers) for scalars. @ in front of the annotation class is optional.

Supports following formats:

  • Map of (GraphQLObjectName.fieldName) to (JavaAnnotation). E.g.: Event.dateTime = @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.example.DateDeserializer.class)
  • Map of (GraphQLType) to (JavaAnnotation). E.g.: EpochMillis = @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.example.EpochMillisDeserializer.class)

Option directiveAnnotationsMapping

Can be used to supply custom annotations for directives in a following format: Map of (GraphQL.directiveName) to (JavaAnnotation). E.g.: auth = @org.springframework.security.access.annotation.Secured({{roles}}). @ in front of the annotation class is optional.

Note: In order to supply the value of directive argument to annotation, use placeholder {{directiveArgument}}. You can also use one of the formatters for directive argument value: {{val?toString}}, {{val?toArray}}, {{val?toArrayOfStrings}}.

Option relayConfig

Can be used to supply a custom configuration for Relay support. For reference see: https://www.graphql-java-kickstart.com/tools/relay/

Key inside relayConfigData TypeDefault valueDescription
directiveNameStringconnectionDirective name used for marking a field.
directiveArgumentNameStringforDirective argument name that contains a GraphQL type name.
connectionTypeStringgraphql.relay.ConnectionGeneric Connection type.

For example, the following schema:

type Query { users(first: Int, after: String): UserConnection @connection(for: "User") }

will result in generating the interface with the following method:

graphql.relay.Connection<User> users(Integer first, String after) throws Exception;

External mapping configuration

Provide a path to external file via property jsonConfigurationFile Sample content of the file:

{
"generateApis": true,
"packageName": "com.kobylynskyi.graphql.testconfigjson",
"customTypesMapping": {
"Price.amount": "java.math.BigDecimal"
}
}
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Highlight search terms from Google/DuckDuckGo/Bing referrer\n(function() {\n var ref = document.referrer;\n var terms = [];\n \n if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) {\n var url = new URL(ref);\n var q = url.searchParams.get('q') || url.searchParams.get('p');\n if (q) {\n terms = q.split(/\\s+/).filter(function(t) { return t.length > 2; });\n }\n }\n \n if (terms.length === 0) return;\n \n var style = document.createElement('style');\n style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }';\n document.head.appendChild(style);\n \n function highlight(node) {\n if (node.nodeType === 3) { // text node\n var text = node.textContent;\n var found = false;\n terms.forEach(function(term) {\n var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\') + ')', 'gi');\n if (regex.test(text)) {\n found = true;\n var frag = document.createDocumentFragment();\n var parts = text.split(regex);\n parts.forEach(function(part, i) {\n if (i % 2 === 0) {\n frag.appendChild(document.createTextNode(part));\n } else {\n var span = document.createElement('span');\n span.className = 'userscript-highlight';\n span.textContent = part;\n frag.appendChild(span);\n }\n });\n node.parentNode.replaceChild(frag, node);\n }\n });\n } else if (node.nodeType === 1 && node.childNodes) { // element\n var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT'];\n if (!skipTags.includes(node.tagName)) {\n Array.from(node.childNodes).forEach(highlight);\n }\n }\n }\n \n highlight(document.body);\n \n // Re-highlight on dynamic content\n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1 || node.nodeType === 3) highlight(node);\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Highlight Search Terms"); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

History
177 lines (132 loc) · 19.7 KB

File metadata and controls

177 lines (132 loc) · 19.7 KB

Codegen Options

OptionData TypeDefault valueDescription
graphqlSchemaPathsList(String)(falls back to graphqlSchemas)GraphQL schema locations. You can supply multiple paths to GraphQL schemas. To include many schemas from a folder hierarchy, use the graphqlSchemas block instead.
graphqlSchemasSee graphqlSchemasAll .graphqls/.graphql files in resourcesBlock to define the input GraphQL schemas, when exact paths are too cumbersome. See table below for a list of options. See graphqlSchemas
graphqlQueryIntrospectionResultPathStringNonePath to GraphQL Introspection Query result in json format (with root object __schema or data.__schema). Sample: sample-introspection-query-result.json
outputDirStringNoneThe output target directory into which code will be generated.
jsonConfigurationFileStringEmptyPath to an external mapping configuration.
packageNameStringEmptyJava package for generated classes.
apiPackageNameStringEmptyJava package for generated api classes (Query, Mutation, Subscription).
modelPackageNameStringEmptyJava package for generated model classes (type, input, interface, enum, union).
generateBuilderBooleanTrueSpecifies whether generated model classes should have builder.
generateApisBooleanTrueSpecifies whether api classes should be generated as well as model classes.
generateDataFetchingEnvironmentArgumentInApisBooleanFalseIf true, then graphql.schema.DataFetchingEnvironment env will be added as a last argument to all methods of root type resolvers and field resolvers.
generateEqualsAndHashCodeBooleanFalseSpecifies whether generated model classes should have equals and hashCode methods defined.
generateImmutableModelsBooleanFalseSpecifies whether generated model classes should be immutable.
generateToStringBooleanFalseSpecifies whether generated model classes should have toString method defined.
apiNamePrefixStringEmptySets the prefix for GraphQL api classes (query, mutation, subscription).
apiNameSuffixStringResolverSets the suffix for GraphQL api classes (query, mutation, subscription).
apiInterfaceStrategySee ApiInterfaceStrategyINTERFACE_PER_OPERATIONSee ApiInterfaceStrategy
apiRootInterfaceStrategySee ApiRootInterfaceStrategySINGLE_INTERFACESee ApiRootInterfaceStrategy
apiNamePrefixStrategySee ApiNamePrefixStrategyCONSTANTSee ApiNamePrefixStrategy
modelNamePrefixStringEmptySets the prefix for GraphQL model classes (type, input, interface, enum, union).
modelNameSuffixStringEmptySets the suffix for GraphQL model classes (type, input, interface, enum, union).
modelValidationAnnotationString@javax.validation.
constraints.NotNull
Annotation for mandatory (NonNull) fields. Can be null/empty.
typeResolverPrefixStringEmptySets the prefix for GraphQL type resolver classes.
typeResolverSuffixStringResolverSets the suffix for GraphQL type resolver classes.
customTypesMappingMap(String,String)EmptySee CustomTypesMapping
customAnnotationsMappingMap(String,String[])EmptySee CustomAnnotationsMapping
directiveAnnotationsMappingMap(String,String[])EmptySee DirectiveAnnotationsMapping
fieldsWithResolversSet(String)EmptyFields that require Resolvers should be defined here in format: TypeName.fieldName or TypeName or @directive. E.g.: Person, Person.friends, @customResolver.
fieldsWithoutResolversSet(String)EmptyFields that DO NOT require Resolvers should be defined here in format: TypeName.fieldName or TypeName or @directive. Can be used in conjunction with generateExtensionFieldsResolvers option. E.g.: Person, Person.friends, @noResolver.
generateParameterizedFieldsResolversBooleanTrueIf true, then generate separate Resolver interface for parametrized fields. If false, then add field to the type definition and ignore field parameters.
generateExtensionFieldsResolversBooleanFalseSpecifies whether all fields in extensions (extend type and extend interface) should be present in Resolver interface instead of the type class itself.
generateModelsForRootTypesBooleanFalseSpecifies whether model classes should be generated for type Query, type Subscription, type Mutation.
useOptionalForNullableReturnTypesBooleanFalseSpecifies whether nullable return types of api methods should be wrapped into java.util.Optional<>. Lists will not be wrapped.
apiReturnTypeStringEmptyReturn type for api methods (query/mutation). For example: reactor.core.publisher.Mono, etc.
apiReturnListTypeStringEmptyReturn type for api methods (query/mutation) having list type. For example: reactor.core.publisher.Flux, etc. By default is empty, so apiReturnType will be used.
subscriptionReturnTypeStringEmptyReturn type for subscription methods. For example: org.reactivestreams.Publisher, io.reactivex.Observable, etc.
relayConfigSee RelayConfig@connection(for: ...)See RelayConfig
generateClientBooleanFalseSpecifies whether client-side classes should be generated for each query, mutation and subscription. This includes: Request classes (contain input data), ResponseProjection classes for each type (contain response fields) and Response classes (contain response data).
requestSuffixStringRequestSets the suffix for Request classes.
responseSuffixStringResponseSets the suffix for Response classes.
responseProjectionSuffixStringResponseProjectionSets the suffix for ResponseProjection classes.
parametrizedInputSuffixStringParametrizedInputSets the suffix for ParametrizedInput classes.
parentInterfacesSee parentInterfacesEmptyBlock to define parent interfaces for generated interfaces (query / mutation / subscription / type resolver). See parentInterfaces
responseProjectionMaxDepthInteger3Sets max depth when use all$() which for facilitating the construction of projection automatically, the fields on all projections are provided when it be invoked. This is a global configuration, of course, you can use all$(max) to set for each method. For self recursive types, too big depth may result in a large number of returned data!

Option graphqlSchemas

When exact paths to GraphQL schemas are too cumbersome to provide in the graphqlSchemaPaths, use the graphqlSchemas block. The parameters inside that block are the following:

Key inside graphqlSchemasData TypeDefault valueDescription
rootDirStringMain resources dirThe root directory from which to start searching for schema files.
recursiveBooleantrueWhether to recursively look into sub directories.
includePatternString.*\.graphqls?A Java regex that file names must match to be included. It should be a regex as defined by the Pattern JDK class. It will be used to match only the file name without path.
excludedFilesSet(empty set)A set of files to exclude, even if they match the include pattern. These paths should be either absolute or relative to the provided rootDir.

Option ApiInterfaceStrategy

Defines how to generate interfaces (resolvers) for each operation: Query/Mutation/Subscription. Provides ability to skip generation of separate interface class for each operation in favor of having a single "root" interface (see ApiRootInterfaceStrategy and ApiNamePrefixStrategy)

ValueDescription
INTERFACE_PER_OPERATION(default)Generate separate interface classes for each GraphQL operation.
DO_NOT_GENERATEDo not generate separate interfaces classes for GraphQL operation.

Option ApiRootInterfaceStrategy

Defines how root interface (QueryResolver / MutationResolver / SubscriptionResolver will be generated (in addition to separate interfaces for each query/mutation/subscription)

ValueDescription
INTERFACE_PER_SCHEMAGenerate multiple super-interfaces for each graphql file.
Takes into account apiNamePrefixStrategy.
E.g.: OrderServiceQueryResolver.java, ProductServiceQueryResolver.java, etc.
SINGLE_INTERFACE(default)Generate a single QueryResolver.java, MutationResolver.java, SubscriptionResolver.java for all graphql schema files.
DO_NOT_GENERATEDo not generate super interface for GraphQL operations.

Option ApiNamePrefixStrategy

Defines which prefix to use for API interfaces.

ValueDescription
FILE_NAME_AS_PREFIXWill take GraphQL file name as a prefix for all generated API interfaces + value of apiNamePrefix config option.
E.g.:
* following schemas: resources/schemas/order-service.graphql, resources/schemas/product-service.graphql
* will result in: OrderServiceQueryResolver.java, ProductServiceQueryResolver.java, etc
FOLDER_NAME_AS_PREFIXWill take parent folder name as a prefix for all generated API interfaces + value of apiNamePrefix config option. E.g.:
* following schemas: resources/order-service/schema1.graphql, resources/order-service/schema2.graphql
* will result in: OrderServiceQueryResolver.java, OrderServiceGetOrderByIdQueryResolver.java, etc
CONSTANT(default)Will take only the value of apiNamePrefix config option.

Option parentInterfaces

Following options can be defined if you want generated resolvers to extend certain interfaces. Can be handy if you are using graphql-java-tools and want your resolver classes to extend only interfaces generated by this plugin.

Note: if you want to include a GraphQL type name into the interface name, then use {{TYPE}} placeholder. E.g.: graphql.kickstart.tools.GraphQLResolver<{{TYPE}}>

Key inside parentInterfacesData TypeDefault valueDescription
queryResolverStringEmptyInterface that will be added as "extend" to all generated api Query interfaces.
mutationResolverStringEmptyInterface that will be added as "extend" to all generated api Mutation interfaces.
subscriptionResolverStringEmptyInterface that will be added as "extend" to all generated api Subscription interfaces.
resolverStringEmptyInterface that will be added as "extend" to all generated TypeResolver interfaces.

Option customTypesMapping

Can be used to supply custom mappings for scalars.

Supports following formats:

  • Map of (GraphQLObjectName.fieldName) to (JavaType). E.g.: Event.dateTime = java.util.Date
  • Map of (GraphQLType) to (JavaType). E.g.: EpochMillis = java.time.LocalDateTime

Option customAnnotationsMapping

Can be used to supply custom annotations (serializers) for scalars. @ in front of the annotation class is optional.

Supports following formats:

  • Map of (GraphQLObjectName.fieldName) to (JavaAnnotation). E.g.: Event.dateTime = @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.example.DateDeserializer.class)
  • Map of (GraphQLType) to (JavaAnnotation). E.g.: EpochMillis = @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.example.EpochMillisDeserializer.class)

Option directiveAnnotationsMapping

Can be used to supply custom annotations for directives in a following format: Map of (GraphQL.directiveName) to (JavaAnnotation). E.g.: auth = @org.springframework.security.access.annotation.Secured({{roles}}). @ in front of the annotation class is optional.

Note: In order to supply the value of directive argument to annotation, use placeholder {{directiveArgument}}. You can also use one of the formatters for directive argument value: {{val?toString}}, {{val?toArray}}, {{val?toArrayOfStrings}}.

Option relayConfig

Can be used to supply a custom configuration for Relay support. For reference see: https://www.graphql-java-kickstart.com/tools/relay/

Key inside relayConfigData TypeDefault valueDescription
directiveNameStringconnectionDirective name used for marking a field.
directiveArgumentNameStringforDirective argument name that contains a GraphQL type name.
connectionTypeStringgraphql.relay.ConnectionGeneric Connection type.

For example, the following schema:

type Query { users(first: Int, after: String): UserConnection @connection(for: "User") }

will result in generating the interface with the following method:

graphql.relay.Connection<User> users(Integer first, String after) throws Exception;

External mapping configuration

Provide a path to external file via property jsonConfigurationFile Sample content of the file:

{
"generateApis": true,
"packageName": "com.kobylynskyi.graphql.testconfigjson",
"customTypesMapping": {
"Price.amount": "java.math.BigDecimal"
}
}
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Strip utm_, fbclid, gclid, etc. from all links on page\n(function() {\n var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content',\n 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid',\n 'ref', 'ref_src', 'source', 'medium', 'campaign'];\n \n function cleanUrl(url) {\n try {\n var u = new URL(url, window.location.origin);\n var changed = false;\n trackingParams.forEach(function(p) {\n if (u.searchParams.has(p)) {\n u.searchParams.delete(p);\n changed = true;\n }\n });\n return changed ? u.toString() : url;\n } catch (e) {\n return url;\n }\n }\n \n function cleanLinks() {\n document.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n \n cleanLinks();\n \n var observer = new MutationObserver(function(mutations) {\n mutations.forEach(function(m) {\n m.addedNodes.forEach(function(node) {\n if (node.nodeType === 1) {\n if (node.tagName === 'A') cleanLinks();\n node.querySelectorAll('a[href]').forEach(function(a) {\n var clean = cleanUrl(a.href);\n if (clean !== a.href) a.href = clean;\n });\n }\n });\n });\n });\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "Remove Tracking Parameters from Links"); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + '
Skip to content

Latest commit

History

History
177 lines (132 loc) · 19.7 KB

File metadata and controls

177 lines (132 loc) · 19.7 KB

Codegen Options

OptionData TypeDefault valueDescription
graphqlSchemaPathsList(String)(falls back to graphqlSchemas)GraphQL schema locations. You can supply multiple paths to GraphQL schemas. To include many schemas from a folder hierarchy, use the graphqlSchemas block instead.
graphqlSchemasSee graphqlSchemasAll .graphqls/.graphql files in resourcesBlock to define the input GraphQL schemas, when exact paths are too cumbersome. See table below for a list of options. See graphqlSchemas
graphqlQueryIntrospectionResultPathStringNonePath to GraphQL Introspection Query result in json format (with root object __schema or data.__schema). Sample: sample-introspection-query-result.json
outputDirStringNoneThe output target directory into which code will be generated.
jsonConfigurationFileStringEmptyPath to an external mapping configuration.
packageNameStringEmptyJava package for generated classes.
apiPackageNameStringEmptyJava package for generated api classes (Query, Mutation, Subscription).
modelPackageNameStringEmptyJava package for generated model classes (type, input, interface, enum, union).
generateBuilderBooleanTrueSpecifies whether generated model classes should have builder.
generateApisBooleanTrueSpecifies whether api classes should be generated as well as model classes.
generateDataFetchingEnvironmentArgumentInApisBooleanFalseIf true, then graphql.schema.DataFetchingEnvironment env will be added as a last argument to all methods of root type resolvers and field resolvers.
generateEqualsAndHashCodeBooleanFalseSpecifies whether generated model classes should have equals and hashCode methods defined.
generateImmutableModelsBooleanFalseSpecifies whether generated model classes should be immutable.
generateToStringBooleanFalseSpecifies whether generated model classes should have toString method defined.
apiNamePrefixStringEmptySets the prefix for GraphQL api classes (query, mutation, subscription).
apiNameSuffixStringResolverSets the suffix for GraphQL api classes (query, mutation, subscription).
apiInterfaceStrategySee ApiInterfaceStrategyINTERFACE_PER_OPERATIONSee ApiInterfaceStrategy
apiRootInterfaceStrategySee ApiRootInterfaceStrategySINGLE_INTERFACESee ApiRootInterfaceStrategy
apiNamePrefixStrategySee ApiNamePrefixStrategyCONSTANTSee ApiNamePrefixStrategy
modelNamePrefixStringEmptySets the prefix for GraphQL model classes (type, input, interface, enum, union).
modelNameSuffixStringEmptySets the suffix for GraphQL model classes (type, input, interface, enum, union).
modelValidationAnnotationString@javax.validation.
constraints.NotNull
Annotation for mandatory (NonNull) fields. Can be null/empty.
typeResolverPrefixStringEmptySets the prefix for GraphQL type resolver classes.
typeResolverSuffixStringResolverSets the suffix for GraphQL type resolver classes.
customTypesMappingMap(String,String)EmptySee CustomTypesMapping
customAnnotationsMappingMap(String,String[])EmptySee CustomAnnotationsMapping
directiveAnnotationsMappingMap(String,String[])EmptySee DirectiveAnnotationsMapping
fieldsWithResolversSet(String)EmptyFields that require Resolvers should be defined here in format: TypeName.fieldName or TypeName or @directive. E.g.: Person, Person.friends, @customResolver.
fieldsWithoutResolversSet(String)EmptyFields that DO NOT require Resolvers should be defined here in format: TypeName.fieldName or TypeName or @directive. Can be used in conjunction with generateExtensionFieldsResolvers option. E.g.: Person, Person.friends, @noResolver.
generateParameterizedFieldsResolversBooleanTrueIf true, then generate separate Resolver interface for parametrized fields. If false, then add field to the type definition and ignore field parameters.
generateExtensionFieldsResolversBooleanFalseSpecifies whether all fields in extensions (extend type and extend interface) should be present in Resolver interface instead of the type class itself.
generateModelsForRootTypesBooleanFalseSpecifies whether model classes should be generated for type Query, type Subscription, type Mutation.
useOptionalForNullableReturnTypesBooleanFalseSpecifies whether nullable return types of api methods should be wrapped into java.util.Optional<>. Lists will not be wrapped.
apiReturnTypeStringEmptyReturn type for api methods (query/mutation). For example: reactor.core.publisher.Mono, etc.
apiReturnListTypeStringEmptyReturn type for api methods (query/mutation) having list type. For example: reactor.core.publisher.Flux, etc. By default is empty, so apiReturnType will be used.
subscriptionReturnTypeStringEmptyReturn type for subscription methods. For example: org.reactivestreams.Publisher, io.reactivex.Observable, etc.
relayConfigSee RelayConfig@connection(for: ...)See RelayConfig
generateClientBooleanFalseSpecifies whether client-side classes should be generated for each query, mutation and subscription. This includes: Request classes (contain input data), ResponseProjection classes for each type (contain response fields) and Response classes (contain response data).
requestSuffixStringRequestSets the suffix for Request classes.
responseSuffixStringResponseSets the suffix for Response classes.
responseProjectionSuffixStringResponseProjectionSets the suffix for ResponseProjection classes.
parametrizedInputSuffixStringParametrizedInputSets the suffix for ParametrizedInput classes.
parentInterfacesSee parentInterfacesEmptyBlock to define parent interfaces for generated interfaces (query / mutation / subscription / type resolver). See parentInterfaces
responseProjectionMaxDepthInteger3Sets max depth when use all$() which for facilitating the construction of projection automatically, the fields on all projections are provided when it be invoked. This is a global configuration, of course, you can use all$(max) to set for each method. For self recursive types, too big depth may result in a large number of returned data!

Option graphqlSchemas

When exact paths to GraphQL schemas are too cumbersome to provide in the graphqlSchemaPaths, use the graphqlSchemas block. The parameters inside that block are the following:

Key inside graphqlSchemasData TypeDefault valueDescription
rootDirStringMain resources dirThe root directory from which to start searching for schema files.
recursiveBooleantrueWhether to recursively look into sub directories.
includePatternString.*\.graphqls?A Java regex that file names must match to be included. It should be a regex as defined by the Pattern JDK class. It will be used to match only the file name without path.
excludedFilesSet(empty set)A set of files to exclude, even if they match the include pattern. These paths should be either absolute or relative to the provided rootDir.

Option ApiInterfaceStrategy

Defines how to generate interfaces (resolvers) for each operation: Query/Mutation/Subscription. Provides ability to skip generation of separate interface class for each operation in favor of having a single "root" interface (see ApiRootInterfaceStrategy and ApiNamePrefixStrategy)

ValueDescription
INTERFACE_PER_OPERATION(default)Generate separate interface classes for each GraphQL operation.
DO_NOT_GENERATEDo not generate separate interfaces classes for GraphQL operation.

Option ApiRootInterfaceStrategy

Defines how root interface (QueryResolver / MutationResolver / SubscriptionResolver will be generated (in addition to separate interfaces for each query/mutation/subscription)

ValueDescription
INTERFACE_PER_SCHEMAGenerate multiple super-interfaces for each graphql file.
Takes into account apiNamePrefixStrategy.
E.g.: OrderServiceQueryResolver.java, ProductServiceQueryResolver.java, etc.
SINGLE_INTERFACE(default)Generate a single QueryResolver.java, MutationResolver.java, SubscriptionResolver.java for all graphql schema files.
DO_NOT_GENERATEDo not generate super interface for GraphQL operations.

Option ApiNamePrefixStrategy

Defines which prefix to use for API interfaces.

ValueDescription
FILE_NAME_AS_PREFIXWill take GraphQL file name as a prefix for all generated API interfaces + value of apiNamePrefix config option.
E.g.:
* following schemas: resources/schemas/order-service.graphql, resources/schemas/product-service.graphql
* will result in: OrderServiceQueryResolver.java, ProductServiceQueryResolver.java, etc
FOLDER_NAME_AS_PREFIXWill take parent folder name as a prefix for all generated API interfaces + value of apiNamePrefix config option. E.g.:
* following schemas: resources/order-service/schema1.graphql, resources/order-service/schema2.graphql
* will result in: OrderServiceQueryResolver.java, OrderServiceGetOrderByIdQueryResolver.java, etc
CONSTANT(default)Will take only the value of apiNamePrefix config option.

Option parentInterfaces

Following options can be defined if you want generated resolvers to extend certain interfaces. Can be handy if you are using graphql-java-tools and want your resolver classes to extend only interfaces generated by this plugin.

Note: if you want to include a GraphQL type name into the interface name, then use {{TYPE}} placeholder. E.g.: graphql.kickstart.tools.GraphQLResolver<{{TYPE}}>

Key inside parentInterfacesData TypeDefault valueDescription
queryResolverStringEmptyInterface that will be added as "extend" to all generated api Query interfaces.
mutationResolverStringEmptyInterface that will be added as "extend" to all generated api Mutation interfaces.
subscriptionResolverStringEmptyInterface that will be added as "extend" to all generated api Subscription interfaces.
resolverStringEmptyInterface that will be added as "extend" to all generated TypeResolver interfaces.

Option customTypesMapping

Can be used to supply custom mappings for scalars.

Supports following formats:

  • Map of (GraphQLObjectName.fieldName) to (JavaType). E.g.: Event.dateTime = java.util.Date
  • Map of (GraphQLType) to (JavaType). E.g.: EpochMillis = java.time.LocalDateTime

Option customAnnotationsMapping

Can be used to supply custom annotations (serializers) for scalars. @ in front of the annotation class is optional.

Supports following formats:

  • Map of (GraphQLObjectName.fieldName) to (JavaAnnotation). E.g.: Event.dateTime = @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.example.DateDeserializer.class)
  • Map of (GraphQLType) to (JavaAnnotation). E.g.: EpochMillis = @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.example.EpochMillisDeserializer.class)

Option directiveAnnotationsMapping

Can be used to supply custom annotations for directives in a following format: Map of (GraphQL.directiveName) to (JavaAnnotation). E.g.: auth = @org.springframework.security.access.annotation.Secured({{roles}}). @ in front of the annotation class is optional.

Note: In order to supply the value of directive argument to annotation, use placeholder {{directiveArgument}}. You can also use one of the formatters for directive argument value: {{val?toString}}, {{val?toArray}}, {{val?toArrayOfStrings}}.

Option relayConfig

Can be used to supply a custom configuration for Relay support. For reference see: https://www.graphql-java-kickstart.com/tools/relay/

Key inside relayConfigData TypeDefault valueDescription
directiveNameStringconnectionDirective name used for marking a field.
directiveArgumentNameStringforDirective argument name that contains a GraphQL type name.
connectionTypeStringgraphql.relay.ConnectionGeneric Connection type.

For example, the following schema:

type Query { users(first: Int, after: String): UserConnection @connection(for: "User") }

will result in generating the interface with the following method:

graphql.relay.Connection<User> users(Integer first, String after) throws Exception;

External mapping configuration

Provide a path to external file via property jsonConfigurationFile Sample content of the file:

{
"generateApis": true,
"packageName": "com.kobylynskyi.graphql.testconfigjson",
"customTypesMapping": {
"Price.amount": "java.math.BigDecimal"
}
}
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Auto-enable theater mode on YouTube\n(function() {\n function tryTheater() {\n var btn = document.querySelector('button[aria-label=\"Theater mode\"], ytd-player #player button[title=\"Theater mode\"]');\n if (btn && !btn.classList.contains('activated')) {\n btn.click();\n }\n }\n \n // Try immediately\n tryTheater();\n \n // Try after navigation (SPA)\n var lastUrl = location.href;\n setInterval(function() {\n if (location.href !== lastUrl) {\n lastUrl = location.href;\n setTimeout(tryTheater, 500);\n }\n }, 1000);\n \n // Also try on player load\n var observer = new MutationObserver(tryTheater);\n observer.observe(document.body, { childList: true, subtree: true });\n})();", "YouTube Theater Mode Default"); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

History
177 lines (132 loc) · 19.7 KB

File metadata and controls

177 lines (132 loc) · 19.7 KB

Codegen Options

OptionData TypeDefault valueDescription
graphqlSchemaPathsList(String)(falls back to graphqlSchemas)GraphQL schema locations. You can supply multiple paths to GraphQL schemas. To include many schemas from a folder hierarchy, use the graphqlSchemas block instead.
graphqlSchemasSee graphqlSchemasAll .graphqls/.graphql files in resourcesBlock to define the input GraphQL schemas, when exact paths are too cumbersome. See table below for a list of options. See graphqlSchemas
graphqlQueryIntrospectionResultPathStringNonePath to GraphQL Introspection Query result in json format (with root object __schema or data.__schema). Sample: sample-introspection-query-result.json
outputDirStringNoneThe output target directory into which code will be generated.
jsonConfigurationFileStringEmptyPath to an external mapping configuration.
packageNameStringEmptyJava package for generated classes.
apiPackageNameStringEmptyJava package for generated api classes (Query, Mutation, Subscription).
modelPackageNameStringEmptyJava package for generated model classes (type, input, interface, enum, union).
generateBuilderBooleanTrueSpecifies whether generated model classes should have builder.
generateApisBooleanTrueSpecifies whether api classes should be generated as well as model classes.
generateDataFetchingEnvironmentArgumentInApisBooleanFalseIf true, then graphql.schema.DataFetchingEnvironment env will be added as a last argument to all methods of root type resolvers and field resolvers.
generateEqualsAndHashCodeBooleanFalseSpecifies whether generated model classes should have equals and hashCode methods defined.
generateImmutableModelsBooleanFalseSpecifies whether generated model classes should be immutable.
generateToStringBooleanFalseSpecifies whether generated model classes should have toString method defined.
apiNamePrefixStringEmptySets the prefix for GraphQL api classes (query, mutation, subscription).
apiNameSuffixStringResolverSets the suffix for GraphQL api classes (query, mutation, subscription).
apiInterfaceStrategySee ApiInterfaceStrategyINTERFACE_PER_OPERATIONSee ApiInterfaceStrategy
apiRootInterfaceStrategySee ApiRootInterfaceStrategySINGLE_INTERFACESee ApiRootInterfaceStrategy
apiNamePrefixStrategySee ApiNamePrefixStrategyCONSTANTSee ApiNamePrefixStrategy
modelNamePrefixStringEmptySets the prefix for GraphQL model classes (type, input, interface, enum, union).
modelNameSuffixStringEmptySets the suffix for GraphQL model classes (type, input, interface, enum, union).
modelValidationAnnotationString@javax.validation.
constraints.NotNull
Annotation for mandatory (NonNull) fields. Can be null/empty.
typeResolverPrefixStringEmptySets the prefix for GraphQL type resolver classes.
typeResolverSuffixStringResolverSets the suffix for GraphQL type resolver classes.
customTypesMappingMap(String,String)EmptySee CustomTypesMapping
customAnnotationsMappingMap(String,String[])EmptySee CustomAnnotationsMapping
directiveAnnotationsMappingMap(String,String[])EmptySee DirectiveAnnotationsMapping
fieldsWithResolversSet(String)EmptyFields that require Resolvers should be defined here in format: TypeName.fieldName or TypeName or @directive. E.g.: Person, Person.friends, @customResolver.
fieldsWithoutResolversSet(String)EmptyFields that DO NOT require Resolvers should be defined here in format: TypeName.fieldName or TypeName or @directive. Can be used in conjunction with generateExtensionFieldsResolvers option. E.g.: Person, Person.friends, @noResolver.
generateParameterizedFieldsResolversBooleanTrueIf true, then generate separate Resolver interface for parametrized fields. If false, then add field to the type definition and ignore field parameters.
generateExtensionFieldsResolversBooleanFalseSpecifies whether all fields in extensions (extend type and extend interface) should be present in Resolver interface instead of the type class itself.
generateModelsForRootTypesBooleanFalseSpecifies whether model classes should be generated for type Query, type Subscription, type Mutation.
useOptionalForNullableReturnTypesBooleanFalseSpecifies whether nullable return types of api methods should be wrapped into java.util.Optional<>. Lists will not be wrapped.
apiReturnTypeStringEmptyReturn type for api methods (query/mutation). For example: reactor.core.publisher.Mono, etc.
apiReturnListTypeStringEmptyReturn type for api methods (query/mutation) having list type. For example: reactor.core.publisher.Flux, etc. By default is empty, so apiReturnType will be used.
subscriptionReturnTypeStringEmptyReturn type for subscription methods. For example: org.reactivestreams.Publisher, io.reactivex.Observable, etc.
relayConfigSee RelayConfig@connection(for: ...)See RelayConfig
generateClientBooleanFalseSpecifies whether client-side classes should be generated for each query, mutation and subscription. This includes: Request classes (contain input data), ResponseProjection classes for each type (contain response fields) and Response classes (contain response data).
requestSuffixStringRequestSets the suffix for Request classes.
responseSuffixStringResponseSets the suffix for Response classes.
responseProjectionSuffixStringResponseProjectionSets the suffix for ResponseProjection classes.
parametrizedInputSuffixStringParametrizedInputSets the suffix for ParametrizedInput classes.
parentInterfacesSee parentInterfacesEmptyBlock to define parent interfaces for generated interfaces (query / mutation / subscription / type resolver). See parentInterfaces
responseProjectionMaxDepthInteger3Sets max depth when use all$() which for facilitating the construction of projection automatically, the fields on all projections are provided when it be invoked. This is a global configuration, of course, you can use all$(max) to set for each method. For self recursive types, too big depth may result in a large number of returned data!

Option graphqlSchemas

When exact paths to GraphQL schemas are too cumbersome to provide in the graphqlSchemaPaths, use the graphqlSchemas block. The parameters inside that block are the following:

Key inside graphqlSchemasData TypeDefault valueDescription
rootDirStringMain resources dirThe root directory from which to start searching for schema files.
recursiveBooleantrueWhether to recursively look into sub directories.
includePatternString.*\.graphqls?A Java regex that file names must match to be included. It should be a regex as defined by the Pattern JDK class. It will be used to match only the file name without path.
excludedFilesSet(empty set)A set of files to exclude, even if they match the include pattern. These paths should be either absolute or relative to the provided rootDir.

Option ApiInterfaceStrategy

Defines how to generate interfaces (resolvers) for each operation: Query/Mutation/Subscription. Provides ability to skip generation of separate interface class for each operation in favor of having a single "root" interface (see ApiRootInterfaceStrategy and ApiNamePrefixStrategy)

ValueDescription
INTERFACE_PER_OPERATION(default)Generate separate interface classes for each GraphQL operation.
DO_NOT_GENERATEDo not generate separate interfaces classes for GraphQL operation.

Option ApiRootInterfaceStrategy

Defines how root interface (QueryResolver / MutationResolver / SubscriptionResolver will be generated (in addition to separate interfaces for each query/mutation/subscription)

ValueDescription
INTERFACE_PER_SCHEMAGenerate multiple super-interfaces for each graphql file.
Takes into account apiNamePrefixStrategy.
E.g.: OrderServiceQueryResolver.java, ProductServiceQueryResolver.java, etc.
SINGLE_INTERFACE(default)Generate a single QueryResolver.java, MutationResolver.java, SubscriptionResolver.java for all graphql schema files.
DO_NOT_GENERATEDo not generate super interface for GraphQL operations.

Option ApiNamePrefixStrategy

Defines which prefix to use for API interfaces.

ValueDescription
FILE_NAME_AS_PREFIXWill take GraphQL file name as a prefix for all generated API interfaces + value of apiNamePrefix config option.
E.g.:
* following schemas: resources/schemas/order-service.graphql, resources/schemas/product-service.graphql
* will result in: OrderServiceQueryResolver.java, ProductServiceQueryResolver.java, etc
FOLDER_NAME_AS_PREFIXWill take parent folder name as a prefix for all generated API interfaces + value of apiNamePrefix config option. E.g.:
* following schemas: resources/order-service/schema1.graphql, resources/order-service/schema2.graphql
* will result in: OrderServiceQueryResolver.java, OrderServiceGetOrderByIdQueryResolver.java, etc
CONSTANT(default)Will take only the value of apiNamePrefix config option.

Option parentInterfaces

Following options can be defined if you want generated resolvers to extend certain interfaces. Can be handy if you are using graphql-java-tools and want your resolver classes to extend only interfaces generated by this plugin.

Note: if you want to include a GraphQL type name into the interface name, then use {{TYPE}} placeholder. E.g.: graphql.kickstart.tools.GraphQLResolver<{{TYPE}}>

Key inside parentInterfacesData TypeDefault valueDescription
queryResolverStringEmptyInterface that will be added as "extend" to all generated api Query interfaces.
mutationResolverStringEmptyInterface that will be added as "extend" to all generated api Mutation interfaces.
subscriptionResolverStringEmptyInterface that will be added as "extend" to all generated api Subscription interfaces.
resolverStringEmptyInterface that will be added as "extend" to all generated TypeResolver interfaces.

Option customTypesMapping

Can be used to supply custom mappings for scalars.

Supports following formats:

  • Map of (GraphQLObjectName.fieldName) to (JavaType). E.g.: Event.dateTime = java.util.Date
  • Map of (GraphQLType) to (JavaType). E.g.: EpochMillis = java.time.LocalDateTime

Option customAnnotationsMapping

Can be used to supply custom annotations (serializers) for scalars. @ in front of the annotation class is optional.

Supports following formats:

  • Map of (GraphQLObjectName.fieldName) to (JavaAnnotation). E.g.: Event.dateTime = @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.example.DateDeserializer.class)
  • Map of (GraphQLType) to (JavaAnnotation). E.g.: EpochMillis = @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.example.EpochMillisDeserializer.class)

Option directiveAnnotationsMapping

Can be used to supply custom annotations for directives in a following format: Map of (GraphQL.directiveName) to (JavaAnnotation). E.g.: auth = @org.springframework.security.access.annotation.Secured({{roles}}). @ in front of the annotation class is optional.

Note: In order to supply the value of directive argument to annotation, use placeholder {{directiveArgument}}. You can also use one of the formatters for directive argument value: {{val?toString}}, {{val?toArray}}, {{val?toArrayOfStrings}}.

Option relayConfig

Can be used to supply a custom configuration for Relay support. For reference see: https://www.graphql-java-kickstart.com/tools/relay/

Key inside relayConfigData TypeDefault valueDescription
directiveNameStringconnectionDirective name used for marking a field.
directiveArgumentNameStringforDirective argument name that contains a GraphQL type name.
connectionTypeStringgraphql.relay.ConnectionGeneric Connection type.

For example, the following schema:

type Query { users(first: Int, after: String): UserConnection @connection(for: "User") }

will result in generating the interface with the following method:

graphql.relay.Connection<User> users(Integer first, String after) throws Exception;

External mapping configuration

Provide a path to external file via property jsonConfigurationFile Sample content of the file:

{
"generateApis": true,
"packageName": "com.kobylynskyi.graphql.testconfigjson",
"customTypesMapping": {
"Price.amount": "java.math.BigDecimal"
}
}
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Remove or un-stick sticky/fixed headers that block content\n(function() {\n function unstick() {\n document.querySelectorAll('header, nav, [role=\"banner\"], .header, .navbar, .sticky, .fixed-top, [style*=\"position: fixed\"], [style*=\"position:sticky\"]').forEach(function(el) {\n if (el.style.position === 'fixed' || el.style.position === 'sticky' || \n getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') {\n el.style.position = 'static';\n el.style.top = 'auto';\n el.style.zIndex = 'auto';\n }\n });\n }\n \n unstick();\n \n var observer = new MutationObserver(unstick);\n observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] });\n})();", "Kill Sticky Headers"); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + '
Skip to content

Latest commit

History

History
177 lines (132 loc) · 19.7 KB

File metadata and controls

177 lines (132 loc) · 19.7 KB

Codegen Options

OptionData TypeDefault valueDescription
graphqlSchemaPathsList(String)(falls back to graphqlSchemas)GraphQL schema locations. You can supply multiple paths to GraphQL schemas. To include many schemas from a folder hierarchy, use the graphqlSchemas block instead.
graphqlSchemasSee graphqlSchemasAll .graphqls/.graphql files in resourcesBlock to define the input GraphQL schemas, when exact paths are too cumbersome. See table below for a list of options. See graphqlSchemas
graphqlQueryIntrospectionResultPathStringNonePath to GraphQL Introspection Query result in json format (with root object __schema or data.__schema). Sample: sample-introspection-query-result.json
outputDirStringNoneThe output target directory into which code will be generated.
jsonConfigurationFileStringEmptyPath to an external mapping configuration.
packageNameStringEmptyJava package for generated classes.
apiPackageNameStringEmptyJava package for generated api classes (Query, Mutation, Subscription).
modelPackageNameStringEmptyJava package for generated model classes (type, input, interface, enum, union).
generateBuilderBooleanTrueSpecifies whether generated model classes should have builder.
generateApisBooleanTrueSpecifies whether api classes should be generated as well as model classes.
generateDataFetchingEnvironmentArgumentInApisBooleanFalseIf true, then graphql.schema.DataFetchingEnvironment env will be added as a last argument to all methods of root type resolvers and field resolvers.
generateEqualsAndHashCodeBooleanFalseSpecifies whether generated model classes should have equals and hashCode methods defined.
generateImmutableModelsBooleanFalseSpecifies whether generated model classes should be immutable.
generateToStringBooleanFalseSpecifies whether generated model classes should have toString method defined.
apiNamePrefixStringEmptySets the prefix for GraphQL api classes (query, mutation, subscription).
apiNameSuffixStringResolverSets the suffix for GraphQL api classes (query, mutation, subscription).
apiInterfaceStrategySee ApiInterfaceStrategyINTERFACE_PER_OPERATIONSee ApiInterfaceStrategy
apiRootInterfaceStrategySee ApiRootInterfaceStrategySINGLE_INTERFACESee ApiRootInterfaceStrategy
apiNamePrefixStrategySee ApiNamePrefixStrategyCONSTANTSee ApiNamePrefixStrategy
modelNamePrefixStringEmptySets the prefix for GraphQL model classes (type, input, interface, enum, union).
modelNameSuffixStringEmptySets the suffix for GraphQL model classes (type, input, interface, enum, union).
modelValidationAnnotationString@javax.validation.
constraints.NotNull
Annotation for mandatory (NonNull) fields. Can be null/empty.
typeResolverPrefixStringEmptySets the prefix for GraphQL type resolver classes.
typeResolverSuffixStringResolverSets the suffix for GraphQL type resolver classes.
customTypesMappingMap(String,String)EmptySee CustomTypesMapping
customAnnotationsMappingMap(String,String[])EmptySee CustomAnnotationsMapping
directiveAnnotationsMappingMap(String,String[])EmptySee DirectiveAnnotationsMapping
fieldsWithResolversSet(String)EmptyFields that require Resolvers should be defined here in format: TypeName.fieldName or TypeName or @directive. E.g.: Person, Person.friends, @customResolver.
fieldsWithoutResolversSet(String)EmptyFields that DO NOT require Resolvers should be defined here in format: TypeName.fieldName or TypeName or @directive. Can be used in conjunction with generateExtensionFieldsResolvers option. E.g.: Person, Person.friends, @noResolver.
generateParameterizedFieldsResolversBooleanTrueIf true, then generate separate Resolver interface for parametrized fields. If false, then add field to the type definition and ignore field parameters.
generateExtensionFieldsResolversBooleanFalseSpecifies whether all fields in extensions (extend type and extend interface) should be present in Resolver interface instead of the type class itself.
generateModelsForRootTypesBooleanFalseSpecifies whether model classes should be generated for type Query, type Subscription, type Mutation.
useOptionalForNullableReturnTypesBooleanFalseSpecifies whether nullable return types of api methods should be wrapped into java.util.Optional<>. Lists will not be wrapped.
apiReturnTypeStringEmptyReturn type for api methods (query/mutation). For example: reactor.core.publisher.Mono, etc.
apiReturnListTypeStringEmptyReturn type for api methods (query/mutation) having list type. For example: reactor.core.publisher.Flux, etc. By default is empty, so apiReturnType will be used.
subscriptionReturnTypeStringEmptyReturn type for subscription methods. For example: org.reactivestreams.Publisher, io.reactivex.Observable, etc.
relayConfigSee RelayConfig@connection(for: ...)See RelayConfig
generateClientBooleanFalseSpecifies whether client-side classes should be generated for each query, mutation and subscription. This includes: Request classes (contain input data), ResponseProjection classes for each type (contain response fields) and Response classes (contain response data).
requestSuffixStringRequestSets the suffix for Request classes.
responseSuffixStringResponseSets the suffix for Response classes.
responseProjectionSuffixStringResponseProjectionSets the suffix for ResponseProjection classes.
parametrizedInputSuffixStringParametrizedInputSets the suffix for ParametrizedInput classes.
parentInterfacesSee parentInterfacesEmptyBlock to define parent interfaces for generated interfaces (query / mutation / subscription / type resolver). See parentInterfaces
responseProjectionMaxDepthInteger3Sets max depth when use all$() which for facilitating the construction of projection automatically, the fields on all projections are provided when it be invoked. This is a global configuration, of course, you can use all$(max) to set for each method. For self recursive types, too big depth may result in a large number of returned data!

Option graphqlSchemas

When exact paths to GraphQL schemas are too cumbersome to provide in the graphqlSchemaPaths, use the graphqlSchemas block. The parameters inside that block are the following:

Key inside graphqlSchemasData TypeDefault valueDescription
rootDirStringMain resources dirThe root directory from which to start searching for schema files.
recursiveBooleantrueWhether to recursively look into sub directories.
includePatternString.*\.graphqls?A Java regex that file names must match to be included. It should be a regex as defined by the Pattern JDK class. It will be used to match only the file name without path.
excludedFilesSet(empty set)A set of files to exclude, even if they match the include pattern. These paths should be either absolute or relative to the provided rootDir.

Option ApiInterfaceStrategy

Defines how to generate interfaces (resolvers) for each operation: Query/Mutation/Subscription. Provides ability to skip generation of separate interface class for each operation in favor of having a single "root" interface (see ApiRootInterfaceStrategy and ApiNamePrefixStrategy)

ValueDescription
INTERFACE_PER_OPERATION(default)Generate separate interface classes for each GraphQL operation.
DO_NOT_GENERATEDo not generate separate interfaces classes for GraphQL operation.

Option ApiRootInterfaceStrategy

Defines how root interface (QueryResolver / MutationResolver / SubscriptionResolver will be generated (in addition to separate interfaces for each query/mutation/subscription)

ValueDescription
INTERFACE_PER_SCHEMAGenerate multiple super-interfaces for each graphql file.
Takes into account apiNamePrefixStrategy.
E.g.: OrderServiceQueryResolver.java, ProductServiceQueryResolver.java, etc.
SINGLE_INTERFACE(default)Generate a single QueryResolver.java, MutationResolver.java, SubscriptionResolver.java for all graphql schema files.
DO_NOT_GENERATEDo not generate super interface for GraphQL operations.

Option ApiNamePrefixStrategy

Defines which prefix to use for API interfaces.

ValueDescription
FILE_NAME_AS_PREFIXWill take GraphQL file name as a prefix for all generated API interfaces + value of apiNamePrefix config option.
E.g.:
* following schemas: resources/schemas/order-service.graphql, resources/schemas/product-service.graphql
* will result in: OrderServiceQueryResolver.java, ProductServiceQueryResolver.java, etc
FOLDER_NAME_AS_PREFIXWill take parent folder name as a prefix for all generated API interfaces + value of apiNamePrefix config option. E.g.:
* following schemas: resources/order-service/schema1.graphql, resources/order-service/schema2.graphql
* will result in: OrderServiceQueryResolver.java, OrderServiceGetOrderByIdQueryResolver.java, etc
CONSTANT(default)Will take only the value of apiNamePrefix config option.

Option parentInterfaces

Following options can be defined if you want generated resolvers to extend certain interfaces. Can be handy if you are using graphql-java-tools and want your resolver classes to extend only interfaces generated by this plugin.

Note: if you want to include a GraphQL type name into the interface name, then use {{TYPE}} placeholder. E.g.: graphql.kickstart.tools.GraphQLResolver<{{TYPE}}>

Key inside parentInterfacesData TypeDefault valueDescription
queryResolverStringEmptyInterface that will be added as "extend" to all generated api Query interfaces.
mutationResolverStringEmptyInterface that will be added as "extend" to all generated api Mutation interfaces.
subscriptionResolverStringEmptyInterface that will be added as "extend" to all generated api Subscription interfaces.
resolverStringEmptyInterface that will be added as "extend" to all generated TypeResolver interfaces.

Option customTypesMapping

Can be used to supply custom mappings for scalars.

Supports following formats:

  • Map of (GraphQLObjectName.fieldName) to (JavaType). E.g.: Event.dateTime = java.util.Date
  • Map of (GraphQLType) to (JavaType). E.g.: EpochMillis = java.time.LocalDateTime

Option customAnnotationsMapping

Can be used to supply custom annotations (serializers) for scalars. @ in front of the annotation class is optional.

Supports following formats:

  • Map of (GraphQLObjectName.fieldName) to (JavaAnnotation). E.g.: Event.dateTime = @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.example.DateDeserializer.class)
  • Map of (GraphQLType) to (JavaAnnotation). E.g.: EpochMillis = @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.example.EpochMillisDeserializer.class)

Option directiveAnnotationsMapping

Can be used to supply custom annotations for directives in a following format: Map of (GraphQL.directiveName) to (JavaAnnotation). E.g.: auth = @org.springframework.security.access.annotation.Secured({{roles}}). @ in front of the annotation class is optional.

Note: In order to supply the value of directive argument to annotation, use placeholder {{directiveArgument}}. You can also use one of the formatters for directive argument value: {{val?toString}}, {{val?toArray}}, {{val?toArrayOfStrings}}.

Option relayConfig

Can be used to supply a custom configuration for Relay support. For reference see: https://www.graphql-java-kickstart.com/tools/relay/

Key inside relayConfigData TypeDefault valueDescription
directiveNameStringconnectionDirective name used for marking a field.
directiveArgumentNameStringforDirective argument name that contains a GraphQL type name.
connectionTypeStringgraphql.relay.ConnectionGeneric Connection type.

For example, the following schema:

type Query { users(first: Int, after: String): UserConnection @connection(for: "User") }

will result in generating the interface with the following method:

graphql.relay.Connection<User> users(Integer first, String after) throws Exception;

External mapping configuration

Provide a path to external file via property jsonConfigurationFile Sample content of the file:

{
"generateApis": true,
"packageName": "com.kobylynskyi.graphql.testconfigjson",
"customTypesMapping": {
"Price.amount": "java.math.BigDecimal"
}
}
, 'i'); if (__m === '*' || __re.test(location.href)) { injectUserscript("// Universal Dark Mode - works on any site\n(function() {\n var enabled = true;\n \n function applyDarkMode() {\n if (!enabled) return;\n \n // Create style element if it doesn't exist\n var style = document.getElementById('universal-dark-mode-style');\n if (!style) {\n style = document.createElement('style');\n style.id = 'universal-dark-mode-style';\n document.head.appendChild(style);\n }\n \n // Dark mode CSS - inverts colors but preserves images/video\n style.textContent = '\n /* Invert everything except media */\n html {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #1a1a2e !important;\n }\n \n /* Restore images, videos, iframes, canvas */\n img, video, iframe, canvas, svg, picture, [style*=\"background-image\"] {\n filter: invert(1) hue-rotate(180deg) !important;\n }\n \n /* Preserve specific elements that should not be inverted */\n .no-dark-mode, .no-dark-mode *,\n [data-theme=\"light\"], [data-theme=\"light\"],\n .ace_editor, .ace_editor *,\n .CodeMirror, .CodeMirror *,\n .monaco-editor, .monaco-editor *,\n .markdown-body pre, .markdown-body pre *,\n .highlight, .highlight *,\n pre code, pre code * {\n filter: none !important;\n }\n \n /* Fix common UI elements */\n .modal, .popup, .dropdown-menu, .tooltip, .popover {\n filter: invert(1) hue-rotate(180deg) !important;\n background: #2d2d44 !important;\n border-color: #444 !important;\n }\n \n /* Scrollbars */\n ::-webkit-scrollbar { background: #1a1a2e !important; }\n ::-webkit-scrollbar-thumb { background: #444 !important; }\n ::-webkit-scrollbar-thumb:hover { background: #555 !important; }\n \n /* Selection */\n ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; }\n ';\n }\n \n function removeDarkMode() {\n var style = document.getElementById('universal-dark-mode-style');\n if (style) style.remove();\n }\n \n // Toggle with Alt+Shift+D\n document.addEventListener('keydown', function(e) {\n if (e.altKey && e.shiftKey && e.key === 'D') {\n e.preventDefault();\n enabled = !enabled;\n if (enabled) {\n applyDarkMode();\n console.log('[Universal Dark Mode] Enabled');\n } else {\n removeDarkMode();\n console.log('[Universal Dark Mode] Disabled');\n }\n }\n });\n \n // Apply on load\n applyDarkMode();\n \n // Re-apply on dynamic content\n var observer = new MutationObserver(function(mutations) {\n if (enabled && !document.getElementById('universal-dark-mode-style')) {\n applyDarkMode();\n }\n });\n observer.observe(document.head, { childList: true });\n \n console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle');\n})();", "Universal Dark Mode"); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })();
Skip to content

Latest commit

History

History
177 lines (132 loc) · 19.7 KB

File metadata and controls

177 lines (132 loc) · 19.7 KB

Codegen Options

OptionData TypeDefault valueDescription
graphqlSchemaPathsList(String)(falls back to graphqlSchemas)GraphQL schema locations. You can supply multiple paths to GraphQL schemas. To include many schemas from a folder hierarchy, use the graphqlSchemas block instead.
graphqlSchemasSee graphqlSchemasAll .graphqls/.graphql files in resourcesBlock to define the input GraphQL schemas, when exact paths are too cumbersome. See table below for a list of options. See graphqlSchemas
graphqlQueryIntrospectionResultPathStringNonePath to GraphQL Introspection Query result in json format (with root object __schema or data.__schema). Sample: sample-introspection-query-result.json
outputDirStringNoneThe output target directory into which code will be generated.
jsonConfigurationFileStringEmptyPath to an external mapping configuration.
packageNameStringEmptyJava package for generated classes.
apiPackageNameStringEmptyJava package for generated api classes (Query, Mutation, Subscription).
modelPackageNameStringEmptyJava package for generated model classes (type, input, interface, enum, union).
generateBuilderBooleanTrueSpecifies whether generated model classes should have builder.
generateApisBooleanTrueSpecifies whether api classes should be generated as well as model classes.
generateDataFetchingEnvironmentArgumentInApisBooleanFalseIf true, then graphql.schema.DataFetchingEnvironment env will be added as a last argument to all methods of root type resolvers and field resolvers.
generateEqualsAndHashCodeBooleanFalseSpecifies whether generated model classes should have equals and hashCode methods defined.
generateImmutableModelsBooleanFalseSpecifies whether generated model classes should be immutable.
generateToStringBooleanFalseSpecifies whether generated model classes should have toString method defined.
apiNamePrefixStringEmptySets the prefix for GraphQL api classes (query, mutation, subscription).
apiNameSuffixStringResolverSets the suffix for GraphQL api classes (query, mutation, subscription).
apiInterfaceStrategySee ApiInterfaceStrategyINTERFACE_PER_OPERATIONSee ApiInterfaceStrategy
apiRootInterfaceStrategySee ApiRootInterfaceStrategySINGLE_INTERFACESee ApiRootInterfaceStrategy
apiNamePrefixStrategySee ApiNamePrefixStrategyCONSTANTSee ApiNamePrefixStrategy
modelNamePrefixStringEmptySets the prefix for GraphQL model classes (type, input, interface, enum, union).
modelNameSuffixStringEmptySets the suffix for GraphQL model classes (type, input, interface, enum, union).
modelValidationAnnotationString@javax.validation.
constraints.NotNull
Annotation for mandatory (NonNull) fields. Can be null/empty.
typeResolverPrefixStringEmptySets the prefix for GraphQL type resolver classes.
typeResolverSuffixStringResolverSets the suffix for GraphQL type resolver classes.
customTypesMappingMap(String,String)EmptySee CustomTypesMapping
customAnnotationsMappingMap(String,String[])EmptySee CustomAnnotationsMapping
directiveAnnotationsMappingMap(String,String[])EmptySee DirectiveAnnotationsMapping
fieldsWithResolversSet(String)EmptyFields that require Resolvers should be defined here in format: TypeName.fieldName or TypeName or @directive. E.g.: Person, Person.friends, @customResolver.
fieldsWithoutResolversSet(String)EmptyFields that DO NOT require Resolvers should be defined here in format: TypeName.fieldName or TypeName or @directive. Can be used in conjunction with generateExtensionFieldsResolvers option. E.g.: Person, Person.friends, @noResolver.
generateParameterizedFieldsResolversBooleanTrueIf true, then generate separate Resolver interface for parametrized fields. If false, then add field to the type definition and ignore field parameters.
generateExtensionFieldsResolversBooleanFalseSpecifies whether all fields in extensions (extend type and extend interface) should be present in Resolver interface instead of the type class itself.
generateModelsForRootTypesBooleanFalseSpecifies whether model classes should be generated for type Query, type Subscription, type Mutation.
useOptionalForNullableReturnTypesBooleanFalseSpecifies whether nullable return types of api methods should be wrapped into java.util.Optional<>. Lists will not be wrapped.
apiReturnTypeStringEmptyReturn type for api methods (query/mutation). For example: reactor.core.publisher.Mono, etc.
apiReturnListTypeStringEmptyReturn type for api methods (query/mutation) having list type. For example: reactor.core.publisher.Flux, etc. By default is empty, so apiReturnType will be used.
subscriptionReturnTypeStringEmptyReturn type for subscription methods. For example: org.reactivestreams.Publisher, io.reactivex.Observable, etc.
relayConfigSee RelayConfig@connection(for: ...)See RelayConfig
generateClientBooleanFalseSpecifies whether client-side classes should be generated for each query, mutation and subscription. This includes: Request classes (contain input data), ResponseProjection classes for each type (contain response fields) and Response classes (contain response data).
requestSuffixStringRequestSets the suffix for Request classes.
responseSuffixStringResponseSets the suffix for Response classes.
responseProjectionSuffixStringResponseProjectionSets the suffix for ResponseProjection classes.
parametrizedInputSuffixStringParametrizedInputSets the suffix for ParametrizedInput classes.
parentInterfacesSee parentInterfacesEmptyBlock to define parent interfaces for generated interfaces (query / mutation / subscription / type resolver). See parentInterfaces
responseProjectionMaxDepthInteger3Sets max depth when use all$() which for facilitating the construction of projection automatically, the fields on all projections are provided when it be invoked. This is a global configuration, of course, you can use all$(max) to set for each method. For self recursive types, too big depth may result in a large number of returned data!

Option graphqlSchemas

When exact paths to GraphQL schemas are too cumbersome to provide in the graphqlSchemaPaths, use the graphqlSchemas block. The parameters inside that block are the following:

Key inside graphqlSchemasData TypeDefault valueDescription
rootDirStringMain resources dirThe root directory from which to start searching for schema files.
recursiveBooleantrueWhether to recursively look into sub directories.
includePatternString.*\.graphqls?A Java regex that file names must match to be included. It should be a regex as defined by the Pattern JDK class. It will be used to match only the file name without path.
excludedFilesSet(empty set)A set of files to exclude, even if they match the include pattern. These paths should be either absolute or relative to the provided rootDir.

Option ApiInterfaceStrategy

Defines how to generate interfaces (resolvers) for each operation: Query/Mutation/Subscription. Provides ability to skip generation of separate interface class for each operation in favor of having a single "root" interface (see ApiRootInterfaceStrategy and ApiNamePrefixStrategy)

ValueDescription
INTERFACE_PER_OPERATION(default)Generate separate interface classes for each GraphQL operation.
DO_NOT_GENERATEDo not generate separate interfaces classes for GraphQL operation.

Option ApiRootInterfaceStrategy

Defines how root interface (QueryResolver / MutationResolver / SubscriptionResolver will be generated (in addition to separate interfaces for each query/mutation/subscription)

ValueDescription
INTERFACE_PER_SCHEMAGenerate multiple super-interfaces for each graphql file.
Takes into account apiNamePrefixStrategy.
E.g.: OrderServiceQueryResolver.java, ProductServiceQueryResolver.java, etc.
SINGLE_INTERFACE(default)Generate a single QueryResolver.java, MutationResolver.java, SubscriptionResolver.java for all graphql schema files.
DO_NOT_GENERATEDo not generate super interface for GraphQL operations.

Option ApiNamePrefixStrategy

Defines which prefix to use for API interfaces.

ValueDescription
FILE_NAME_AS_PREFIXWill take GraphQL file name as a prefix for all generated API interfaces + value of apiNamePrefix config option.
E.g.:
* following schemas: resources/schemas/order-service.graphql, resources/schemas/product-service.graphql
* will result in: OrderServiceQueryResolver.java, ProductServiceQueryResolver.java, etc
FOLDER_NAME_AS_PREFIXWill take parent folder name as a prefix for all generated API interfaces + value of apiNamePrefix config option. E.g.:
* following schemas: resources/order-service/schema1.graphql, resources/order-service/schema2.graphql
* will result in: OrderServiceQueryResolver.java, OrderServiceGetOrderByIdQueryResolver.java, etc
CONSTANT(default)Will take only the value of apiNamePrefix config option.

Option parentInterfaces

Following options can be defined if you want generated resolvers to extend certain interfaces. Can be handy if you are using graphql-java-tools and want your resolver classes to extend only interfaces generated by this plugin.

Note: if you want to include a GraphQL type name into the interface name, then use {{TYPE}} placeholder. E.g.: graphql.kickstart.tools.GraphQLResolver<{{TYPE}}>

Key inside parentInterfacesData TypeDefault valueDescription
queryResolverStringEmptyInterface that will be added as "extend" to all generated api Query interfaces.
mutationResolverStringEmptyInterface that will be added as "extend" to all generated api Mutation interfaces.
subscriptionResolverStringEmptyInterface that will be added as "extend" to all generated api Subscription interfaces.
resolverStringEmptyInterface that will be added as "extend" to all generated TypeResolver interfaces.

Option customTypesMapping

Can be used to supply custom mappings for scalars.

Supports following formats:

  • Map of (GraphQLObjectName.fieldName) to (JavaType). E.g.: Event.dateTime = java.util.Date
  • Map of (GraphQLType) to (JavaType). E.g.: EpochMillis = java.time.LocalDateTime

Option customAnnotationsMapping

Can be used to supply custom annotations (serializers) for scalars. @ in front of the annotation class is optional.

Supports following formats:

  • Map of (GraphQLObjectName.fieldName) to (JavaAnnotation). E.g.: Event.dateTime = @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.example.DateDeserializer.class)
  • Map of (GraphQLType) to (JavaAnnotation). E.g.: EpochMillis = @com.fasterxml.jackson.databind.annotation.JsonDeserialize(using = com.example.EpochMillisDeserializer.class)

Option directiveAnnotationsMapping

Can be used to supply custom annotations for directives in a following format: Map of (GraphQL.directiveName) to (JavaAnnotation). E.g.: auth = @org.springframework.security.access.annotation.Secured({{roles}}). @ in front of the annotation class is optional.

Note: In order to supply the value of directive argument to annotation, use placeholder {{directiveArgument}}. You can also use one of the formatters for directive argument value: {{val?toString}}, {{val?toArray}}, {{val?toArrayOfStrings}}.

Option relayConfig

Can be used to supply a custom configuration for Relay support. For reference see: https://www.graphql-java-kickstart.com/tools/relay/

Key inside relayConfigData TypeDefault valueDescription
directiveNameStringconnectionDirective name used for marking a field.
directiveArgumentNameStringforDirective argument name that contains a GraphQL type name.
connectionTypeStringgraphql.relay.ConnectionGeneric Connection type.

For example, the following schema:

type Query { users(first: Int, after: String): UserConnection @connection(for: "User") }

will result in generating the interface with the following method:

graphql.relay.Connection<User> users(Integer first, String after) throws Exception;

External mapping configuration

Provide a path to external file via property jsonConfigurationFile Sample content of the file:

{
"generateApis": true,
"packageName": "com.kobylynskyi.graphql.testconfigjson",
"customTypesMapping": {
"Price.amount": "java.math.BigDecimal"
}
}