Skip to main content

Backend

Accounts are now customized to add multiple fields.

  1. Accounts module is imported from adminide-stack/accounts-api-server the module has basic fields like email, phone number, etc and those are added to graphql schema and mongo schema like below.

Mongo Schema

image

Graphql Schema

image

  1. We can inject the default mongo schema through the module.

image

image

  1. But if we need to customize accounts to add more fields, we can skip the default module.

a) Add extended fields in mongo scheme like below.

image

b) As well graphql extension. Make sure to add the directives @isAuthenticated @addAccountContext at the end.

image

Generate graphql types by running yarn generateGraphql and all the new files generated need to be compiled in those specific packages.

c) Write service

image

d) Add necessary types to refer in the Container

image

e) Bind to the IAccountMongoExtSchema in Container for extending Account's Mongo Schema. Also bind ExtendedAccountServce for accessing in the resolvers.

image

d) Write the resolver to get the specific field data

image

f) Include it in the modules

image

Frontend

On frontend you can write queries how you want.

For example if you need to get Composite Account data including the basic account field + exntended account fields, you can query in one gql

Fragment

image

Query

image

Also you can call individual queries

image

After any changes to .gql or .graphql make sure to run yarn generateGraphql to generate types.