Skip to content

Commit d0b4275

Browse files
committed
Treat ID scalars as a string in the case of filtering
1 parent 7ea3b9b commit d0b4275

File tree

2 files changed

+34
-19
lines changed

2 files changed

+34
-19
lines changed

graphql-api-generator/generator.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,6 @@ def run(schema: GraphQLSchema, config: dict):
104104
if config.get('generation').get('query_list_of'):
105105
schema = add_list_of_types(schema)
106106
schema = add_list_queries(schema)
107-
#schema = add_filters_to_type_fields(schema)
108107

109108
# add input types
110109
if config.get('generation').get('input_to_create_objects'):

graphql-api-generator/utils/utils.py

Lines changed: 34 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -337,29 +337,45 @@ def add_scalar_filters(schema: GraphQLSchema):
337337

338338
# String
339339
make += 'input _StringFilter {' \
340-
' _eq: String ' \
341-
' _neq: String ' \
342-
' _gt: String ' \
343-
' _egt: String ' \
344-
' _lt: String ' \
345-
' _elt: String ' \
346-
' _in: [String] ' \
347-
' _nin: [String] ' \
348-
' _like: String ' \
349-
' _ilike: String ' \
350-
' _nlike: String ' \
351-
' _nilike: String ' \
352-
'} '
340+
' _eq: String ' \
341+
' _neq: String ' \
342+
' _gt: String ' \
343+
' _egt: String ' \
344+
' _lt: String ' \
345+
' _elt: String ' \
346+
' _in: [String] ' \
347+
' _nin: [String] ' \
348+
' _like: String ' \
349+
' _ilike: String ' \
350+
' _nlike: String ' \
351+
' _nilike: String ' \
352+
'} '
353+
354+
# ID (behaves like a string)
355+
make += 'input _IDFilter {' \
356+
' _eq: String ' \
357+
' _neq: String ' \
358+
' _gt: String ' \
359+
' _egt: String ' \
360+
' _lt: String ' \
361+
' _elt: String ' \
362+
' _in: [String] ' \
363+
' _nin: [String] ' \
364+
' _like: String ' \
365+
' _ilike: String ' \
366+
' _nlike: String ' \
367+
' _nilike: String ' \
368+
'} '
353369

354370
# Boolean
355371
make += 'input _BooleanFilter {' \
356-
' _eq: Boolean ' \
357-
' _neq: Boolean ' \
358-
'} '
372+
' _eq: Boolean ' \
373+
' _neq: Boolean ' \
374+
'} '
359375

360-
# ID and schema-defined scalars
376+
# Schema-defined scalars
361377
for scalar_name, scalar in schema.type_map.items():
362-
if not is_scalar_type(scalar) or scalar_name in ['Int', 'Float', 'String', 'Boolean']:
378+
if not is_scalar_type(scalar) or scalar_name in ['Int', 'Float', 'String', 'Boolean', 'ID']:
363379
continue
364380

365381
make += f'input _{scalar_name}Filter {{' \

0 commit comments

Comments
 (0)