@@ -25,35 +25,36 @@ var (
2525 querySchemaOnly bool
2626)
2727
28- var queryCmd = & cobra.Command {
29- Use : "query <graphql>" ,
30- Short : "Execute a GraphQL query" ,
31- Long : `Execute a GraphQL query against the beans data.
28+ var graphqlCmd = & cobra.Command {
29+ Use : "graphql <query>" ,
30+ Aliases : []string {"query" },
31+ Short : "Execute a GraphQL query or mutation" ,
32+ Long : `Execute a GraphQL query or mutation against the beans data.
3233
33- The query argument should be a valid GraphQL query string.
34+ The argument should be a valid GraphQL query or mutation string.
3435
3536Examples:
3637 # List all beans
37- beans query '{ beans { id title status } }'
38+ beans graphql '{ beans { id title status } }'
3839
3940 # Get a specific bean
40- beans query '{ bean(id: "abc") { title status body } }'
41+ beans graphql '{ bean(id: "abc") { title status body } }'
4142
4243 # Filter beans by status
43- beans query '{ beans(filter: { status: ["todo", "in-progress"] }) { id title } }'
44+ beans graphql '{ beans(filter: { status: ["todo", "in-progress"] }) { id title } }'
4445
4546 # Get beans with relationships
46- beans query '{ beans { id title blockedBy { id title } children { id title } } }'
47+ beans graphql '{ beans { id title blockedBy { id title } children { id title } } }'
4748
4849 # Use variables
49- beans query -v '{"id": "abc"}' 'query GetBean($id: ID!) { bean(id: $id) { title } }'
50+ beans graphql -v '{"id": "abc"}' 'query GetBean($id: ID!) { bean(id: $id) { title } }'
5051
51- # Read query from stdin (useful for complex queries or escaping issues)
52- echo '{ beans { id title } }' | beans query
53- cat query.graphql | beans query
52+ # Read from stdin (useful for complex queries or escaping issues)
53+ echo '{ beans { id title } }' | beans graphql
54+ cat query.graphql | beans graphql
5455
5556 # Print the schema
56- beans query --schema` ,
57+ beans graphql --schema` ,
5758 Args : func (cmd * cobra.Command , args []string ) error {
5859 if querySchemaOnly {
5960 return nil
@@ -206,9 +207,9 @@ func GetGraphQLSchema() string {
206207}
207208
208209func init () {
209- queryCmd .Flags ().BoolVar (& queryJSON , "json" , false , "Output raw JSON (no formatting)" )
210- queryCmd .Flags ().StringVarP (& queryVariables , "variables" , "v" , "" , "Query variables as JSON string" )
211- queryCmd .Flags ().StringVarP (& queryOperation , "operation" , "o" , "" , "Operation name (for multi-operation documents)" )
212- queryCmd .Flags ().BoolVar (& querySchemaOnly , "schema" , false , "Print the GraphQL schema and exit" )
213- rootCmd .AddCommand (queryCmd )
210+ graphqlCmd .Flags ().BoolVar (& queryJSON , "json" , false , "Output raw JSON (no formatting)" )
211+ graphqlCmd .Flags ().StringVarP (& queryVariables , "variables" , "v" , "" , "Query variables as JSON string" )
212+ graphqlCmd .Flags ().StringVarP (& queryOperation , "operation" , "o" , "" , "Operation name (for multi-operation documents)" )
213+ graphqlCmd .Flags ().BoolVar (& querySchemaOnly , "schema" , false , "Print the GraphQL schema and exit" )
214+ rootCmd .AddCommand (graphqlCmd )
214215}
0 commit comments