Closed danieledwardgeorgehitchcock closed 11 months ago
Hi,
Thanks for your feedback.
I downloaded your project, found the query you are mentioning here and had a quick look at the code generated which seems to reflect correctly the rippleenergy schema you shared.
Using a mapped operation in its simplest way (in your case Me()
) generates a query containing all fields and inner types it has in the schema definition.
Taking as example member
inner type, you were expecting the following
member {
id
registrationCompleted
__typename
}
but actually it is composed of many more fields (as per the generated code )
class Member(GQLObject):
id: ID
registrationCompleted: bool
communityName: str
isBusiness: bool
businessName: str
businessRegistrationNumber: str
fullyChargedPreregistered: bool
badges: list_Badge[Badge]
branding: Branding
beneficiaries: list_MemberNextOfKin[MemberNextOfKin]
address: MemberAddress
consumption: MemberConsumption
invoices: list_MemberInvoice[MemberInvoice]
memberships: list_GQLObject[GQLObject] ## Circular Reference for CoopMembership
capacityOwnedTotal: BigInt
ownershipPercentageTotal: float
memberDocument: MemberDocument
investmentTotal: int
billSavingsAcrossAllProjects: int
expectedGenerationAnnualTotal: BigInt
hasReservedInActiveCoop: bool
dateOfReservationInActiveCoop: Date
dateOfLastSharePurchase: Date
hasBoughtSharesInActiveCoop: bool
hasBoughtSharesInGraigFatha: bool
hasBoughtSharesInKirkHill: bool
hasBoughtSharesInMultipleCoops: bool
isSuppliedByOctopusEnergy: bool
currentMemberSupplier: MemberSupplier
waitingListPlaces: list_MemberCoopWaitingListPlace[MemberCoopWaitingListPlace]
Consequently the generated call is including mandatory arguments for its inner types.
In order to achieve the query you want there are several ways:
1) Using set_show
function available in the query object (not very suitable for your situation, you should call it for each field)
Examples of usage can be found [here](https://github.com/dapalex/py-graphql-mapper/blob/develop/tests/tstquery/connobj_viewchange_test.py) or [here](https://github.com/dapalex/py-graphql-mapper/blob/develop/tests/tstquery/complex_obj_test.py)
Documentation [here](https://github.com/dapalex/py-graphql-mapper/tree/develop/pygqlmap#dynamic-visibility-of-fields)
2) Directly removing the fields you don't need in the generated class (if you are sure you won't ever need them)
3) Creating a custom type using pygqlmap
module (which is a fairly simple implementation).
An example of usage can be found here
Documentation here
I am using this tool to create a Python Module see here. This is using the open GraphQL API instance here.
I seem to be having issues regarding the recursion of fields in comparison to what I am expecting to see from the documented queries in the GraphQL client referenced above.
An example of this is as follows:
Expected query:
Query from generator:
I have tried following through the examples in the repo to try and resolve this but cannot seem to work out if it is a bug or a misunderstanding..?
At present, the generated call throws multiple errors due to missing required values from the response