Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 38 additions & 2 deletions packages/protocols/graphql/src/tck.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,17 @@ class GraphQLEndpoint implements ProtocolEndpoint {

if (operation.filter) {
queryArgs += `$where: ${entityName}Filter`;
variables.where = operation.filter;
// Transform simple filter format { field: value } to GraphQL format { field: { eq: value } }
variables.where = this.transformFilter(operation.filter);
}

if (operation.options?.orderBy) {
queryArgs += queryArgs ? ', ' : '';
queryArgs += `$orderBy: [${entityName}OrderBy!]`;
variables.orderBy = operation.options.orderBy.map((o: any) => ({
field: o.field,
direction: o.order || 'ASC'
}));
}

if (operation.options?.limit) {
Expand Down Expand Up @@ -239,6 +249,28 @@ class GraphQLEndpoint implements ProtocolEndpoint {
};
}

/**
* Transform TCK filter format to GraphQL filter format
* TCK: { active: true } -> GraphQL: { active: { eq: true } }
*/
private transformFilter(filter: any): any {
if (!filter || typeof filter !== 'object') {
return filter;
}

const transformed: any = {};
for (const [key, value] of Object.entries(filter)) {
if (value !== null && typeof value === 'object' && !Array.isArray(value)) {
// Already in GraphQL format (e.g., { eq: value })
transformed[key] = value;
} else {
// Simple format, wrap in { eq: value }
transformed[key] = { eq: value };
}
}
return transformed;
}

private async executeBatch(operation: ProtocolOperation): Promise<ProtocolResponse> {
// GraphQL doesn't have native batch in the same way, but we can use multiple mutations
const entityName = this.capitalize(operation.entity);
Expand Down Expand Up @@ -318,7 +350,11 @@ class GraphQLEndpoint implements ProtocolEndpoint {
`;

const result = await this.graphqlRequest(query, {});
return result.data;
// Include both TCK-compatible format and original schema
return {
types: result.data.__schema?.types || [],
__schema: result.data.__schema
};
}

async close(): Promise<void> {
Expand Down
6 changes: 4 additions & 2 deletions packages/protocols/odata-v4/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -726,8 +726,10 @@ export class ODataV4Plugin implements RuntimePlugin {
for (const pair of pairs) {
const [key, value] = pair.split('=');
if (key) {
const decodedKey = decodeURIComponent(key);
params[decodedKey as keyof ODataQueryParams] = decodeURIComponent(value || '');
// Replace + with space before decoding (application/x-www-form-urlencoded format)
const decodedKey = decodeURIComponent(key.replace(/\+/g, ' '));
const decodedValue = decodeURIComponent((value || '').replace(/\+/g, ' '));
params[decodedKey as keyof ODataQueryParams] = decodedValue;
}
}

Expand Down
Loading