GithubHelp home page GithubHelp logo

graphql-courses's Introduction

Requetes pour initialiser la base de données

INSERT INTO address VALUES (1,'Happy Street','Delhi'),(2,'2nd Street','Mumbai'),(3,'3rd Street','Delhi'),(4,'any street','Mumbai');
INSERT INTO student (id, first_name, last_name, email, address_id) VALUES (1,'John','Smith','[email protected]',1),(2,'Virat','Dave','[email protected]',2),(3,'Steve','Martin','[email protected]',3),(4,'Sachin','Kumar','[email protected]',4);
INSERT INTO subject (id, subject_name, marks_obtained, student_id) VALUES (1, 'Java', 80, 1), (2, 'MySQL', 70, 1), (3, 'Java', 80, 2), (4, 'MySQL', 70, 2), (5, 'MongoDB', 70, 2), (6, 'MySQL', 70, 3), (7, 'MongoDB', 70, 3), (8, 'Java', 60, 4), (9, 'MongoDB', 50, 4);

Requêtes avec filtre

query {
  student(id: 3) {
    email
    firstName
    lastName
    learningSubjects(subjectNameFilter: MongoDB) {
      id
      subjectName
    }
    fullName
  }
}

Requête de modification

mutation {
  createStudent(createStudentRequest: {
    firstName: "Alex"
    lastName: "Omar"
    email: "[email protected]"
    street: "any street"
    city: "canada"
    subjectsLearning: [
      {
        subjectName: "Java"
        marksObtained: 60.00
      },
      {
        subjectName: "MongoDB"
        marksObtained: 50.00
      }
    ]
  }) {
    id
    firstName
    lastName
    email
    street
    city
    learningSubjects(subjectNameFilter: All) {
      id
      subjectName
      marksObtained
    }
    fullName
  } 
}

Requête query avec une variable graphQL

query student($id: Int, $subName: SubjectNameFilter) {
    student(id: $id) {
        email
        firstName
        lastName
        learningSubjects(subjectNameFilter: $subName) {
            id
            subjectName
        }
        fullName
    }
}

Variable

{
    "id": 1,
    "subName": "All"
}

Requête mutation avec une variable graphQL

mutation createStudent($createStudentRequest: CreateStudentRequest) {
    createStudent(createStudentRequest: $createStudentRequest) {
        id
        firstName
        lastName
        email
        street
        city
        learningSubjects(subjectNameFilter: All) {
            id
            subjectName
            marksObtained
        }
        fullName
    }
}

Variable

{
  "createStudentRequest": {
    "firstName": "Alex",
    "lastName": "Omar",
    "email": "[email protected]",
    "street": "any street",
    "city": "canada",
    "subjectsLearning": [
      {
        "subjectName": "Java",
        "marksObtained": 60.00
      },
      {
        "subjectName": "MongoDB",
        "marksObtained": 50.00
      }
    ]
  }
}

graphql-courses's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.