MANOMANO
Native GraphQL in PHP:
A journey
GraphQWhat?
Introduction to GraphQL
GraphQWhat?
Introduction to GraphQL
Learn how it works on their official page
ManoMano confidential
GraphQWhat?
GraphQL VS REST
ManoMano confidential
GraphQWhat?
So why choose GraphQL at ManoMano?
ManoMano confidential
GraphQWhat?
Introduction to Apollo Federation
Microservice architecture + GraphQL = Problems?
We want a single GraphQL schema for the whole website, gluing together all GraphQL APIs from our microservices
Solution => Apollo GraphQL Federation
ManoMano confidential
GraphQWhat?
Introduction to Apollo Federation
ManoMano confidential
GraphQWhat?
Introduction to Apollo Federation
Apollo federation norms v1 requires the following to be implemented:
ManoMano confidential
GraphQL at ManoMano
Our adoption plan
GraphQL at ManoMano
Adoption plan: current state
ManoMano confidential
GraphQL at ManoMano
Adoption plan: target state
ManoMano confidential
Apollo Federation in PHP
Application to our homepage microservice
Apollo Federation in PHP
Situation before GraphQL
ManoMano confidential
Apollo Federation in PHP
Situation before GraphQL
So, we want to try out GraphQL now
We will create a new "adapter" component that will convert the public REST API into a GraphQL one
The NodeJS dog
All adapters will be in NodeJS! YOLOL!!!
LOL!!!
ManoMano confidential
Apollo Federation in PHP
Situation during GraphQL experiment
ManoMano confidential
Apollo Federation in PHP
Situation during GraphQL experiment
The NodeJS dog
Le PHP dog
We can't maintain the adapter anymore. You do it. LOL.
Wait, quoi? We don't know nodeJS!
LOL?
How about we handle le GraphQL directly from le microservice?
We could maintain le GraphQL then. This removes complexity and improves performance.
We will changer some things, but we will make sure to include your legacy API
ManoMano confidential
Apollo Federation in PHP
Situation after adding Federation to the ms
ManoMano confidential
Apollo Federation in PHP
Situation after adding Federation to the ms
Le PHP dog
The archi-dog
Bien sûr! We will clean this up once we're sûrs le public REST API is no longer used.
Very nice! But your work is not completely done.
Don't forget one of our goals with GraphQL is to get rid of MSF.
This could take some time, though…
ManoMano confidential
Apollo Federation in PHP
Target situation
ManoMano confidential
Steak tack
or is it Tech Stack?
Tech stack
Analysis
The official Federation page of the Apollo website lists officially recognized implementations in various languages, including PHP.
Only 2 libraries implement Federation:
Neither are compatible yet with Federation V2.
ManoMano confidential
Tech stack
Green elements are new to the stack
ManoMano confidential
How it works
How it works
Resulting schema
Link to the federated schema here
ManoMano confidential
How it works
Controller
ManoMano confidential
How it works
Infrastructure code
Folders:
Files:
ManoMano confidential
How it works
Non-blocking errors
Problem:
Solution:
ManoMano confidential
How it works
Limited listing
For this specific API, none of the listing actions needs pagination. This does not mean we should allow any number of items to be returned!
ManoMano confidential
Caveats
Caveats
Federation v2
Not available yet… An MR on skillshare/apollo-federation-php is on the way but is not merged yet.
Open-source world is slow-paced -> we should not wait for this feature to be merged.
In case this cause a problem on the long-term, either
ManoMano confidential
Caveats
Schema maintenance
The following is specific to ManoMano
Code First: The GraphQL schema is generated from code instead of versioned
Tools do exist in the package to generate the schema from code.
However the result is not compatible with our current supergraph deployment system. The schema generation system is not extensible and this behaviour cannot be fixed easily.
Consequently the schema must be maintained manually
ManoMano confidential
Caveats
Graph renaming
The following is not specific to PHP
The following is specific to ManoMano
The legacy graph was named homepage-b2c, we wanted to rename it to homepage
However the current deployment system won't allow this - because it would create service interruptions
ManoMano confidential
If you want to do the same thing
Some advice
If you want to do the same thing
Architecture
The following advice is not specific to PHP
ManoMano confidential
If you want to do the same thing
Development
The following advice is not specific to PHP
ManoMano confidential
Conclusions
Conclusion
Takeaways
Few ManoMano projects still use PHP, so a specific lib/bundle was not deemed necessary in our case.
ManoMano confidential
Resources
Resources
Some links
ManoMano confidential