Slide 1

Slide 1 text

Efficient Feature Implementation Using Type Merging Yan

Slide 2

Slide 2 text

Today's keynote is available for public viewing on Speaker Deck. Feel free to share :)

Slide 3

Slide 3 text

TOC 1. Self introduction 2. Introduction of the services 3. Use case of the GraphQL Stitching and the Type Merging 3. How Type Merging improve cross service development 4. 3 challenges I faced

Slide 4

Slide 4 text

1. Self introduction I’m Yan (@mtyk_5) 󰢧 Kondo Motoya RevComm We are using GraphQL with Python. (Personally, I’ve not joined that team) Kalonade (quited) Using Hasura as a backend SHE Using GraphQL Yoga

Slide 5

Slide 5 text

1. Self introduction I’m Yan 󰢧 Kondo Motoya RevComm We are using GraphQL with Python. (Personally, I’ve not joined that team) Kalonade (quited) Using Hasura as a backend SHE Using GraphQL Yoga

Slide 6

Slide 6 text

2. Introduction of the services At SHE, we provide services for upskilling. We offer two main types of services: For learners. (like Udemy) For companies looking to hire learners. SHElikes SHE WORKS

Slide 7

Slide 7 text

2. Introduction of the services SHElikes API SHE WORKS API SHEProf API DB DB DB SHElikes SHE WORKS

Slide 8

Slide 8 text

2. Introduction of the services SHElikes API SHE WORKS API SHEProf API DB DB DB SHElikes SHE WORKS

Slide 9

Slide 9 text

3. Use case of the GraphQL Stitching and the Type Merging SHEProf API DB SHElikes https://www.freepik.com/free-vector/attractive-online-curriculum-template_23 33343.htm#query=profile%20ui&position=13&from_view=search&track=ais Freepik It's a part of our learning service, a service similar to LinkedIn where users can view each other's profiles. Users can enter their key attributes and create a simple resume, highlighting their strengths.

Slide 10

Slide 10 text

3. Use case of the GraphQL Stitching and the Type Merging SHE WORKS API DB SHE WORKS https://www.freepik.com/free-photo/application-form-employme nt-document-concept_18138154.htm#query=applicant%20for m&position=23&from_view=search&track=ais on Freepik It's a service that connects companies with learners. For instance, companies can initiate competitions for specific jobs, and learners can apply based on their own achievements and work.

Slide 11

Slide 11 text

3. Use case of the GraphQL Stitching and the Type Merging SHE WORKS API DB SHE WORKS https://www.freepik.com/free-photo/application-form-employme nt-document-concept_18138154.htm#query=applicant%20for m&position=23&from_view=search&track=ais on Freepik what is your profile URL? Learners need to include the URL to their own profile when applying to companies. Unfortunately, sometimes users make mistakes in this process, which can result in missed job opportunities.

Slide 12

Slide 12 text

3. Use case of the GraphQL Stitching and the Type Merging SHE WORKS API DB SHE WORKS https://www.freepik.com/free-photo/application-form-employme nt-document-concept_18138154.htm#query=applicant%20for m&position=23&from_view=search&track=ais on Freepik what is your profile URL? Learners need to include the URL to their own profile when applying to companies. Unfortunately, sometimes users make mistakes in this process, which can result in missed job opportunities. How can we address this issue?

Slide 13

Slide 13 text

3. Use case of the GraphQL Stitching and the Type Merging SHE WORKS API DB SHE WORKS SHEProf API DB Should we use two different GraphQL API? Maybe, No.

Slide 14

Slide 14 text

3. Use case of the GraphQL Stitching and the Type Merging SHE WORKS API DB SHE WORKS SHEProf API DB We should use GraphQL Stitching to connect both SHEProf API and SHE Works API. We call this server as “GraphQL Gateway”. GraphQL Gateway

Slide 15

Slide 15 text

3. Use case of the GraphQL Stitching and the Type Merging The implementation of the Gateway was done using the following steps: 1. Implemented a query that outputs the schema as a string, called '_sdl Query,' for each Sub GraphQL API. 2. Used this information to retrieve the schema for each Sub GraphQL API within the GraphQL Gateway. 3. Finally, used the stitchSchemas function to generate the schema for the GraphQL Gateway. See the sample implementation -> https://the-guild.dev/graphql/stitching/docs/approaches/stitching-directives

Slide 16

Slide 16 text

3. How Type Merging improve cross service development Using GraphQL Stitching, we were able to connect two Sub GraphQL APIs. The next step is to retrieve the desired data without creating a new query by utilizing Type Merging. SHE WORKS API SHEProf API Type User { id profile: Profile } type Profile { userId profileUrl } Type User { id } Query { getUser(id: String): User }

Slide 17

Slide 17 text

3. How Type Merging improve cross service development SHE WORKS API SHEProf API Type User { id profile: Profile } type Profile { userId profileUrl } Type User { id } Query { getUser(id: String): User } Gateway API Type User { id profile: Profile 👀 } type Profile { userId profileUrl } Query { getUser(id: String!): User 👀 }

Slide 18

Slide 18 text

3. How Type Merging improve cross service development SHE WORKS API SHEProf API Type User { id profile: Profile } type Profile { userId profileUrl } Type User { id } Query { getUser(id: String): User } Gateway API Type User { id profile: Profile 👀 } type Profile { userId profileUrl } Query { getUser(id: String!): User 👀 } How can we merge types?

Slide 19

Slide 19 text

3. How Type Merging improve cross service development You can merge types with Type Merging. https://the-guild.dev/graphql/stitching/docs/approaches/type-merging 1. Define merge configuration in the GraphQL Gateway Schmea 2. Define merge configuration in the each Sub GraphQL Schema with directive

Slide 20

Slide 20 text

3. How Type Merging improve cross service development You can merge types with Type Merging. https://the-guild.dev/graphql/stitching/docs/approaches/type-merging 1. Define merge configuration in the GraphQL Gateway Schmea 2. Define merge configuration in the each Sub GraphQL Schema with directive

Slide 21

Slide 21 text

3. How Type Merging improve cross service development You can merge types with Type Merging. https://the-guild.dev/graphql/stitching/docs/approaches/type-merging 1. Define merge configuration in the GraphQL Gateway Schmea 2. Define merge configuration in the each Sub GraphQL Schema with directive

Slide 22

Slide 22 text

3. How Type Merging improve cross service development The concept of Type Merging is best illustrated in the official documentation's diagram.

Slide 23

Slide 23 text

When I implemented the function, I faced some challenges…

Slide 24

Slide 24 text

4. 3 challenges I faced Where should we defined the “Typem merging configuration” If we use “directive” on the each sub GraphQL API Schema. SHElikes Team SHE WORKS Team Schema Schema Gateway

Slide 25

Slide 25 text

4. 3 challenges I faced Where should we defined the “Typem merging configuration” If we use “directive” on the each sub GraphQL API Schema. 👍 We don’t need to touch GraphQL Gateway. So, the each team can implement their functions separately. 👍 Defining with “directives” seems to be simple. 😓 Since you don't actually see the integrated schema in the Gateway, as the system scales up, there may be cases where it doesn't work correctly, and it's difficult to understand why.

Slide 26

Slide 26 text

4. 3 challenges I faced Where should we defined the “Typem merging configuration” If we use “directive” on the each sub GraphQL API Schema. 👍 We don’t need to touch GraphQL Gateway. So, the each team can implement their functions separately. 👍 Defining with “directives” seems to be simple. 😓 Since you don't actually see the integrated schema in the Gateway, as the system scales up, there may be cases where it doesn't work correctly, and it's difficult to understand why. 󰢧 If you have a opinion or good idea let’s discuss later!

Slide 27

Slide 27 text

4. 3 challenges I faced How can we define “kindly” Schema to other teams. We should prepare like the following Schema for the GraphQL Gateway even though we don’t use it for the Sub API GraphQL. Query { getUser(id: String!): User }

Slide 28

Slide 28 text

4. 3 challenges I faced How can we define “kindly” Schema to other teams. We should prepare like the following Schema for the GraphQL Gateway even though we don’t use it for the Sub API GraphQL. Query { getUser(id: String!): User } 󰢧 Is there any “eslint” staff to restrict the developers to follow the regurgitation or defect standard? If you have any thoughts, please let me know!

Slide 29

Slide 29 text

4. 3 challenges I faced How can I debug the GraphQL Stitching? I encountered cases where I couldn't pinpoint where the issue was occurring during the actual implementation. Sub GraphQL Schema GraphQL Gateway Resolvers

Slide 30

Slide 30 text

4. 3 challenges I faced How can I debug the GraphQL Stitching? I encountered cases where I couldn't pinpoint where the issue was occurring during the actual implementation. Sub GraphQL Schema GraphQL Gateway Resolvers 🙃 The Gateway send collect queries?

Slide 31

Slide 31 text

4. 3 challenges I faced How can I debug the GraphQL Stitching? Personally, I checked the executor function to find what query is executed. But I believe there are more efficient way to do debug. I will deeply look into the issues, but if you have a time. Let’s discuss!

Slide 32

Slide 32 text

Thank you for your attention, I will find answers and share them on docs later!