-
Notifications
You must be signed in to change notification settings - Fork 70
question: how to generate globalTypes (like apollo) #175
Comments
I’m not sure. Maybe @alloy can answer you. |
custom scalar is ok.
this enum type is generated for for example, apollo tooling is generating a file that contained all enum types. schema: enum Color {
BLUE
GREEN
RED
}
enum Direction {
Right
Left
} apollo client:codegen --globalTypesFile=src/globalTypes.ts the generated file is independent of any query or fragment in the code and only depends on the schema file. generated file export enum GenerationType {
BLUE = "BLUE",
GREEN = "GREEN",
RED = "RED",
}
export enum Direction {/*..*/}
// and all other enums defined in the schema file for the relay, it would be like export type Color = "BLUE" | "GREEN" | "RED" | "%future added value";
export type Direction = "..." |
for example, the |
you want something like this
can you try implement this to Typescript? |
yes. it is what I want (I assume schema argument is all defined types in graphql)
yes, I can. flow and typescript output is almost equal in this case. except for the header part. but I don't know at which file it should be written. or where and how this function should be used. (integrated with relay-compiler-language-typescript and relay-compiler) |
Me and @smmoosavi wrote a package for this purpose: |
Great to hear, can you add this to relay documentation? |
@sibelius Where should I add this to? |
Check Facebook/relay repo, there is a docusaurus there, this could be close to type emission guide |
How about just type aliases? |
we can generate global types (like enums) with apollo tooling. you can see
--globalTypesFile
option.can we do the same thing with relay compiler and generate global types file.
tnx
The text was updated successfully, but these errors were encountered: