github.com/speedoops/go-gqlrest-demo@v0.0.0-20220710122636-5c6460aeab4f/graph/todo.graphqls (about) 1 # GraphQL schema example 2 # 3 # https://gqlgen.com/getting-started/ 4 5 # https://github.com/99designs/gqlgen/issues/1579 6 #directive @deprecated(reason: String = "No longer supported") on FIELD_DEFINITION | ENUM_VALUE 7 8 extend type Mutation { 9 createTodo(input: NewTodoInput!): Todo! @http(url: "/api/v1/todos") 10 updateTodo(input: UpdateTodoInput!): Todo! 11 @http(url: "/api/v1/todo/{id}", method: "PUT") 12 completeTodo(id: ID!): Todo! @http(url: "/api/v1/todo/{id}/complete") 13 completeTodos(ids: [ID!]): [Todo!] @http(url: "/api/v1/todos/bulk-complete") 14 deleteTodo(id: ID!): Boolean! 15 @http(url: "/api/v1/todo/{id}", method: "DELETE") 16 deleteTodoByUser(userID: ID!): Boolean! 17 @http(url: "/api/v1/todos", method: "DELETE") 18 @hasRole(role: ADMIN) 19 @hide(for: ["rest"]) 20 } 21 22 input NewTodoInput { 23 text: String! 24 userID: String! 25 done: Boolean 26 } 27 28 input UpdateTodoInput { 29 id: ID! # https://www.apollographql.com/blog/graphql/basics/designing-graphql-mutations/ 30 text: String 31 userID: String 32 } 33 34 extend type Query { 35 todo(id: ID!, name: String, tmp: Int): Todo! @http(url: "/api/v1/todos/{id}") 36 todos( 37 ids: [ID!] 38 userId: ID 39 types: [TodoType] 40 text: String 41 text2: [String] 42 done: Boolean 43 done2: [Boolean!] 44 pageOffset: Int 45 pageSize: Int 46 ): [Todo!]! @http(url: "/api/v1/todos") 47 } 48 type Todo { 49 id: ID! 50 text: String! 51 done: Boolean! @deprecated(reason: "blah blah") 52 user: User! @hide(for: ["rest", "cli"]) 53 type: TodoType 54 categories: [Category!] @hide(for: ["rest0", "cli"]) 55 } 56 type Category { 57 id: ID! @hide(for: ["rest", "cli"]) 58 name: String! 59 } 60 61 enum TodoType { 62 TypeA 63 TypeB 64 }