Skip to content

Commit

Permalink
Allow pascal selectQueryOrMutationField values (#4777)
Browse files Browse the repository at this point in the history
* allowPascal selectQueryOrMutationField

* Changeset

Co-authored-by: Arda TANRIKULU <[email protected]>
  • Loading branch information
dr3 and ardatan authored Nov 7, 2022
1 parent 6084e41 commit baa4fbf
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 15 deletions.
9 changes: 9 additions & 0 deletions .changeset/itchy-ties-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@graphql-mesh/openapi': patch
'@graphql-mesh/raml': patch
'@omnigraph/openapi': patch
'@omnigraph/raml': patch
'@graphql-mesh/types': patch
---

Allow pascal-cased `Query` and `Mutation` values for `selectQueryOrMutationField`
2 changes: 2 additions & 0 deletions packages/handlers/openapi/yaml-config.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ enum FallbackFormat {
enum QueryOrMutation {
query
mutation
Query
Mutation
}

type OASSelectQueryOrMutationFieldConfig {
Expand Down
2 changes: 2 additions & 0 deletions packages/handlers/raml/yaml-config.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ type RAMLHandler {
enum QueryOrMutation {
query
mutation
Query
Mutation
}

type RAMLSelectQueryOrMutationFieldConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export async function getJSONSchemaOptionsFromOpenAPIOptions(
logger = new DefaultLogger('getJSONSchemaOptionsFromOpenAPIOptions'),
}: GetJSONSchemaOptionsFromOpenAPIOptionsParams
) {
const fieldTypeMap: Record<string, 'query' | 'mutation'> = {};
const fieldTypeMap: Record<string, OpenAPILoaderSelectQueryOrMutationFieldConfig['fieldName']> = {};
for (const { fieldName, type } of selectQueryOrMutationField) {
fieldTypeMap[fieldName] = type;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/loaders/openapi/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export interface OpenAPILoaderOptions extends Partial<JSONSchemaLoaderOptions> {
}

export interface OpenAPILoaderSelectQueryOrMutationFieldConfig {
type: 'query' | 'mutation';
type: 'query' | 'mutation' | 'Query' | 'Mutation';
fieldName: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getAbsolutePath, getCwd, JSONSchemaObject } from 'json-machete';
import { api10, loadApi } from '@ardatan/raml-1-parser';
import { fetch as crossUndiciFetch } from '@whatwg-node/fetch';
import toJsonSchema from 'to-json-schema';
import { RAMLLoaderOptions } from './types';
import { RAMLLoaderOptions, RAMLLoaderSelectQueryOrMutationFieldConfig } from './types';
import { asArray } from '@graphql-tools/utils';
import { getFieldNameFromPath } from './utils';
import { getInterpolatedHeadersFactory } from '@graphql-mesh/string-interpolation';
Expand Down Expand Up @@ -41,7 +41,7 @@ export async function getJSONSchemaOptionsFromRAMLOptions({
baseUrl: string;
fetch?: WindowOrWorkerGlobalScope['fetch'];
}> {
const fieldTypeMap: Record<string, 'query' | 'mutation'> = {};
const fieldTypeMap: Record<string, RAMLLoaderSelectQueryOrMutationFieldConfig['fieldName']> = {};
for (const { fieldName, type } of selectQueryOrMutationField) {
fieldTypeMap[fieldName] = type;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/loaders/raml/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export interface RAMLLoaderOptions extends Partial<JSONSchemaLoaderOptions> {
}

export interface RAMLLoaderSelectQueryOrMutationFieldConfig {
type: 'query' | 'mutation';
type: 'query' | 'mutation' | 'Query' | 'Mutation';
fieldName: string;
}
8 changes: 4 additions & 4 deletions packages/types/src/config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1965,8 +1965,8 @@
"properties": {
"type": {
"type": "string",
"enum": ["query", "mutation"],
"description": "Allowed values: query, mutation"
"enum": ["query", "mutation", "Query", "Mutation"],
"description": "Allowed values: query, mutation, Query, Mutation"
},
"fieldName": {
"type": "string"
Expand Down Expand Up @@ -2664,8 +2664,8 @@
"properties": {
"type": {
"type": "string",
"enum": ["query", "mutation"],
"description": "Allowed values: query, mutation"
"enum": ["query", "mutation", "Query", "Mutation"],
"description": "Allowed values: query, mutation, Query, Mutation"
},
"fieldName": {
"type": "string"
Expand Down
8 changes: 4 additions & 4 deletions packages/types/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -892,9 +892,9 @@ export interface OpenapiHandler {
}
export interface OASSelectQueryOrMutationFieldConfig {
/**
* Allowed values: query, mutation
* Allowed values: query, mutation, Query, Mutation
*/
type: 'query' | 'mutation';
type: 'query' | 'mutation' | 'Query' | 'Mutation';
fieldName: string;
}
/**
Expand Down Expand Up @@ -953,9 +953,9 @@ export interface RAMLHandler {
}
export interface RAMLSelectQueryOrMutationFieldConfig {
/**
* Allowed values: query, mutation
* Allowed values: query, mutation, Query, Mutation
*/
type: 'query' | 'mutation';
type: 'query' | 'mutation' | 'Query' | 'Mutation';
fieldName: string;
}
/**
Expand Down
2 changes: 1 addition & 1 deletion website/src/generated-markdown/OpenapiHandler.generated.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ Overrides the server object in the OAS.
Applying this will ignore all responses with status code other than 2xx, resulting in simpler response types, usualy regular object type instead of union.
Default: false
* `selectQueryOrMutationField` (type: `Array of Object`) - Allows to explicitly override the default operation (Query or Mutation) for any OAS operation:
* `type` (type: `String (query | mutation)`, required)
* `type` (type: `String (query | mutation | Query | Mutation)`, required)
* `fieldName` (type: `String`, required)
* `queryParams` (type: `JSON`) - JSON object representing the query search parameters to add to the API calls
2 changes: 1 addition & 1 deletion website/src/pages/docs/migration/openapi-0.31-0.32.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Some options where replaced/dropped:
- `provideErrorExtensions`: Dropped. Using debug mode for that matter is recommend
- `qs`: Use `queryParams` instead. Note that using this option in the previous handler resulted in removing query input arguments, where now the behavior is making them all nullable, and preferring the input arg over the config params if both exist.
- `requestOptions`: Dropped
- `selectQueryOrMutationField`: Previous structure was simplified. Now this option expects an array of object, each containing `fieldName` (for relevant field name) and `type` for the expected type (`query`/`mutation`)
- `selectQueryOrMutationField`: Previous structure was simplified. Now this option expects an array of object, each containing `fieldName` (for relevant field name) and `type` for the expected type (`Query`/`Mutation`)
- `simpleNames`: The current convention is equivalent to `simpleNames: true`. For other setups see the [naming convention transform](https://www.graphql-mesh.com/docs/transforms/naming-convention)
- `strict`: Use `ignoreErrorResponses` (input value should be inverted)

Expand Down

0 comments on commit baa4fbf

Please sign in to comment.