# Make a local copy of your GraphQL schema
get-graphql-schema https://my-graphql-endpoint.com/v1/graphql > schema.gql
go-graphql-client-gen --operations operations.sql run
- Type Mapping
- Scalar Generation
- Type Generation
- Object Generation
- Query Generation
- Inline Fragments
- Fragment Spreads
- Mutation Generation
- CLI commands
- Remote schema support
- Custom type mapping/overrides
- Multiple selection sets in the root operation
Visit the examples directory for various working examples.
Schema from https://countries.trevorblades.com/ Full schema is located at examples/countries/schema.gql Generated types and operations at examples/countries/types
type Continent {
code: ID!
name: String!
countries: [Country!]!
}
type Country {
code: ID!
name: String!
native: String!
phone: String!
continent: Continent!
capital: String
currency: String
languages: [Language!]!
emoji: String!
emojiU: String!
states: [State!]!
}
type Language {
code: ID!
name: String
native: String
rtl: Boolean!
}
type State {
code: String
name: String!
country: Country!
}
type Continent struct {
Code id `graphql:"code" json:"code,omitempty"` // code ID!
Name string `graphql:"name" json:"name,omitempty"` // name String!
Countries []Country `graphql:"countries" json:"countries,omitempty"` // countries [Country!]!
}
type Country struct {
Code id `graphql:"code" json:"code,omitempty"` // code ID!
Name string `graphql:"name" json:"name,omitempty"` // name String!
Native string `graphql:"native" json:"native,omitempty"` // native String!
Phone string `graphql:"phone" json:"phone,omitempty"` // phone String!
Continent Continent `graphql:"continent" json:"continent,omitempty"` // continent Continent!
Capital *string `graphql:"capital" json:"capital,omitempty"` // capital String
Currency *string `graphql:"currency" json:"currency,omitempty"` // currency String
Languages []Language `graphql:"languages" json:"languages,omitempty"` // languages [Language!]!
Emoji string `graphql:"emoji" json:"emoji,omitempty"` // emoji String!
EmojiU string `graphql:"emojiU" json:"emojiU,omitempty"` // emojiU String!
States []State `graphql:"states" json:"states,omitempty"` // states [State!]!
}
type Language struct {
Code id `graphql:"code" json:"code,omitempty"` // code ID!
Name *string `graphql:"name" json:"name,omitempty"` // name String
Native *string `graphql:"native" json:"native,omitempty"` // native String
Rtl bool `graphql:"rtl" json:"rtl,omitempty"` // rtl Boolean!
}
type State struct {
Code *string `graphql:"code" json:"code,omitempty"` // code String
Name string `graphql:"name" json:"name,omitempty"` // name String!
Country Country `graphql:"country" json:"country,omitempty"` // country Country!
}