Name: Abdulamalik IramaStudent Number: 169050206Part 1: Text-to-ModelGraphQL queries are strings interpreted and parsed by the server.
A received query is first checked to ensure it only refers to the types and fields defined, the GraphQL server returns specific data format which has already been specified by the client if there are any syntax errors, the server stops execution and returns an error message to the client.GraphQL is an application-layer protocol and it’s not tied to HTTP unlike Representational State Transfer (REST). The parser exposes lower level APIs for generating GraphQL Abstract Syntax Tree (AST) and traversing it.
The parser also exposes tagged function for parsing GraphQL queries2.GraphQL server parses the query, once the parsing has taken place then validation occurs before execution if the syntax is correct. The executors call the resolve functions and waits for the resolve functions return all values before cascading down the tree5. GraphQL resolve functions could contain arbitrary code because of that GraphQL server can communicate to a different kind of backend and also other GraphQL servers5.Part 2: Model-to-TextGraphQL could be used for generating Typescripts, Flow typings, backend code which could be Java, .
NET and many more. Also for generating REST APIs, personal resolvers, personal data models, query buildersCode Generation in GraphQL takes the description of the system types and sets GraphQL queries as inputs and outputs a set of response models and query requests3.REFERENCE1.Nick Schrock.
2015. GraphQL Introduction. ONLINE Available at https://reactjs.org/blog/2015/05/01/graphql-introduction.html. Accessed 3 January 2018.2. Florent Cailhol.
2015. Experimental Facebook’s GraphQL parser. ONLINE Available at: https://www.npmjs.com/package/graphql-parser. Accessed 3 January 2018.3. Sashko Stubailo.
2015. Native code generation at Facebook. ONLINE Available at: https://dev-blog.apollodata.com/native-code-generation-at-facebook-7d6d0db4f3ee. Accessed 3 January 2018.
4. Dotan Simha. 2017. GraphQL Code-Generator 1.0.
ONLINE Available at: https://dev-blog.apollodata.com/native-code-generation-at-facebook-7d6d0db4f3ee. Accessed 3 January 2018.5. Apollo GraphQL.
(2016). GraphQL explained – Apollo GraphQL. online Available at: https://dev-blog.
apollodata.com/graphql-explained-5844742f195e Accessed 3 Jan. 2018.