@@ -7,7 +7,7 @@ import type { Config, Context } from "@netlify/functions";
7
7
const linter = new Linter ( { cwd : '.' , } ) ;
8
8
9
9
const apolloClient = new ApolloClient ( {
10
- uri : Netlify . env . get ( 'APOLLO_STUDIO_URL' ) ?? 'https://graphql. api.apollographql.com/api/graphql' ,
10
+ uri : Netlify . env . get ( 'APOLLO_STUDIO_URL' ) ?? 'https://api.apollographql.com/api/graphql' ,
11
11
cache : new InMemoryCache ( ) ,
12
12
} ) ;
13
13
@@ -21,9 +21,7 @@ const docQuery = gql`query Doc($graphId: ID!, $hash: SHA256) {
21
21
22
22
const customCheckCallbackMutation = gql `mutation CustomCheckCallback($input: CustomCheckCallbackInput!, $name: String!, $graphId: ID!) {
23
23
graph(id: $graphId) {
24
- id
25
24
variant(name: $name) {
26
- id
27
25
customCheckCallback(input: $input) {
28
26
__typename
29
27
... on CustomCheckResult {
@@ -95,6 +93,25 @@ export default async (req: Request, context: Context) => {
95
93
96
94
console . log ( `eslint messages: ${ JSON . stringify ( messages ) } ` ) ;
97
95
96
+ const violations = messages . map ( violation => ( {
97
+ // Fail check if a naming convention is violated
98
+ level : violation . ruleId === '@graphql-eslint/naming-convention' ? 'ERROR' : 'WARNING' ,
99
+ message : violation . message ,
100
+ rule : violation . ruleId ?? 'unknown' ,
101
+ sourceLocations : {
102
+ start : {
103
+ byteOffset : 0 ,
104
+ line : violation . line ,
105
+ column : violation . column ,
106
+ } ,
107
+ end : {
108
+ byteOffset : 0 ,
109
+ line : violation . endLine ,
110
+ column : violation . endColumn ,
111
+ }
112
+ }
113
+ } ) ) ;
114
+
98
115
const callbackResult = await apolloClient . mutate ( {
99
116
mutation : customCheckCallbackMutation ,
100
117
variables : {
@@ -103,24 +120,8 @@ export default async (req: Request, context: Context) => {
103
120
input : {
104
121
taskId : event . checkStep . taskId ,
105
122
workflowId : event . checkStep . workflowId ,
106
- status : 'SUCCESS' ,
107
- violations : messages . map ( violation => ( {
108
- level : "WARNING" ,
109
- message : violation . message ,
110
- rule : violation . ruleId ,
111
- sourceLocations : {
112
- start : {
113
- byteOffset : violation . column ,
114
- line : violation . line ,
115
- column : violation . column ,
116
- } ,
117
- end : {
118
- byteOffset : violation . endColumn ,
119
- line : violation . endLine ,
120
- column : violation . endColumn ,
121
- }
122
- }
123
- } ) ) ,
123
+ status : violations . find ( violation => violation . level === 'ERROR' ) !== undefined ? 'FAILURE' : 'SUCCESS' ,
124
+ violations : violations ,
124
125
}
125
126
} ,
126
127
context : {
0 commit comments