Skip to content

Instantly share code, notes, and snippets.

@ryuichi24
Last active November 14, 2022 12:02
Show Gist options
  • Save ryuichi24/60be5590deb4bb933733e81ece07e0c5 to your computer and use it in GitHub Desktop.
Save ryuichi24/60be5590deb4bb933733e81ece07e0c5 to your computer and use it in GitHub Desktop.
vscode snippets
{
// https://stackoverflow.com/questions/65846228/capitalize-first-letter-of-vscode-snippet
"template for mutation": {
"prefix": "mu",
"body": [
"input $1Input {",
"\t$2",
"}",
"",
"type $1Response {",
"\t$3",
"}",
"",
"type Mutation {",
"\t${1/(.)/${1:/downcase}/}(${1/(.)/${1:/downcase}/}Input: $1Input!): $1Response!",
"}",
""
]
},
"template for query": {
"prefix": "qu",
"body": [
"input $1Input {",
"\t$2",
"}",
"",
"type $1Response {",
"\t$3",
"}",
"",
"type Query {",
"\t${1/(.)/${1:/downcase}/}(${1/(.)/${1:/downcase}/}Input: $1Input!): $1Response!",
"}",
""
]
}
}
{
// https://blog.webdevsimplified.com/2022-03/vscode-snippet/
"template for graphql resolver": {
"prefix": "reso",
"body": [
"export const resolvers: Resolvers<MyContext$1> = {",
"\t${2|Mutation,Query|}: {",
"\t\t$3: async (_, args, context, info) => {",
"\t\t\treturn {",
"\t\t\t\t$4",
"\t\t\t}",
"\t\t}",
"\t}",
"}",
""
]
}
}
{
"template for React Function Component": {
"prefix": "rf",
"body": [
"import React from 'react'",
"",
"type ${TM_FILENAME_BASE}Props = {",
"$1",
"}",
"",
"export const $TM_FILENAME_BASE: React.FC<${TM_FILENAME_BASE}Props> = ({$2}) => {",
"\t\treturn (<>${TM_FILENAME_BASE}</>);",
"}"
],
"description": "Typescript React Function Component"
},
"template for useState": {
"prefix": "us",
"body": [
"const [$1, set${1/(.)/${1:/upcase}/}] = useState<$2>($3);"
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment