profusion / sgqlc

Simple GraphQL Client
https://sgqlc.readthedocs.io/
ISC License
506 stars 85 forks source link

add: --exclude-default-types and --add-scalar-imports arguments to schema codegen #227

Closed volga closed 1 year ago

volga commented 1 year ago

Description

We are testing Golang services that use the library https://github.com/99designs/gqlgen to generate the code. This library also uses a custom scalar Time type, but, unlike the sgqlc library, in it the Time type is a complete representation of the timestamp.

With the current changes, it is proposed to add: --exclude-default-types argument to the client generation utility, which provides the ability to deactivate the use of default types in the generated client; --add-scalar-imports argument to the client generation utility, which provides the ability to import the use of custom scalar types in the generated client.

Pull request checklist

How to test it

use sgqlc-codegen schema -d schema.json --exclude-default-types Time Date DateTimes command with --exclude-default-types argument

Visual reference

with argument in command

class Time(sgqlc.types.Scalar):
    __schema__ = schema

without argument in command

Time = sgqlc.types.datetime.Time
volga commented 1 year ago

Hi, @barbieri ! Could you check this final patch, please? We already need these changes in our work. I am sure that these are useful changes for library users.

volga commented 1 year ago

Ping šŸ˜‰

barbieri commented 1 year ago

thanks for pinging, will look into it today... I forgot it in a pile of TODO list šŸ˜…

volga commented 1 year ago

Sorry! Somehow a commit was added past the hooks. And I still have changes on the local. Now everything is fine - I sent them.

volga commented 1 year ago

Ping šŸ””

volga commented 1 year ago

@barbieri Hello! Can you release this patch? We want to use them in our work.

volga commented 1 year ago

Ping šŸ””

volga commented 1 year ago

Hello, @barbieri! Thank you! Can you release it?

barbieri commented 1 year ago

done https://pypi.org/project/sgqlc/16.2/