mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-15 01:12:56 +03:00
console: add formatting to action sdl
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7835 GitOrigin-RevId: e4ce96664c218a6a08124102733f7c79707fbb69
This commit is contained in:
parent
7027af5a05
commit
aee0f7a766
@ -6,6 +6,8 @@ import {
|
||||
parseCustomTypes,
|
||||
hydrateTypeRelationships,
|
||||
} from './hasuraCustomTypeUtils';
|
||||
import { format } from 'prettier/standalone';
|
||||
import parserGraphql from 'prettier/parser-graphql';
|
||||
|
||||
export const isValidOperationName = operationName => {
|
||||
return operationName === 'query' || operationName === 'mutation';
|
||||
@ -22,6 +24,13 @@ const getActionTypeFromOperationType = operationType => {
|
||||
return 'mutation';
|
||||
};
|
||||
|
||||
export const formatSdl = sdl => {
|
||||
return format(sdl, {
|
||||
parser: 'graphql',
|
||||
plugins: [parserGraphql],
|
||||
});
|
||||
};
|
||||
|
||||
const getOperationTypeFromActionType = operationType => {
|
||||
if (operationType === 'query') {
|
||||
return 'Query';
|
||||
@ -300,17 +309,19 @@ export const getActionDefinitionSdl = (
|
||||
outputType,
|
||||
description
|
||||
) => {
|
||||
return getObjectTypeSdl({
|
||||
name: getOperationTypeFromActionType(actionType),
|
||||
fields: [
|
||||
{
|
||||
name,
|
||||
arguments: args,
|
||||
type: outputType,
|
||||
description,
|
||||
},
|
||||
],
|
||||
});
|
||||
return formatSdl(
|
||||
getObjectTypeSdl({
|
||||
name: getOperationTypeFromActionType(actionType),
|
||||
fields: [
|
||||
{
|
||||
name,
|
||||
arguments: args,
|
||||
type: outputType,
|
||||
description,
|
||||
},
|
||||
],
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
export const getServerTypesFromSdl = (sdl, existingTypes) => {
|
||||
|
Loading…
Reference in New Issue
Block a user