Skip to content

pollen8/clubmanager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Front end:

cd client
npm start

Backend:

Run server (MySQL and Prisma) & Start the GraphQL server

cd server
docker-compose up -d && npm run start

Updating the database structure

Edit prisma/dataodel.prisma then

prisma deploy

Navigate to http://localhost:4000 in your browser to explore the API of your GraphQL server in a GraphQL Playground.

5. Using the GraphQL API

The schema that specifies the API operations of your GraphQL server is defined in ./src/schema.graphql. Below are a number of operations that you can send to the API using the GraphQL Playground.

Feel free to adjust any operation by adding or removing fields. The GraphQL Playground helps you with its auto-completion and query validation features.

Retrieve all published posts and their authors

query {
  feed {
    id
    title
    content
    published
    author {
      id
      name
      email
    }
  }
}
See more API operations

Create a new user

mutation {
  signupUser(
    name: "Sarah"
    email: "[email protected]"
  ) {
    id
  }
}

Create a new draft

mutation {
  createDraft(
    title: "Join the Prisma Slack"
    content: "https://slack.prisma.io"
    authorEmail: "[email protected]"
  ) {
    id
    published
  }
}

Publish an existing draft

mutation {
  publish(id: "__POST_ID__") {
    id
    published
  }
}

Note: You need to replace the __POST_ID__-placeholder with an actual id from a Post item. You can find one e.g. using the filterPosts-query.

Search for posts with a specific title or content

{
  filterPosts(searchString: "graphql") {
    id
    title
    content
    published 
    author {
      id
      name
      email
    }
  }
}

Retrieve a single post

{
  post(id: "__POST_ID__") {
    id
    title
    content
    published
    author {
      id
      name
      email
    }
  }
}

Note: You need to replace the __POST_ID__-placeholder with an actual id from a Post item. You can find one e.g. using the filterPosts-query.

Delete a post

mutation {
  deletePost(id: "__POST_ID__") {
    id
  }
}

Note: You need to replace the __POST_ID__-placeholder with an actual id from a Post item. You can find one e.g. using the filterPosts-query.

6. Changing the GraphQL schema

After you made changes to schema.graphql, you need to update the generated types in ./src/generated/graphqlgen.ts and potentially also adjust the resolver implementations in ./src/resolvers:

yarn generate

This invokes graphqlgen and updates ./src/generated/graphqlgen.ts to incorporate the schema changes in your TS type definitions. It also generates scaffolded resolvers in ./src/generated/tmp/resolvers that you might need to copy and paste into ./src/resolvers.

Next steps

About

manage our badminton club

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published