IT |
ITmedia 総合記事一覧 |
[ITmedia News] ホンダ、独自の「ビークルOS」開発へ 25年投入目指し人材採用を倍増 |
https://www.itmedia.co.jp/news/articles/2304/26/news176.html
|
itmedia |
2023-04-26 18:39:00 |
IT |
ITmedia 総合記事一覧 |
[ITmedia Mobile] povo2.0で利用できる「300MB(3日間)」のプロモーションコード配布中 「SNS+動画データ使い放題(7日間)」の登場記念 |
https://www.itmedia.co.jp/mobile/articles/2304/26/news175.html
|
ITmediaMobilepovoで利用できる「MB日間」のプロモーションコード配布中「SNS動画データ使い放題日間」の登場記念povoにおいて期間限定のトッピング「SNS動画データ使い放題日間」が登場したことを受けて、povoの公式Twitterアカウントが「MB日間」の無料トッピングを配布している。 |
2023-04-26 18:30:00 |
IT |
ITmedia 総合記事一覧 |
[ITmedia News] Microsoftは1~3月期も増収減益 ナデラCEOは会見で「AI」を連発 |
https://www.itmedia.co.jp/news/articles/2304/26/news173.html
|
azure |
2023-04-26 18:04:00 |
TECH |
Techable(テッカブル) |
リコーら「メタバース空間制作サービス」の提供開始。空間設計などをワンパッケージ提案 |
https://techable.jp/archives/204059
|
提供開始 |
2023-04-26 09:00:45 |
IT |
情報システムリーダーのためのIT情報専門サイト IT Leaders |
サイバートラストとLiquid、「マイナンバーカード機能のスマホ搭載」に対応した本人確認サービス | IT Leaders |
https://it.impress.co.jp/articles/-/24777
|
サイバートラストとLiquid、「マイナンバーカード機能のスマホ搭載」に対応した本人確認サービスITLeadersサイバートラストとLiquidは年月日、マイナンバーカードを利用した公的個人認証サービスを、同年月日に始まる「マイナンバーカード機能のスマートフォン搭載」スマホJPKIに対応させたと発表した。 |
2023-04-26 18:55:00 |
AWS |
AWS Japan Blog |
AWS で Virtual Live Remote Production を実現するメディア向け Partner Acceleration イニシアチブのご紹介 |
https://aws.amazon.com/jp/blogs/news/jpmne-aws-introduces-virtual-live-remote-production-partner-acceleration-initiative-for-media/
|
mampe |
2023-04-26 09:28:27 |
js |
JavaScriptタグが付けられた新着投稿 - Qiita |
Angular tutorial 6. サーバからサーバの取得 メモ |
https://qiita.com/tomo1006/items/a92b800f4415411a34e1
|
angular |
2023-04-26 18:38:03 |
Ruby |
Rubyタグが付けられた新着投稿 - Qiita |
コレクションと配列をJavaとRubyとを比較して理解する |
https://qiita.com/Mizut452/items/38560c18d6174fb4a296
|
配列 |
2023-04-26 18:25:47 |
Docker |
dockerタグが付けられた新着投稿 - Qiita |
初心者がDockerでよく使うコマンド |
https://qiita.com/chro96/items/18523d8c5b3abe0a7188
|
docker |
2023-04-26 18:00:40 |
技術ブログ |
Developers.IO |
Notionに二段階認証が導入されたので既にAppleIDやGoogleアカウントで設定済みの場合含めて検証してみた #Notion |
https://dev.classmethod.jp/articles/check-notion-two-factor-authentication/
|
apple |
2023-04-26 09:09:55 |
海外TECH |
MakeUseOf |
Go Electric and Save With the Autel Home Smart EV Charger |
https://www.makeuseof.com/autel-home-smart-ev-charger/
|
charger |
2023-04-26 09:10:38 |
海外TECH |
DEV Community |
Building a More Robust Apache APISIX Ingress Controller With Litmus Chaos |
https://dev.to/apisix/building-a-more-robust-apache-apisix-ingress-controller-with-litmus-chaos-1m6f
|
Building a More Robust Apache APISIX Ingress Controller With Litmus Chaos OverviewChaos Engineering plays a crucial role in assessing and enhancing the resilience and reliability of software systems By simulating disruptive events organizations can identify vulnerabilities and improve the system s design and architecture In this article we will discuss the importance of Chaos Engineering and its specific application in designing Chaos experiments for Ingress Controllers Why We Need Chaos Engineering Chaos Engineering is the process of evaluating software systems by simulating destructive events such as server network outages or API throttling By introducing chaos or faults within the system we can test the system s resilience and reliability in unstable and unexpected conditions Chaos Engineering helps teams identify hidden risks monitor vulnerabilities and identify performance bottlenecks in distributed systems by simulating real world scenarios in a secure control environment This approach effectively prevents system downtime or production interruptions Netflix s approach to handling systems inspired us to adopt a more scientific approach which drove the birth and development of Chaos Engineering Introduction of Disruptive EventsChaos Engineering involves introducing disruptive events such as network partitions service degradation and resource constraints to simulate real world scenarios and test the system s ability to handle unexpected conditions The purpose is to identify vulnerabilities or weaknesses and improve the system s design and architecture to make it more robust and resilient Testing System ResilienceIn today s constantly evolving and fast paced technology landscape testing system resilience is crucial to ensure that systems are robust scalable and capable of handling unexpected challenges and conditions Chaos Engineering is an effective way to achieve this by introducing disruptive events to observe the system s response and measure its ability to handle unexpected conditions Organizations can monitor system logs performance metrics and user experience to measure the impact of disruptive events on system resilience Tracking these metrics provides a better understanding of the system s behavior allowing organizations to identify areas for improvement Discovering Hidden ProblemsDistributed systems are prone to hidden issues such as data loss performance bottlenecks and communication errors which can be challenging to detect as they may only become visible when the system is under pressure Chaos Engineering can help uncover these hidden issues by introducing disruptive events This information can then be used to improve the system s design and architecture making it more resilient and reliable Proactively identifying and resolving these problems enhances the reliability and performance of systems preventing downtime reducing the risk of data loss and ensuring the system runs smoothly What It s Worth and Why We Need It Distributed systems are complex and inherently chaotic which can lead to failure The use of cloud and microservices architecture provides many advantages but also comes with complexity and chaos Engineers are responsible for making the system as reliable as possible Without testing there is no confidence to use the project in the production environment In addition to conventional unit tests and end to end tests introducing chaos tests makes the system more robust When an error occurs repairing it takes time and can cause immeasurable losses with long term effects in the future During the repair process various factors need consideration including the system s complexity the type of error and possible new problems to ensure effective final repair Furthermore when an open source project brings serious faults to users in the production environment many users may switch to other products How to Design Chaos Experiments for an Ingress Controller What Is Ingress Ingress is a Kubernetes resource object that contains rules for how external clients can access services within the cluster These rules dictate which clients can access which services how client requests are routed to the appropriate services and how client requests are handled What Is an Ingress Controller An Ingress resource requires an Ingress Controller to process it The controller translates the Ingress rules into configurations on a proxy allowing external clients to access services within the cluster In a production environment Ingress Controllers need to have complex capabilities such as limiting access sources and request methods authentication and authorization Most Ingress Controllers extend the semantics of Ingress through annotations in the Ingress resource What Is Apache APISIX Ingress Controller Apache APISIX Ingress Controller is a specialized type of load balancer that helps administrators manage and control Ingress traffic It uses APISIX as a data plane to provide users with dynamic routing load balancing elastic scaling security policies and other features to improve network control and ensure higher availability and security for their business APISIX Ingress Controller supports three configuration modes Kubernetes Ingress custom resources and Gateway API What Is Litmus Chaos Litmus Chaos is an open source Chaos Engineering framework that provides an infrastructure experimental framework to validate the stability of controllers and microservices architectures It can simulate various environments such as container level and application level environments natural disasters faults and upgrades to understand how the system responds to these changes The framework can also explore the behavior changes between controllers and applications and how controllers respond to challenges in specific states Litmus Chaos offers convenient observability integration capabilities and is highly extensible How to Design Chaos Experiments Here is a general procedure for designing chaos experiments in any scenario Define the system under test Identify the specific components of the system you want to experiment on and develop clear and measurable objectives for the experiment This includes creating a comprehensive list of the components such as hardware and software that will be tested as well as defining the scope of the experiment and the expected outcomes kube apiserver if an exception occurs the Ingress resource write failed Ingress controller Network interruption Crash Podfaults I Odata plane Network interruption Crash Podfaults I OChoose the right experiment Select an experiment that is aligned with the objectives you have set and closely mimics a real world scenario This will help ensure that the experiment produces meaningful results and accurately reflects the behavior of the system Establish a hypothesis Establish a hypothesis about how the system will behave during the experiment and what outcomes you anticipate This should be based on experience or research and it should be reasonable and testable Run the experiment Run the experiment in a controlled environment such as a staging environment to limit the potential for harm to the production system Collect all relevant data during the experiment and store it securely There may be differing opinions on whether the experiment should take place directly in the production environment However for most scenarios we need to ensure the Service Level Objective SLO of the system is met Evaluate the results Evaluate the results of the experiment and compare them to your hypothesis Analyze the data collected and document any observations or findings This includes identifying any unexpected results or discrepancies and determining how they might affect the system Additionally consider how the results of the experiment can be used to improve the system Main Usage Scenarios of Ingress ControllerThe most important capability of an Ingress Controller is to proxy traffic and all other functions are based on this core function Therefore when conducting Chaos Engineering normal proxy traffic is the key metric To define the system under test for APISIX Ingress Controller users need to create route configurations such as Ingress Gateway API or CRD and apply them to the Kubernetes cluster via Kubectl This process goes through kube apiserver for authentication authorization admission and other related procedures and is then stored in etcd The APISIX Ingress Controller continuously watches for changes in Kubernetes resources These configurations are then converted to configurations on the data plane When a client requests the data plane it accesses the upstream service according to the routing rules If kube apiserver has an exception it will prevent the configuration from being created or the Ingress Controller from getting the correct configuration Similarly if there is an exception in the data plane such as a network interruption or Pod killed it will also not be able to do normal traffic proxy The scope of our experiment is mainly the impact on system availability if the Ingress Controller has an exception Detailed Operation StepsChoose the right experiment We can cover many scenarios of incorrect configuration through end to end tests Mainly through Chaos Engineering we can verify whether the data plane can still proxy traffic normally when the Ingress Controller encounters an exception such as DNS errors network interruptions or Pod killed Establish a hypothesis For each scenario we can create a hypothesis such as When the Ingress controller Pod gets X the client s request can still get a normal response Run the experiment The experiment and variables have been determined so all that s left is to experiment Litmus Chaos provides various ways to conduct experiments We can do this through the Litmus Portal To do this we need to create a Chaos scenario select the application to be experimented on and these steps are relatively straightforward However we must pay attention to the fact that Litmus Chaos includes a Probes resource Probes are pluggable checks that can be defined within the ChaosEngine for any Chaos Experiment The experiment pods execute these checks based on the mode they are defined in and factor their success as necessary conditions in determining the verdict of the experiment in addition to the standard in built checks At the same time we can also schedule experiments which is a very valuable function Additionally Litmus Chaos also supports running experiments by submitting YAML manifests Evaluate the results Litmus Chaos has built in statistical reports and it can be integrated with Prometheus and Grafana to provide a unified dashboard for integration Benefits and FutureThrough rigorous end to end testing and the power of Chaos Engineering we re confident in the stability and reliability of the delivered APISIX Ingress Controller Chaos Engineering has also helped us to identify and fix bugs We re constantly working to improve and evolve this amazing project and we invite you to join our community |
2023-04-26 09:44:51 |
海外TECH |
DEV Community |
Introduction Metaphore Stories |
https://dev.to/darkterminal/introduction-metaphore-stories-12el
|
Introduction Metaphore Stories What I builtPublic Collections of Metaphore our Freestyler accross the world Gain knowledge with unusual perspective from our Punk members Category Submission DIY Deployments Improve the deployment process for open source projects Guidance Build automation workflows for DevOps processes using Codespaces or Actions This could include automated testing custom deployment scripts or continuous integration continuous deployment CI CD pipelines App Link Screenshots DescriptionStory as Code Public Collections of Metaphore our Freestyler accross the world Gain knowledge with unusual perspective from our Punk members Every Punk can make any contributions to share your styles and unsual code snippet metaphor that belived it s something wrong different in traditional theory or usual business but it s work That our Punk Freestyle Engineer Welcome to the Street Community Programmer We know that programming is more than just code It s an art form and like all art it s open to interpretation That s why we ve created a space for metaphor stories in each programming language Each story is a unique interpretation of programming in a particular language and it s a great way to expand your thinking and learn new skills Whether you re a seasoned programmer or just starting our stories will inspire and challenge you to think outside the box Link to Source Code StreetCommunityProgrammer metaphore Story as Code Public Collections of Metaphore our Freestyler accross the world Gain knowledge with unusual perspective from our Punk members Metaphore Public Collections of Metaphore our Freestylers accross the world Gain knowledge with unusual perspective from our Punk members See it in action Every Punk can make any contributions to share your styles and unsual code snippet metaphor that belived it s something wrong different in traditional theory or usual business but it s work That our Punk Freestyle Engineer Welcome to the Street Community ProgrammerHow it s work We use GitHub issues templates to create a new metaphore Once the metaphore is accepted we use GitHub Action to generate a markdown file that contains the metaphore The website vercel build is triggered and updated automatically Your metaphore is now live online I have a story to list Create amp Share Your Metaphor Story Don t ask how to contribute just share what you want to share Let Me In NotesEvery… View on GitHub Permissive LicenseMIT LICENSE BackgroundAs a group of programmers who are all about breaking boundaries challenging conventional theories and creating code that s off the chain we noticed that there was a lack of platforms where programmers can share their unique styles and unconventional approaches to coding We wanted to create a community where members can freely express their creativity and share their knowledge with others Thus the Street Community Programmer was born Our goal is to provide a platform for programmers to showcase their unconventional methods and perspectives through code snippets and metaphors We believe that this will not only provide valuable insights for fellow programmers but also encourage creativity and innovation in the tech industry We are inspired by the idea that the best solutions often come from unconventional approaches We believe that every programmer has their own unique style and perspective and that by sharing these with others we can all learn and grow together With the Street Community Programmer we hope to create a space where the tech community can come together and push the boundaries of what is possible How We built itMetaphore is built using Next JS a React based web development framework and is hosted on Vercel a cloud platform for serverless deployment To automate the process of adding new metaphors we also used GitHub Actions a feature of GitHub that allows us to automate workflows directly from our GitHub repository To ensure consistency in the types of metaphors submitted and to make the submission process easier for users we also created a GitHub Issue template that guides users through the submission process This template includes fields for the story title back story full story demo link optional and donation link optional Once a user submits a metaphor through the GitHub Issue template our team reviews it before closing the issue Once the issue is closed our GitHub Action is triggered which automatically publishes the metaphor to the Metaphore website We also made use of GitHub s reaction feature which allows users to react to existing metaphors with emojis This helps surface the best metaphors for everyone to see Overall Metaphore was built with a focus on community driven development and easy submission processes making it accessible to anyone who wants to share their software metaphors Additional Resources InfoOG IMAGE REST Generator The Authors Imam Ali MustofaFollow Software Freestyle Engineer Coding while Dancing Cinnamon Cigarettes ️Metaphor Story KubdevFollow Hi I m Software Engineer from France Daily Learner Docendo Discimus |
2023-04-26 09:22:11 |
海外TECH |
DEV Community |
How to Build A GraphQL API with Node.js, Apollo-Server, and MongoDB Atlas |
https://dev.to/onlyoneerin/how-to-build-a-graphql-api-with-nodejs-apollo-server-and-mongodb-atlas-12fm
|
How to Build A GraphQL API with Node js Apollo Server and MongoDB Atlas IntroductionAre you a developer looking to create an efficient and flexible API Then look no further than GraphQL GraphQL is a modern way of creating APIs that allow the frontend to request only the data they need making it a more efficient alternative to REST APIs If you re a Node js developer looking to build a GraphQL API you re in the right place In this article you are going to create a food recipe GraphQL API with Node js Apollo Server and MongoDB Atlas With Apollo Server you ll get a production ready GraphQL implementation with many features MongoDB Atlas is a database service that makes it easy to scale your application But before diving into the details let s ensure we re all on the same page If you re new to GraphQL don t worry You can check out our previous article on the fundamentals of GraphQL It s an excellent introduction to the topic and a solid foundation for building your GraphQL API PrerequisitesBasic understanding of Node js syntax and JavaScriptFundamentals of GraphQL and its syntaxnpm installed on your computer You can get it here if you don t have npm installed on your computer Setting up a MongoDB Atlas clusterBefore building the API you need to set up your MongoDB Atlas cluster An Atlas cluster is a group of servers configured to store and manage data in MongoDB These clusters can be customized to meet specific performance scalability and security requirements It s a straightforward process and I am going to walk you through the steps MongoDB Atlas is a cloud based database service offered by MongoDB that provides a fully managed and scalable environment for our MongoDB databases Think of it as a group of computers working together to store and manage data ensuring it is always available and secure To get started Go to the MongoDB Atlas website on your browser by clicking here If you have an account you can log in or create one if you are not an existing user It is free Once signed in you are going to be redirected to your dashboard where all the different functionalities and integrations can be performed Click the “Build a Database button to start building the database You need to set up basic configurations for your database Select the M Free tier as it suits your needs Choose any cloud service provider options in the “Provider section For this article I recommend you select the AWS option For the region field select the region closest to where you are Choose a suitable name for the cluster It can be simple as you can t change the name once the cluster is created You can call your cluster “Food Recipe because you are building a food recipe API Once you have configured all primary fields in the template click the “Create button This button creates the Atlas cluster needed for this article It would be best if you also authenticated your connection MongoDB automatically generates a username and password for the first database user using the details provided during sign up To create other users with permission to read and write choose the “Username and Password option which lets you create a user with a username and a secure password Once you have inputted all the details click the “Create User button to save the user credentials You need to enable the network s access to read and write data to your cluster MongoDB automatically adds your current IP address but you can add more networks to access your cluster Select the “My Local Environment option to add an IP address to your network list Input the IP address and add a short description to identify the IP address Click the “Add Entry button to add the network Click the “Finish button to fully set up the “Food Recipe cluster You can now connect your database to your application and start writing your API Connecting your application to the MongoDB databaseTo connect your application to your MongoDB database You need to obtain the connection string for your cluster To obtain the connection string Login to your dashboard click the “Connect button for your cluster A list of different options to connect your application is available for you to choose from I recommend you choose the “Drivers method as this method lets you use Node js as your runtime environment Make sure you select the latest version of Node js You can then copy the connection string to use in your application Keep this copy in your notepad as it is needed in your index js file to connect your application to your MongoDB database Setting up a development environmentIn this section you are going to set up a development environment by creating a project installing necessary dependencies and connecting your MongoDB Atlas cluster to your application In your preferred code editor Open a new terminal and run the following command npm init yesThis command creates an empty package json The empty package json is essential for installing and managing the dependencies for the project Installing the dependencies In the terminal run the following command npm install apollo server graphql mongoose nodemonThe following command installs the four packages needed for this project The apollo server dependency lets you create a server that can handle GraphQL queries and mutations The graphql package provides the tools necessary to build and execute GraphQL queries and mutations the mongoose package offers a simple way to interact with MongoDB databases and the nodemon package automatically restarts your Node js application whenever you make changes to your code Inside your package json file you need to include a start command Whenever you run npm start in the terminal the start command runs the index js file which serves as a server scripts include the start command after the “test command start nodemon index js In your project folder create an index js file The code in the index js file sets up an Apollo Server that handles your GraphQL queries and mutations connect to a MongoDB database using mongoose and start listening for requests on a specified port In the index js file copy the following code This is getting the ApolloServer object out of the Apollo server libraryconst ApolloServer require apollo server This gives you access to Mongoose from the Mongoose package const mongoose require mongoose You need to create a variable to store the MongoDB string you got from your database Go to where you saved it and get the string Replace the username and password with your MongoDB Atlas username and password const MONGODB mongodb srv lt username gt lt password gt food recipe brtcty mongodb net retryWrites true amp w majority const typeDefs require graphql typeDefs const resolvers require graphql resolvers const server new ApolloServer typeDefs resolvers You want your apollo server to interact with Mongoose by passing in your MongoDB URImongoose connect MONGODB useNewUrlParser true then to show when the connection is made gt console log MongoDB Connected Successfully return server listen port to handle the response object and show where your server is running then res gt console log Server is running on port res url Let s take a closer look at the code line by line const ApolloServer require apollo server Here you re importing the ApolloServer object from the apollo server library The object lets you create an Apollo server that can handle GraphQL queries and mutations const mongoose require mongoose Next you re importing the mongoose library a MongoDB library It provides a simple way to interact with the MongoDB database const MONGODB mongodb srv feyijimierinle Backspace food recipe brtcty mongodb net retryWrites true amp w majority Here you defined a variable called MONGODB that stores the URI to your MongoDB database The URI is a long string that contains your username password and host information needed to connect to your database const typeDefs require graphql typeDefs const resolvers require graphql resolvers You re importing the type definitions and resolvers from separate files in a graphql folder Type definitions describe the structure and functionality of a GraphQL schema At the same time resolvers handle the logic for resolving GraphQL queries and mutations const server new ApolloServer typeDefs resolvers Here you created an instance of ApolloServer passing in your type definitions and resolvers as arguments The instance allows your server to handle GraphQL operations mongoose connect MONGODB useNewUrlParser true then gt console log MongoDB Connected Successfully return server listen port then res gt console log Server is running on port res url Finally you re connecting to your MongoDB database using the mongoose connect method passing in your MongoDB URI as the first argument Once the connection is established you re using the server listen to start your Apollo Server passing in an options object that specifies the port number you want to use in this case Finally you re logging a message to the console to confirm that the server is running and to indicate where it s listening for requests Go to http localhost on your browser to confirm if your server is running without errors Setting up the Mongoose ModelIn this section you need to set up your Mongoose model A Mongoose model is a template that helps you create and handle MongoDB documents in a Node js app It sets the data format including the fields and their types It allows the apollo server to interact with MongoDB database Make a new folder in the root directory of your project You can name it models Make a new file in the models folder called Recipe jsIn your recipe js file copy the following code Getting the model and Schema object from the Mongoose packageconst model Schema require mongoose Making a new Schema for the recipeconst recipeSchema new Schema Here you need to pass in all the properties expected in the recipeSchema name String description String dateCreated String originated String to export data from this file module exports model Recipe recipeSchema lt p gt amp nbsp lt p gt Let s take a closer look at the code line by line const model Schema require mongoose First you imported the model and Schema objects from the mongoose package model is a function that lets you define a new data model At the same time Schema is a class that lets you specify the structure and properties of the data model const recipeSchema new Schema name String description String dateCreated String originated String You created a new recipeSchema object an instance of the Schema class This recipeSchema object defines the structure of your recipe data model specifying the properties you expect to have in your data model Your recipeSchema object has four properties name description dateCreated and originated Each of these properties is a string data type module exports model Recipe recipeSchema Finally you are exporting the model function from this file which creates a data model You re passing two arguments to the model function Recipe and recipeSchema Recipe is the name of your data model which is used to identify and query this data model later recipeSchema is the data model structure that you created earlier Setting up GraphQL typeDefs and resolverstypeDefs is short for type definitions These blueprints describe the shape of the data that can be queried or mutated in a GraphQL API You can define types like Query and Mutation that represent the root types of your API and then determine the properties and fields that can be queried or mutated under each type Resolvers are functions that implement the behaviour of the queries and mutations defined in your typeDefs Resolvers tell GraphQL how to retrieve the data that s being requested and what to do with the data when it s retrieved In this section you need to define the typeDefs and resolvers necessary for the food recipe API Create a folder in the root directory of your project It would be best if you named it grahql This folder contains the typeDefs and the resolver files Create two files in the graphql folder and name them typeDefs js and resolvers js In the typeDefs js file copy the following code const gql require apollo server module exports gql type Recipe name String description String dateCreated String originated String input RecipeInput name String description String originated String type Query recipe ID ID Recipe getRecipes amount Int Recipe type Mutation createRecipe recipeInput RecipeInput Recipe deleteRecipe ID ID Boolean editRecipe ID ID recipeInput RecipeInput Boolean This code defines the schema for your API using the apollo server library The gql function is used to determine the schema using the GraphQL syntax The schema defines the types that can be queried and mutated and the fields that can be accessed on those types This particular schema defines three types Recipe RecipeInput Query and Mutation Recipe is a type that has fields for name description dateCreated and originated This type represents a recipe object in our API RecipeInput is an input type used for creating and editing recipe objects It has fields for name description and originated which are the properties that can be passed in from the client side A query is a type that defines the read operations in CRUD Create Read Update Delete operations The recipe field is used to retrieve a single recipe by its ID while the getRecipes field is used to retrieve an array of recipes A mutation is a type that defines the write operations in CRUD operations The createRecipe field is used to create a recipe object the deleteRecipe area is used to delete a recipe by its ID and the editRecipe field is used to update a recipe by its ID and create a recipe object This schema defines the types inputs queries and mutations used to build the GraphQL API In the resolver js file copy the following code This gives us access to the recipe model you created in the Recipe jsconst Recipe require models Recipe module exports Query This holds all our queries to the apollo server async recipe ID return await Recipe findById ID async getRecipes amount return await Recipe find sort dateCreated limit amount Mutation This holds all our mutation async createRecipe recipeInput name description originated This code is setting up the module const createdRecipe new Recipe name name description description dateCreated new Date toISOString originated originated const response await createdRecipe save This is saying save the cretedRecipe schema or module to our MongoDB need to return a recipe to our apollo server resolver return id response id response doc take all of the different properties of the result and show all the various properties that are going to show what our recipe is all about async deleteRecipe ID const wasDeleted await Recipe deleteOne id ID deletedCount use a mongoose function called deleteOne return wasDeleted the deletedCount returns if something was created and if nothing was created async editRecipe ID recipeInput name description const wasEdited await Recipe updateOne id ID name name description description modifiedCount returns an object similarly to the wasDeleted return wasEdited returns if an ID can t be found Let s go over the code line by line const Recipe require models Recipe This line imports the Recipe model you created in another file and stores it in the Recipe variable You can then use the Recipe variable to interact with the Recipe collection in your MongoDB database module exports Query async recipe ID return await Recipe findById ID async getRecipes amount return await Recipe find sort dateCreated limit amount The previous block of code exports an object with two properties Query and Mutation Query holds our queries to the apollo server which lets you read data There are two query resolvers defined here The recipe resolver takes an ID argument and returns a single Recipe object matching that ID The getRecipes resolver takes an amount argument and returns an array of Recipe objects sorted by date created up to the specified amount Mutation async createRecipe recipeInput name description originated const createdRecipe new Recipe name name description description dateCreated new Date toISOString originated originated const response await createdRecipe save return id response id response doc async deleteRecipe ID const wasDeleted await Recipe deleteOne id ID deletedCount return wasDeleted async editRecipe ID recipeInput name description const wasEdited await Recipe updateOne id ID name name description description modifiedCount return wasEdited The previous block of code exports an object with a Mutation property Mutation holds all your mutations on the apollo server which lets you write data There are three mutation resolvers defined here The createRecipe resolver takes an object with name description and originated properties creates a Recipe object using the Recipe model saves it to your database and returns the newly created Recipe object The deleteRecipe resolver takes an ID argument finds the Recipe object with that ID in the database and deletes it It then returns the number of objects deleted which is if the delete operation was successful and if it was not The editRecipe resolver takes an ID argument and an object with name and description properties finds the Recipe object with that ID in the database updates its name and description properties and returns the number of objects modified which is if the update operations was successful and if it was not You have successfully created a Food Recipe GraphQL API You can now go ahead and test your API in the GraphQL playground Testing the Food Recipe API in the GraphQL PlaygroundIn this section you are going to test the Food Recipe API in the GraphQL Playground which is a graphical interface for testing and interacting with GraphQL APIs In your terminal run the command npm start This command starts a GraphQL playground on localhost as specified in the index js file The playground lets you create read update and delete a food recipe directly from the playground all in one call The Docs tab is located at the left hand pane Click on it to view the documentation for the Food Recipe API This docs tab gives an overview of the queries mutations and types that are available in the API To test a query enter the following code in the right hand pane Query Recipe id ID recipes ID id name description dateCreated This query retrieves all recipes from the database and return their names descriptions and dateCreated Click the Run button at the top of the right hand pane to execute the query The results is displayed in the bottom pane and you would see a list of recipes along with their names descriptions and dateCreated To test a mutation enter the following code in the right hand pane mutation CreateRecipe recipeInput RecipeInput createRecipe recipeInput recipeInput name description createdAt This mutation adds a new recipe to the database with the specified name description and createdAt Click the Run button to execute the mutation The results is displayed in the bottom pane and you would see the details of the newly added recipe To test a query with parameters enter the following code in the right hand pane Query GetRecipes amount Int getRecipeByNumber amount amount name description This query retrieves a recipe from the database with the specified amount and return its name and description Note that you have defined a variable called amount in the query that you need to pass in the value for the amount parameter In the bottom pane click on the Query Variables tab and enter the following JSON object amount This object defines the value for the amount variable that you defined in the query Click the Run button to execute the query The results is displayed in the bottom pane and you would see the details of the first five recipes in your database That s it You have successfully tested the Food Recipe API in the GraphQL Playground You can use this tool to further explore the API and test different queries and mutations ConclusionIn conclusion this tutorial has provided a comprehensive guide on building a GraphQL API with Node js Apollo Server and MongoDB Atlas By using these technologies you can create APIs that are flexible efficient and easy to maintain One of the benefits of GraphQL is that it allows clients to request only the data they need which can lead to faster and more efficient data fetching And by leveraging the features of Apollo Server you can build a robust secure and scalable API with various integrations and features With the knowledge gained from this tutorial you can begin exploring the possibilities of GraphQL and API development and use these technologies to create innovative and exciting projects With the right approach you can create powerful and efficient APIs that meet the needs of modern applications and users |
2023-04-26 09:17:12 |
海外TECH |
Engadget |
Tile's latest accessory helps track your cat |
https://www.engadget.com/tiles-latest-accessory-helps-track-your-cat-095531840.html?src=rss
|
Tile x s latest accessory helps track your catTile best known for its AirTag like trackers that help you locate lost objects can now find something that can get lost on purpose ーyour cat The Tile for Cats tracker from Life is a modified version of the Tile Sticker with a silicon collar attachment and foot Bluetooth range The idea is to give you peace of mind that your cat is somewhere in the house and then help you figure out exactly where that sneaky floof is hiding nbsp The battery on the Tile for Cats lasts a generous three years and you can easily replace the sticker It even offers AI assistant integration with Siri Alexa and Google Assistant so you can locate Sir Fluffybutt with a voice command nbsp For the price tag you get a Tile sticker and attachment that s compatible with most cat collars including breakaway collars The attachment can stretch up to times without breaking and is water resistant so it ll continue to function even if hit with a few drops nbsp Tile for Cats is Life s first pet tracker though the company was already marketing its regular Tile Trackers for the same purpose It s designed for indoor use only though due to the limited range If you re worried about your pet getting lost outside you d be better off with a dedicated pet tracker typically costing around plus a subscription fee nbsp This article originally appeared on Engadget at |
2023-04-26 09:55:31 |
海外TECH |
Engadget |
Beats Studio Buds+ leak on Amazon with a May 18th release date |
https://www.engadget.com/beats-studio-buds-leak-on-amazon-with-a-may-18th-release-date-091639570.html?src=rss
|
Beats Studio Buds leak on Amazon with a May th release dateBeats might release its next gen Studio Buds model on May th MacRumors spotted an Amazon listing that showed images and details for Apple s Beats Studio Buds ーthe page even allowed customers to pre order the earbuds until it was yanked offline The earbuds which were listed for or more than the current model will have a transparent option that puts their internal components on display similar to Nothing s design That said they will also be available in black and ivory for those who aren t quite as intrigued or enamored by transparent electronics nbsp According to the listing the Studio Buds can run up to hours instead of just when combined with the charging case like the current model Speaking of the charging case it seems to retain its predecessor s shape except it s most likely lighter The upcoming product s item weight is ounces while the current Studio Buds is listed as ounces The Studio Buds microphones are three times larger than the current model s and they also have a more powerful processor Those components enable more active noise cancelling power and a transparency mode ーthat is the mode that lets some ambient noise in so the user remains aware of their surroundings ーthat s apparently twice as effective nbsp The upcoming earbuds also support spatial audio for immersive sounds quot always on quot Siri and compatibility with Apple s quot Find My quot tracking app Plus they feature one touch pairing with both Apple and Android devices as well as automatic switching that makes it easy to use them with multiple phones and tablets Considering the Amazon page for the Studio Buds seems to have the complete details about the model we ll likely see it go back up in the coming weeks when Apple is ready to take pre orders nbsp This article originally appeared on Engadget at |
2023-04-26 09:16:39 |
海外科学 |
NYT > Science |
Beatrix Potter Is More Than the Creator of Peter Rabbit |
https://www.nytimes.com/2023/04/26/arts/design/beatrix-potter-peter-rabbit-science.html
|
Beatrix Potter Is More Than the Creator of Peter RabbitAn exhibition in Nashville of Beatrix Potter s works explores her love of the world of science and the challenges facing women of the Victorian era |
2023-04-26 09:00:45 |
海外ニュース |
Japan Times latest articles |
New generation could rekindle ozeki rank’s missing spark |
https://www.japantimes.co.jp/sports/2023/04/26/sumo/ozeki-charisma/
|
New generation could rekindle ozeki rank s missing sparkWith a history of engaging and charismatic wrestlers sumo s second highest rank often draws a greater response from fans than the stoicism demanded from yokozuna |
2023-04-26 18:15:59 |
海外ニュース |
Japan Times latest articles |
Has India’s time come or is this just another siren song? |
https://www.japantimes.co.jp/opinion/2023/04/26/commentary/world-commentary/india-population/
|
bulls |
2023-04-26 18:33:30 |
ニュース |
BBC News - Home |
Government hits 20,000 new police officers pledge |
https://www.bbc.co.uk/news/65377091?at_medium=RSS&at_campaign=KARANGA
|
officers |
2023-04-26 09:08:40 |
ニュース |
BBC News - Home |
Not proven verdict to be scrapped in Scottish courts |
https://www.bbc.co.uk/news/uk-scotland-65397235?at_medium=RSS&at_campaign=KARANGA
|
courtsthe |
2023-04-26 09:57:35 |
ニュース |
BBC News - Home |
Amazon UK workers on brink of winning union victory |
https://www.bbc.co.uk/news/business-65340522?at_medium=RSS&at_campaign=KARANGA
|
amazon |
2023-04-26 09:33:37 |
ニュース |
BBC News - Home |
Lucy Bronze: England and Barcelona defender has keyhole knee surgery |
https://www.bbc.co.uk/sport/football/65396264?at_medium=RSS&at_campaign=KARANGA
|
surgery |
2023-04-26 09:45:33 |
ニュース |
BBC News - Home |
Sudan: Third evacuation flight of Britons lands in Cyprus |
https://www.bbc.co.uk/news/uk-65395361?at_medium=RSS&at_campaign=KARANGA
|
separate |
2023-04-26 09:05:47 |
サブカルネタ |
ラーブロ |
中華そば ごんべえ@羽村市<らーめん> |
http://ra-blog.net/modules/rssc/single_feed.php?fid=209806
|
中華そば |
2023-04-26 10:00:46 |
IT |
週刊アスキー |
『白猫GOLF』がおかげさまのハーフアニバーサリー!5大キャンペーンを開催中 |
https://weekly.ascii.jp/elem/000/004/134/4134740/
|
開催中 |
2023-04-26 18:35:00 |
IT |
週刊アスキー |
『エラーゲームリセット』初日で“40.4”万ダウンロードを達成! |
https://weekly.ascii.jp/elem/000/004/134/4134735/
|
gamereset |
2023-04-26 18:05:00 |
IT |
週刊アスキー |
無印良品の家、ウェブ上で手軽に家づくりを体験できる「かんたん見積」サービス |
https://weekly.ascii.jp/elem/000/004/134/4134730/
|
家づくり |
2023-04-26 18:30:00 |
IT |
週刊アスキー |
Dropbox、動画プロジェクトを効率化する「Dropbox Replay」提供開始 |
https://weekly.ascii.jp/elem/000/004/134/4134663/
|
dropbox |
2023-04-26 18:40:00 |
IT |
週刊アスキー |
ナカバヤシ、USBハブとSD/microSDカードリーダー・ライターを備えるヘッドホンフックを発表 |
https://weekly.ascii.jp/elem/000/004/134/4134720/
|
microsd |
2023-04-26 18:30:00 |
コメント
コメントを投稿