diff --git a/api-specs/history/api.raml b/api-specs/history/api.raml index f461aca78..c368ffb3a 100644 --- a/api-specs/history/api.raml +++ b/api-specs/history/api.raml @@ -154,6 +154,24 @@ resourceTypes: type: string description: | `key` of the Project. + /graphql: + post: + displayName: GraphQL + description: Execute a GraphQL request. + securedBy: + - oauth_2_0: + scopes: + ['view_audit_log:{projectKey}', 'view_categories:{projectKey}'] + body: + application/json: + example: !include examples/GraphQLRequest.json + type: GraphQLRequest + responses: + 200: + body: + application/json: + example: !include examples/GraphQLResponse.json + type: GraphQLResponse get: displayName: Query Records securedBy: diff --git a/api-specs/history/examples/GraphQLRequest.json b/api-specs/history/examples/GraphQLRequest.json new file mode 100644 index 000000000..ea69afce1 --- /dev/null +++ b/api-specs/history/examples/GraphQLRequest.json @@ -0,0 +1,8 @@ +{ + "query": "query getCategoryChanges($startDate: DateFilterValue!, $endDate: DateFilterValue!){categories(date:{from:$startDate to:$endDate}) {results {type modifiedAt changes {previousValue nextValue change} resource{id} }}}", + "operationName": "getCategoryChanges", + "variables": { + "startDate": "2024-09-07T08:53:28.471Z", + "endDate": "2024-11-07T08:53:28.471Z" + } +} diff --git a/api-specs/history/examples/GraphQLResponse.json b/api-specs/history/examples/GraphQLResponse.json new file mode 100644 index 000000000..7355a79c6 --- /dev/null +++ b/api-specs/history/examples/GraphQLResponse.json @@ -0,0 +1,34 @@ +{ + "data": { + "categories": { + "results": [ + { + "type": "ResourceUpdated", + "modifiedAt": "2024-11-07T08:53:28.471Z", + "changes": [ + { + "previousValue": { + "en": "Old name for Category" + }, + "nextValue": { + "en": "New name for Category" + }, + "change": "changeName" + } + ], + "resource": { + "id": "cd260fc9-c575-4ba3-8789-cc4c9980ee4e" + } + }, + { + "type": "ResourceCreated", + "modifiedAt": "2024-10-22T22:39:44.201Z", + "changes": [], + "resource": { + "id": "ffae2221-40c4-410d-bd13-e0fa4b6a4dd6" + } + } + ] + } + } +} diff --git a/api-specs/history/types/GraphQLError.raml b/api-specs/history/types/GraphQLError.raml new file mode 100644 index 000000000..89bbba447 --- /dev/null +++ b/api-specs/history/types/GraphQLError.raml @@ -0,0 +1,20 @@ +#%RAML 1.0 DataType +(package): GraphQL +displayName: GraphQLError +type: object +description: Contains an error message, the location of the code that caused the error, and other information to help you correct the error. +properties: + message: + type: string + description: Detailed description of the error explaining the root cause of the problem and suggesting how to correct the error. + locations: + type: array + items: GraphQLErrorLocation + description: Location within your query where the error occurred. + path?: + type: array + items: any + description: Query fields listed in order from the root of the query response up to the field in which the error occurred. `path` is displayed in the response only if an error is associated with a particular field in the query result. + extensions: + type: GraphQLErrorObject + description: Dictionary with additional information where applicable. diff --git a/api-specs/history/types/GraphQLRequest.raml b/api-specs/history/types/GraphQLRequest.raml new file mode 100644 index 000000000..783c7f53e --- /dev/null +++ b/api-specs/history/types/GraphQLRequest.raml @@ -0,0 +1,16 @@ +#%RAML 1.0 DataType +(package): GraphQL +displayName: GraphQLRequest +example: !include ../examples/GraphQLRequest.json +description: The query, operation name, and variables that are sent to the GraphQL API. +type: object +properties: + query: + type: string + description: String representation of the _Source Text_ of the _Document_ that is specified in the [Language section of the GraphQL specification](https://spec.graphql.org/draft/#sec-Language). + operationName?: + type: string + description: Name of the operation, if you defined several operations in `query`. + variables?: + type: GraphQLVariablesMap + description: JSON object that contains key-value pairs in which the keys are variable names and the values are variable values. diff --git a/api-specs/history/types/GraphQLResponse.raml b/api-specs/history/types/GraphQLResponse.raml new file mode 100644 index 000000000..a30dd66e0 --- /dev/null +++ b/api-specs/history/types/GraphQLResponse.raml @@ -0,0 +1,15 @@ +#%RAML 1.0 DataType +(package): GraphQL +displayName: GraphQLResponse +type: object +example: !include ../examples/GraphQLResponse.json +description: | + `error` is present in the response only if the GraphQL query was unsuccessful. +properties: + data?: + type: any + description: JSON object that contains the results of a GraphQL query. + errors?: + type: array + items: GraphQLError + description: Errors that the GraphQL query returns. diff --git a/api-specs/history/types/types.raml b/api-specs/history/types/types.raml index 65095a05c..0de454759 100644 --- a/api-specs/history/types/types.raml +++ b/api-specs/history/types/types.raml @@ -13,6 +13,12 @@ Label: !include label/Label.raml LocalizedString: !include common/LocalizedString.raml ChangeTargetChangeValue: !include change/change-value/ChangeTargetChangeValue.raml ChangeValueChangeValue: !include change/change-value/ChangeValueChangeValue.raml +GraphQLRequest: !include ../../api/types/graphql/GraphQLRequest.raml +GraphQLResponse: !include ../../api/types/graphql/GraphQLResponse.raml +GraphQLError: !include GraphQLError.raml +GraphQLErrorLocation: !include ../../api/types/graphql/GraphQLErrorLocation.raml +GraphQLVariablesMap: !include ../../api/types/graphql/GraphQLVariablesMap.raml +GraphQLErrorObject: !include ../../api/types/error/graphql/GraphQLErrorObject.raml # Generated types AddAddressChange: !include change/AddAddressChange.raml AddAssetChange: !include change/AddAssetChange.raml