Skip to content

Commit 523849b

Browse files
authored
Merge pull request #438 from objectstack-ai/copilot/update-script-for-new-endpoint
2 parents 3779fd4 + 98603bb commit 523849b

File tree

4 files changed

+789
-1213
lines changed

4 files changed

+789
-1213
lines changed

examples/basic/api-protocols-example.ts

Lines changed: 49 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -54,50 +54,60 @@ export const graphqlConfig: GraphQLConfig = {
5454
types: [
5555
{
5656
name: 'DateTime',
57-
kind: 'scalar',
57+
object: 'scalar',
5858
description: 'ISO 8601 date-time string',
59+
isInterface: false,
5960
},
6061
{
6162
name: 'JSON',
62-
kind: 'scalar',
63+
object: 'scalar',
6364
description: 'JSON object',
65+
isInterface: false,
6466
},
6567
{
6668
name: 'AggregationResult',
67-
kind: 'object',
68-
fields: [
69-
{ name: 'count', type: 'Int!' },
70-
{ name: 'sum', type: 'Float' },
71-
{ name: 'avg', type: 'Float' },
72-
{ name: 'min', type: 'Float' },
73-
{ name: 'max', type: 'Float' },
74-
]
69+
object: 'aggregation_result',
70+
isInterface: false,
71+
fields: {
72+
mappings: {
73+
count: { graphqlType: 'Int!' },
74+
sum: { graphqlType: 'Float' },
75+
avg: { graphqlType: 'Float' },
76+
min: { graphqlType: 'Float' },
77+
max: { graphqlType: 'Float' },
78+
}
79+
}
7580
}
7681
],
7782

7883
// Custom mutations
7984
mutations: [
8085
{
8186
name: 'convertLead',
82-
args: [
83-
{ name: 'id', type: 'ID!' },
84-
{ name: 'accountName', type: 'String!' }
85-
],
86-
type: 'ConvertLeadResult!',
87-
description: 'Convert a lead to an account'
87+
object: 'lead',
88+
type: 'custom',
89+
authRequired: true,
90+
description: 'Convert a lead to an account',
91+
input: {
92+
fields: {
93+
include: ['id', 'accountName']
94+
}
95+
}
8896
}
8997
],
9098

9199
// Custom subscriptions
92100
subscriptions: [
93101
{
94102
name: 'recordUpdated',
95-
args: [
96-
{ name: 'object', type: 'String!' },
97-
{ name: 'recordId', type: 'ID!' }
98-
],
99-
type: 'RecordUpdateEvent!',
100-
description: 'Subscribe to record updates'
103+
object: 'record',
104+
events: ['updated'],
105+
authRequired: true,
106+
description: 'Subscribe to record updates',
107+
filter: {
108+
enabled: true,
109+
fields: ['object', 'recordId']
110+
}
101111
}
102112
],
103113

@@ -107,22 +117,25 @@ export const graphqlConfig: GraphQLConfig = {
107117
name: 'auth',
108118
description: 'Requires authentication',
109119
locations: ['FIELD_DEFINITION', 'OBJECT'],
120+
repeatable: false,
110121
},
111122
{
112123
name: 'permission',
113124
description: 'Requires specific permission',
114125
locations: ['FIELD_DEFINITION', 'OBJECT'],
115-
args: [
116-
{ name: 'requires', type: 'String!' }
117-
]
126+
repeatable: false,
127+
args: {
128+
requires: { type: 'String!', description: 'Required permission' }
129+
}
118130
},
119131
{
120132
name: 'deprecated',
121133
description: 'Marks field as deprecated',
122134
locations: ['FIELD_DEFINITION'],
123-
args: [
124-
{ name: 'reason', type: 'String' }
125-
]
135+
repeatable: false,
136+
args: {
137+
reason: { type: 'String', description: 'Deprecation reason' }
138+
}
126139
},
127140
],
128141
},
@@ -133,24 +146,30 @@ export const graphqlConfig: GraphQLConfig = {
133146
depthLimit: {
134147
enabled: true,
135148
maxDepth: 10,
149+
onDepthExceeded: 'reject',
136150
},
137151

138152
// Query complexity
139153
complexity: {
140154
enabled: true,
141155
maxComplexity: 1000,
156+
defaultFieldComplexity: 1,
157+
listMultiplier: 10,
158+
onComplexityExceeded: 'reject',
142159
},
143160

144161
// Rate limiting
145162
rateLimit: {
146163
enabled: true,
147-
window: '1m',
148-
limit: 1000,
164+
strategy: 'sliding_window',
165+
onLimitExceeded: 'reject',
166+
includeHeaders: true,
149167
},
150168

151169
// Persisted queries
152170
persistedQueries: {
153171
enabled: true,
172+
mode: 'optional',
154173
security: {
155174
rejectIntrospection: true
156175
}

0 commit comments

Comments
 (0)