Modifiers It may be helpful first to g… At its heart graphql is all about declaring a type schema and mapping that over backing runtime data. This issue has been open for a very long time. By clicking “Sign up for GitHub”, you agree to our terms of service and The path of least resistance is the path most often traveled. In the case of user-defined JSON data, can we just make it clear that custom scalars aren't restricted to how they can be serialized. This should create a new file called resolvers-types.ts in your codebase. Our challenge is to take these 3 sources of information and present them as one unified type. The number of locales is undefined. In my use-case I have objects of this shape (in typescript): Using the list of key-values would mean I am doing a transformation on the server to send the data and then do the reverse transformation on the client to build up that map again. I would like to support ES6 Map construction directly from json. Find more information about that process here https://github.com/facebook/graphql/blob/master/CONTRIBUTING.md. For anyone arriving here looking for a Map type, I suggest first reading the comments on this thread about the API design tradeoffs and alternative approaches available. For the object returned by hero, we select the name and appearsIn fieldsBecause the shape of a GraphQL query closely matches the result, you can predict what the query will return without knowing that much about the server. So it would result in a very tedious and rather hard to maintain union type. } If you’re unfamiliar with the concept of defining a GraphQL schema, think of it as a manifest for declaring what kinds of objects and queries are available within your API. Our API delivers content defined and managed through a custom CMS, and a main feature is being flexible and dynamic. By default, every type is nullable - it's legitimate to return null as any of the scalar types. This means that if there is a choice of creating a new type that has more semantic meaning to the UI or creating a map that has no tooling support or contract, but is "quick" to create on the server, then a map is going to be used. ), or have a fromString (or fromInt / fromDate - depending on the Scalar type) static method. 3.1.1.1 Int. In the previous articles, we talked about the basic set-up for GraphQL projects as well as the use of GraphiQL for executing queries and mutations. If you need multiple you can use aliases to query for multiple. the fields id, name, cost, tax. (versus approach 2 in, view, the data is shown to a user in his/her 's preferred language, admin, the data is to be edited (translations added / changed / removed) by an administrative user. For every object in the list it will look for an id field, find it by name in a map or via a getId() getter method and that will be sent back in the graphql Scalars. This means that it becomes much harder to integrate with generic tools like GraphiQL and do introspection in general. +1. Of course you can use the express-graphql middleware, graphql-yoga or whatever you want Create typeDefs and resolvers map. One is via using a not type safe List