#js nested object filter
Explore tagged Tumblr posts
Text
iç içe obje içerisinden key değerine göre filtre yapmak js
let a = { "employments": { "38": { "type": "EMPLOYMENT", "id": 38, "name": "deneme", "type": "deneme", "employer": 12, } } }
yukarıdaki employer yani 12 değerine ulaşmak istiyorum
Object.values(a.employments).map(value => value.employer) //burasi [12] şeklinde sonuc veriyor
Object.values(a.employments).map(value => value.employer)[0] // 12 şeklinde ulaşıyorum
1 note
·
View note
Text
Download mongodb 4.0

Download mongodb 4.0 how to#
Download mongodb 4.0 for mac os x#
Download mongodb 4.0 code#
The cursor.not(operator-expression) method performs a logical NOT operation on the specified “operator-expression” and selects the documents that do not match the “operator-expression”. MongoBooser integrates node-fetch to bring window.fetch to MongoDB Script.Ĭonsole.log( await( await(fetch( '')).text())) Ĭonsole.log( await( await(fetch( '')).json())) Minor Enhancement More Useful MongoDB Shell Extensions Global fetch() method
Download mongodb 4.0 how to#
Out of the box, Ctrl-Space, Alt-Space are acceptable triggers.Ĭlick here to learn how to use Node.js Modules in Your Script You can always manually trigger it with Ctrl-Shift-Space. The IntelliSense suggestions will pop up as you type and automatically complete Javascript method names, variables, etc. Within this release, MongoBooster also offers Intellisense experience for Node.js required packages. Intellisense for Node.js Required Packages The above example can be written with the MongoBooster await function. Note this await function is different from es7 await, this await function may be used in functions without the async keyword marked. It can await a promise or a promise array. Within this release, we have also added support for ES7 Async/Await in MongoBooster shell.Īs a comparison, MongoBooster has a build-in function await which is a common js method, not a keyword. See the features and SQL examples supported by the MongoBooster. Autocomplete for keywords, MongoDB collection names, field names and SQL functions.Provide a programming interface (mb.runSQLQuery) that can be integrated into your script.Aggregation Pipeline Operators as SQL Functions (dateToString, toUpper, split, substr…).SQL Functions (COUNT, SUM, MAX, MIN, AVG).Access data via SQL including WHERE filters, ORDER BY, GROUP BY, HAVING, DISTINCT, LIMIT.The Equivalent MongoDB Query can be viewed in console.log tab.Ĭlick here to learn how to run SQL SELECT Query against MongoDB SQL Query Features The SQL query is validated and translated into a MongoDB query and executed by MongoBooster. SQL features are not natively supported by MongoDB.If you want the results not to be edited directly, you can enable the “read-only” mode by clicking the lock button in the toolbar.Pressing shortcut “Esc” will return the previous value and exit the editor. Double-click on any value or array element to edit. MongoBooster supports in-place editing in result tree view.You can always manually trigger the auto-complete feature with Ctrl-Shift-Space. The IntelliSense suggestions will pop up as you type. The build-in SQL language service knows all possible completions, SQL functions, keywords, MongoDB collection names and field names.Just Click on the “console.log/print” tab to show the equivalent MongoDB query: Just type a snippet prefix “run”, and enter “tab” to insert this snippet, then press “Command-Enter” to execute it and get the result.
Download mongodb 4.0 code#
MongoBooster also offers a “runSQLQuery” code snippets. Open a shell tab, enter the above script. SELECT department, SUM(salary) AS total FROM employees GROUP BY department You can query MongoDB by using old SQL which you probably already know 1 Instead of writing the MongoDB query which is represented as a JSON-like structure 1 Let’s look at how to use the GROUP BY clause with the SUM function in SQL. SQL support includes functions, expressions, aggregation for collections with nested objects and arrays. With MongoBooster V4, you can run SQL SELECT Query against MongoDB.
Download mongodb 4.0 for mac os x#
This major upgrade includes Query MongoDB with SQL, ES7 Async/Await support and more.Īlthough we are showing screenshots of MongoBooster for Windows, all these new features are available for Mac OS X and Linux as well. Today, we are extremely pleased to announce the release of MongoBooster 4.0.

0 notes
Link
A nice list of HTML, CSS and JavaScript How Tos with basic concepts for everyday use. Feel free to comment your own approaches :)
Disabling everything with CSS
CSS
.disabled { filter: grayscale(1); pointer-events: none; }
View on JSFiddle here.
Split an array into chunks without mutability
JS
const array = [1, 2, 3, 4] const size = 3 const new_array = array.reduce((acc, a, i) => { i % size ? acc[parseInt(i / size)].push(a) : acc.push([a]) return acc }, [])
or even shorter:
const new_array = array.reduce((acc, a, i) => i % size ? acc : [...acc, array.slice(i, i + size)], [])
Remember, start using const, if you need to change its value then use let and avoid as much as possible var. View on JSFiddle here.
Saving and loading dates
Save your datetime always in UTC ISO and load it to the user interface using local ISO. Use native widgets to avoid facing date format preferences (middle endian, little endian, etc) HTML
<input type="datetime-local"> <button>Save</button> <button>Load</button>
JS
$button_save.onclick = () => localStorage.setItem('datetime', $input.value && new Date($input.value).toISOString()) $button_load.onclick = () => $input.value = localStorage.getItem('datetime') && toLocalISOString(new Date(localStorage.getItem('datetime'))) .slice(0, -8) function toLocalISOString(d) { const offset = d.getTimezoneOffset() return new Date( d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes() - offset, d.getSeconds(), d.getMilliseconds()).toISOString() }
View on JSFiddle here. I recommend using sessionStorage and localStorage. Do not abuse cookies if they are not strictly necessary. If you need more local storage you can use IndexedDB.
Select HTML table columns by clicking on the headers
JS
document.querySelectorAll('th').forEach($th => $th.onclick = event => { document.querySelectorAll(`td:nth-of-type(${event.currentTarget .cellIndex + 1})`) .forEach($td => $td.classList.toggle('selected')) })
Remember, onclick always overwrites the previous function (in case there was any), use addEventListener() for multiple functions. View on JSFiddle here.
Rename when destructuring
We are going to rename time property while sorting our array of objects. JS
let times = [ {name:'dog', time: '10:23'}, {name: 'laundry', time: '09:34'}, {name: 'work', time: '11:00'}] times.sort(({ time: a }, { time: b }) => a < b ? -1 : a > b ? 1 : 0)
Remember, sort() changes the orginal array. View on JSFiddle here.
Autocomplete dropdown
Have you ever used autocomplete dropdowns from jQuery UI or Bootstrap third party options? A complete heavyweight mess. Luckly, we got a couple of years ago an awaited solution: Native HTML5 Autocomplete dropdown with datalist. A lightweight standard supported in all devices. HTML
<input list="series"> <datalist id="series"> <option value="Adventure Time"> <option value="Rick and Morty"> <option value="Game of Thrones"> <option value="Planet Earth 2"> </datalist>
View on JSFiddle here. Save your tooling time and dependency, use as few libraries and frameworks as possible!
Real easy responsiveness with CSS Grid
CSS Grid is the easiest, cleanest and powerful way to deal with responsiveness, a completely new approach baked in the last years and ready to use. CSS Grid changes how you used to layout your documents, instead of divitis (plenty of divs) and JavaScript to change div positions depending on screens (what Bootstrap does nowadays), you can use pure CSS grid layouts with just the meaningful divs and independently of document source order. You don’t need to touch HTML or JavaScript, you don’t need Bootstrap or even complex CSS rules, what you see in your CSS is what you get on your screen. HTML
<div class="grid"> <div class="name">Name</div> <div class="score">Score</div> <div class="skills">Skills</div> <div class="chart">Chart</div> </div>
CSS
.grid { display: grid; grid-template-areas: "name" "score" "skills" "chart"; } @media only screen and (min-width: 500px) { .grid { grid-template-areas: "name skills" "score skills" "chart chart"; } } .name { grid-area: name; } .score { grid-area: score; } .skills { grid-area: skills; } .chart { grid-area: chart; }
View on JSFiddle here. I would recommend you to do these examples. Fall in love with Grid Templates like I did ❤
Move parts of the user interface without loss of interaction
HTML
<ul> <li> <button id="up">Up</button> <button id="down">Down</button> </li> <li>Nothing</li> <li>Nothing</li> </ul>
JS
document.querySelector('#up').onclick = e => { const $li = e.target.parentElement if ($li.previousElementSibling) $li.parentElement.insertBefore($li, $li.previousElementSibling) } document.querySelector('#down').onclick = e => { const $li = e.target.parentElement if ($li.nextElementSibling) $li.parentElement.insertBefore($li.nextElementSibling, $li) }
Remember, target is what triggers the event and currentTarget is what you assigned your listener to. View on JSFiddle here.
HTML input time with 24 hours format
Rely on native HTML widgets without depending on third party libraries. However, sometimes there are some limitations, if you have ever dealt with an HTML input time you know what it is about, try to set up maximum or minimum hours/minutes and/or change from 12 hours format to 24 hours and viceversa. By now, a good solution to avoid headaches is to use 2 inputs of the type number and a pinch of JS. HTML
<div> <input type="number" min="0" max="23" placeholder="23">: <input type="number" min="0" max="59" placeholder="00"> </div>
CSS
div { background-color: white; display: inline-flex; border: 1px solid #ccc; color: #555; } input { border: none; color: #555; text-align: center; width: 60px; }
JS
document.querySelectorAll('input[type=number]') .forEach(e => e.oninput = () => { if (e.value.length >= 2) e.value = e.value.slice(0, 2) if (e.value.length == 1) e.value = '0' + e.value if (!e.value) e.value = '00' })
Remember, == double comparation for equality and === triple one for equality and type. If you want to check whether a variable is undefined or not, simple use triple compartion a === undefined and the same for null. If you want to check whether it exists or not use typeof a != 'undefined'. View on JSFiddle here.
Loop n times without mutable variables
JS
[...Array(10).keys()] .reduce((sum, e) => sum + `<li>${e}</li>`, '')
also like this:
[...Array(10)] .reduce((sum, _, i) => sum + `<li>${i}</li>`, '')
View on JSFiddle here.
Horizontal and vertical center
Forget about any complicated way, just use Flexbox and set up horizontal center and vertical center in the container. CSS
body { position: absolute; top: 0; right: 0; bottom: 0; left: 0; display: flex; justify-content: center; align-items: center; } div { background-color: #555; width: 100px; height: 100px; }
View on JSFiddle here.
Asynchronous fetch
Using fetch() with asyncronous functions. JS
async function async_fetch(url) { let response = await fetch(url) return await response.json() } async_fetch(‘https://httpbin.org/ip') .then(data => console.log(data)) .catch(error => console.log('Fetch error: ' + error))
View on JSFiddle here. Note, as you have noticed I don’t write the ; semicolon, that’s perfectly fine, in JavaScript the ; is not mandatory, it doesn’t matter if you write it or not, the JS engine is going to check it and insert it if needed, just be careful with new lines that start with ( parentesis and avoid return with the value in a diferent line.
Footer with right and left buttons
HTML
<footer> <div> <button>Button A</button> <button>Button B</Button> </div> <div> <button>Button C</button> <button>Button D</button> </div> </footer>
CSS
footer { display: flex; justify-content: space-between; position: fixed; bottom: 0; left: 0; right: 0; }
View on JSFiddle here.
Scroll into view
I have created n boxes (divs) with random colors to select one of them randomly and make it visible on the viewport. Every time you rerun the code you will see in your screen the selected box regardless of its position. JS
document.querySelector(`div:nth-child(${random})`).scrollIntoView()
View on JSFiddle here.
Flattening arrays of objects
JS
array = alphas.map(a => a.gammas.map(g => g.betas) ).join()
If you want to see other different approaches using forEach with concat and with push check this link (I did also some time consuming test using jsPerf). View on JSFiddle here. Remember, in case you want to flat arrays of arrays you can do it easily with flat().
[1, 2, [3, 4, [5, 6]]].flat(Infinity)
Nesting arrays of objects
Returns an array of n elements filled with content: JS
let get_array = (n, content) => Array(n).fill(content)
Returns an object with a name property that has a content value:
let get_object = (name, content) => Object.defineProperty({}, name, {value: content})
3 levels of arrays with objects (nested)
a = get_array(3, get_object('b', get_array(6, get_object('c', get_array(3, {}) )) ))
View on JSFiddle here.
Array without duplicate values
JS
const array = [1, 2, 3, 3, 3, 2, 1]
The Set strategy:
[...new Set(array)]
The filter strategy (easier to figure out but slower):
array.filter((elem, index) => index == array.indexOf(elem))
View on JSFiddle here. Remember, Array.from(iterableObj) = [...iterableObj]
HTML input with units
HTML
<span><input type="number" min="0" value="50">€</span>
CSS
span { background: white; border: 1px solid #e8e8e8; } input { background: inherit; outline: none; border: none; padding: 0 5px; }
View on JSFiddle here.
Responsive background loop video
HTML
<video autoplay loop poster="https://website/video.jpg"> <source src="http://website/video.webm"> </video>
CSS
video.landscape { width: 100vw; height: auto; } video { width: auto; height: 100vh; }
Remember, you can add as many sources as you want to support different video formats. View on JSFiddle here.
How to print specific HTML content
If you want to print a specific HTML content, for example everything inside a div tag or a tag element with a particular identifier, you can use window.print() in a new window with just the content you want to. It’s easy but tricky, we would like an accessible print method for any HTML element but there aren’t. Don’t forget to add/link some CSS in your new window otherwise you will get the default style from your browser. JS, HTML, CSS
function print(content) { let win = window.open() win.document.write(` <html><head> <title>Report</title> <style> div { display: inline-flex; width: 200px; height: 200px; justify-content: center; align-items: center; background-color: #e9a9c7; color: #39464e; } </style> </head><body>` ) win.document.write(content) win.document.write('</body></html>') win.print() win.close() }
View on JSFiddle here. Note, the write method is synchronous, however sometimes window tries to print before write has finished, it happens only in some browsers ¬¬, therefore trying to avoid this we have added a setTimeout(). Yeah, no quite elegant but among all the different ways, it is the shortest that works across all updated browsers so far.
View, hide, type and generate password
Love to make things as simple as possible xD A hint just inside the input, then a button to show the password and finally another button to generate random passwords. HTML
<input id="password" type="password" placeholder="type password..."> <button id="view-password"></button> <button id="generate-password">↻</button>
View or hide password: JS
$view_password.addEventListener('click', e => { e.currentTarget.classList.toggle('view') if (e.currentTarget.className.includes('view')) $password.setAttribute('type', 'text') else $password.setAttribute('type', 'password') })
Set a random password and make sure it’s shown:
$generate_password.addEventListener('click', () => { $view_password.classList.add('view') $password.setAttribute('type', 'text') $password.value = Math.random().toString(36).slice(-8) })
View on JSFiddle here. Note, I personally name selector’s const starting with a $.
Infinite previous and next selection
Select each element in a selection loop. If you go forward as soon as you finish the list of elements you will start selecting from the beginning and the same if you go in opposite direction. HTML
<button id="previous">Previous</button> <button id="next">Next</button> <ul> <li></li> <li class="selected"></li> <li></li> <li></li> <li></li> </ul>
JS
document.querySelector('#next').addEventListener('click', () => { const $selected = document.querySelector('.selected') const $next_element = $selected.nextElementSibling if (!$next_element) $next_element = $selected.parentElement.firstElementChild $selected.classList.remove('selected') $next_element.classList.add('selected') })
Remember, use nextElementSibling and previousElementSibling (DOM elements) instead of nextSibling and previousSibling (DOM objects). A DOM Object can be anything: comments, insolated text, line breaks, etc. In our example nextSibling would have worked if we had set all our HTML elements together without anything between then:
<ul><li></li><li></li></ul>
View on JSFiddle here.
Responsive square
I have seen many weird ways to create responsive squares, that’s why I would like to share an easy one. Go to the JSFiddle link below and play resizing the result window. CSS
div { width: 60vw; height: 60vw; margin: 20vh auto; background-color: #774C60; }
View on JSFiddle here.
Circle area defined by mouse click
We are going to define the area of a circle depending on where we click within a box area. We can handle this using JavaScript events, a little bit of basic maths and CSS. Width and height are igual, it doesn’t matter which we will set for our maths: JS
const width = e.currentTarget.clientWidth
Absolute position of the mouse cursor from the circle center:
const x = Math.abs(e.clientX — offset.left — width / 2) const y = Math.abs(e.clientY — offset.top — width / 2)
The maximum will tell us the percent of the circle area:
percent = Math.round(2 * Math.max(x, y) * 100 / width) $circle.style.width = percent + '%' $circle.style.height = percent + '%'
Text Overwriting
Well, maybe you are thinking that you can just turn on your Insert key from your keyboard but what If you don’t have it or if you want to always have an overwriting mode (independently) while typing in some specific inputs and textareas. You can do it easily. JS
$input.addEventListener('keypress', function(e) { const cursor_pos = e.currentTarget.selectionStart if (!e.charCode) return $input.value = $input.value.slice(0, cursor_pos) + $input.value.slice(cursor_pos + 1) e.currentTarget.selectionStart = e.currentTarget.selectionEnd = cursor_pos })
View on JSFiddle here.
Counter with a reset using closures
Set up a basic counter with a closure and some external accessible options. JS
const add = (function() { let offset = 0 return function(option) { switch (option) { case 0: offset = 0; break; case 1: offset++; break; case 2: offset — ; break; default: throw ‘Not a valid option’; } console.log(offset) } })()
Remembler, a closure just let you keep recorded and protected your variables. View on JSFiddle here.
Infinite scroll
Have you ever seen those automatic "Load More" while you scroll down? Did you see them on Tumblr for images, Gmail for messages or Facebook? Cool, isn’t it? The infinite scroll is an alternative for pagination and it’s everywhere. It optimizes the user experience loading data as the user required it (indirectly). You get faster loading process for pages, web, apps and it just loads what you need instead of the whole bunch. You don’t need to add extra interactions, buttons or widgets because it comes with the normal reading behaviour that you are used to: scroll down with the mouse or with the finger in a touchable screen. JS
const $ol = document.querySelector('ol') function load_more() { let html = '' for (var i = 0; i < 5; i++) html += '<li></li>' $ol.innerHTML += html } $ol.addEventListener('scroll', function() { if ($ol.scrollHeight — $ol.scrollTop == $ol.clientHeight) load_more() })
View on JSFiddle here. Just notice in the example above that we could make it more efficient creating nodes and using appendChild().
Material icons
HTML
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> <i class="material-icons">face</i>
View on JSFiddle here.
Basic CSS transition using box-shadow
Our CSS will change if the mouse is over the element with an ease-in-out transition effect (slow start and end). We are filling up the element with an inner shadow (inset) CSS
i { transition: all 0.5s ease-in-out; box-shadow: 0 0 0 75px #E94F37 inset; } i:hover { box-shadow: 0 0 0 4px #E94F37 inset; color:#E94F37; }
View on JSFiddle here.
Export HTML table to CSV file
Imagine you have an HTML table and you want to download it as a CSV table. HTML
<table> <tr><th>Name</th><th>Age</th><th>Country</th></tr> <tr><td>Geronimo</td><td>26</td><td>France</td></tr> <tr><td>Natalia</td><td>19</td><td>Spain</td></tr> <tr><td>Silvia</td><td>32</td><td>Russia</td></tr> </table>
First of all, you need to transform from HTML to CSV: JS
let csv = [] let rows = document.querySelectorAll('table tr') for (var i = 0; i < rows.length; i++) { let row = [], cols = rows[i].querySelectorAll('td, th') for (var j = 0; j < cols.length; j++) row.push(cols[j].innerText) csv.push(row.join(',')) } download_csv(csv.join('\n'), filename)
After that, you can download it using Blob and a link:
let csvFile = new Blob([csv], {type: 'text/csv'}) let downloadLink = document.createElement('a') downloadLink.download = filename downloadLink.href = window.URL.createObjectURL(csvFile) downloadLink.style.display = 'none' document.body.appendChild(downloadLink) downloadLink.click()
View on JSFiddle here.
Keyboard events
Use event.code to get a human readable way of knowing which keys are pressed. Use event.key if you want to distinguish between capital letter or not, and avoid browser shortcuts, i.e: Ctrl + P (print) JS
document.onkeydown = event => { switch (event.code) { case ‘ArrowDown’: $div.style.top = `${parseInt($div.style.top || 0) + step}px` break case ‘KeyR’: if (event.altKey) $div.style.top = 0 break } }
View on JSFiddle here.
Short selectors like jQuery
Using JavaScript is some kind of annoying when you have to select DOM elements, in those cases we could miss jQuery because vanilla JavaScript is simply too long. JS
// Select one element (first one) document.querySelector('#peter') document.querySelector('.staff') document.querySelector('.staff').querySelector('.age') // Select all elements document.querySelectorAll('.staff')
We don’t like to repeat things when we are coding, if you define the next code at the beginning of your JavaScript you will be avaliable to do it similar even better than jQuery.
function $(selector) { return document.querySelector(selector) } function $$(selector) { return document.querySelectorAll(selector) } Element.prototype.$ = function(selector) { return this.querySelector(selector) } Element.prototype.$$ = function(selector) { return this.querySelectorAll(selector) }
Now you can write our example shorter:
// Select one element $('#peter') $('.staff') $('.staff').$('.age') // Select all elements $$('.staff')
It’s easy to keep in mind because $ behaves like jQuery with CSS selectors and $$ does the same but it allows you to select multiple elements. The first one return the element and the second one a list of elements. Just one more thing, you cannot use jQuery with this code because jQuery use $ too, if you need it you have to change the $ in our code for another thing, ie: qS. Remember, in JavaScript we have something better than classes: prototype. It doesn’t matter if you use class, under the hood is using prototype.
Which is the different between property and attribute?
A property is in the DOM; an attribute is in the HTML that is parsed into the DOM. HTML
<body onload="foo()">
JS
document.body.onload = foo
Avoid switch statement when you don’t need logic
Arrays are faster, in the next example if you want to now which is the nineth month you can just code months[9]. JS
const months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
0 notes
Text
Starting A New Business – Big Idea Bootcamp
The very best element? Selfmade now offers a single-on-one particular mentoring with prosperous business owners who’ve been where you are suitable now and who treatment about making a variation for gals in business enterprise. They include business house owners, founders, VCs, and matter-make any difference experts in industries these kinds of as finance, advertising, marketing and advertising, licensing, manner, and media.
Our summer mentorship application will attribute a host of new mentors we are psyched to link you with, which include:
Linda Xu, Entrepreneur and E-Commerce Skilled
Linda is the co-founder and chief expansion officer at Cart.com, a Collection-A e-commerce technologies platform that associates with makes to enable them improve. Linda served as head of growth at Sitari Ventures the place she oversaw tactic and functions. She has acquired and suggested tech and customer companies as a personal equity trader at global firms like The Riverside Corporation and Lazard. Also, Linda invested a transient stint on the crew launching Uber Freight. She enjoys all items food and crops.
Stephanie Cartin, Social Media Qualified + Entrepreneur
An entrepreneur at heart, Stephanie walked absent from her corporate profession in 2012 to observe her enthusiasm to start Socialfly, a major social-initial digital and influencer promoting agency based mostly in New York Town. Socialfly has considering that blossomed to around 30 complete-time staff and has been named to Inc. 5000’s speediest increasing non-public companies two yrs in a row. The company has worked with more than 200 properly-regarded brand names including Lady Scouts, WeTV, Conair, Nest Fragrances, 20th Century Fox and Univision. Stephanie is the co-host of the Entreprenista Podcast and co-author of Like, Love, Stick to: The Entreprenista’s Guideline to Applying Social Media To Develop Your Small business. She is also a recent receiver of the SmartCEO Brava award, which recognizes the major feminine CEOs in New York and a Stevie Award for Girls Operate Place of work of the Calendar year.
Kristina Ross, Written content Creator + Social Media Whiz
Kristina Would make #Information is a social media
funtrepreneur
, creative strategist, and community speaker for all matters Net relevant. Four several years as a magazine editor and producer/copywriter in the world of marketing (Mercedes, Most cancers Analysis, French Kiss Documents), Kristina packed her luggage and resolved to go remote with social media as she noticed a booming marketplace. Considering the fact that then, she designed @thefabstory from 10k to 1m followers in just 18 months and now specializes in creative tactics powering social media promotion and consumer acquisition. Her strategies have levelled applications from the major 50 into #1 in their application keep classes overnight. Kristina’s operate and activities have been featured in Forbes, Thrive World-wide and has given various talks at Harvard Business University on the huge terrible entire world of #information.
A.V. Perkins, Selfmade Alum and Creator of AVdoeswhat
A.V. is a Do-it-yourself qualified and creator of Avdoeswhat.com. What commenced as a conventional Do-It-Yourself site has developed into a lifestyle platform that consists of crafts, upcycled home furnishings and pop lifestyle. As a electronic host for HGTV Handmade, together with appearances in Bustle, The Pioneer Woman, and BuzzFeed, A.V. is established to assist thrifty millennials understand “Life is superior when you Do-It-By yourself!” A.V. is also the co-creator of College of Dope, an thrilling believed-provoking card game that celebrates Hip Hop society.The initially of its variety.
David Mesfin, Inventive Director + Model Pro
David is a multi-disciplinary designer and imaginative director with award-successful integrated marketing campaign history, together with the Tremendous Bowl, FIFA, NFL, and world-wide launch marketing campaign. He has produced international partnerships to improve brand recognition via common, digital, social, and experimental promoting campaigns, collaborating with C-suite leaders from Genesis, Hyundai, Honda, Sony, Adidas, Oakley, Toyota, Neutrogena, Land a lot more to communicate their firm’s eyesight by way of resourceful and marketing and advertising. He has acquired awards from Cannes, One Clearly show, Clio, Webby, EFFIE, Interaction Arts, Google Imaginative Sandbox, OC and LA ADDY, DIGIDAY, TED | Ads Truly worth Spreading, American Advertising and marketing Federation, FWA, The A-Checklist Hollywood Awards, IAB Mixx, and Graphis.
Jasmine Plouffe, Brand name Strategist
Jasmin is a manufacturer strategist/graphic designer who assists feminine business owners attract their desire prospects by sharing their story and having their branding and graphic design to a whole new amount.
Plus, our Selfmade Alum will be there to guide you together the way! Go from feeling by yourself to sensation deeply linked to a community of like-minded women of all ages. Our experienced company and career coaches will motivate you to take the up coming phase toward your biz objectives via weekly Accountability Pods. College students will have obtain to a large local community of like-minded entrepreneurs, including experts, founders, future company companions, freelancers, and extra.
This summer months, Selfmade coaches include Niki Shamdasani, co-founder and CEO of Sani, a South Asian-impressed trend brand Emily Merrell, founder and chief networking officer of feminine-centered networking firm 6 Levels Modern society Dr. Annie Vovan, whose profession spans the corporate earth, non-financial gain room, and company-dependent and e-commerce enterprises and Cachet Prescott, a enterprise mindset mentor and strategist.
Prepared to just take your company strategy to the subsequent degree? Enroll in Selfmade Summertime session currently!
Fascinated in joining our Mentor Plan? Use listed here.
window.REBELMOUSE_Lively_Duties_QUEUE.push(perform()
!functionality(f,b,e,v,n,t,s) if(f.fbq)returnn=f.fbq=purpose()n.callMethod? n.callMethod.utilize(n,arguments):n.queue.thrust(arguments) if(!f._fbq)f._fbq=nn.press=nn.loaded=!0n.model='2.0' n.queue=[]t=b.createElement(e)t.async=! t.src=vs=b.getElementsByTagName(e)[0] s.parentNode.insertBefore(t,s)(window, document,'script', 'https://link.facebook.internet/en_US/fbevents.js') fbq('init', '377612259624022') fbq('track', 'PageView')
)
window.REBELMOUSE_Active_Tasks_QUEUE.drive(functionality(){
window.REBELMOUSE_STDLIB.loadExternalScript("https://htlbid.com/v3/brit.co/htlbid.js", operate() {
/* (() => { googletag.cmd.thrust(() => { window.oldPubAds = googletag.pubads() window.oldSetTargeting = window.oldPubAds.setTargeting window.oldRefresh = window.oldPubAds.refresh
window.oldPubAds.setTargeting = (important, worth) => if (crucial == 'post_id') console.log(`HTL.pubads().setTargeting('$vital', $JSON.stringify(worth))`)
oldSetTargeting(important, worth)
window.oldPubAds.refresh = (slots) => let slotArray = googletag.pubads().getSlots() if (slots) slotArray = slots
const slotString = slots.map(s => s.getAdUnitPath().exchange('/112497074/', '')) console.log(`HTL.pubads().refresh($slotString)`)
if (slots) oldRefresh(slots) else oldRefresh()
googletag.pubads = () => return window.oldPubAds
}) })() */
})
})
window.REBELMOUSE_Energetic_Responsibilities_QUEUE.drive(functionality()
window.REBELMOUSE_STDLIB.loadExternalScript("https://s.skimresources.com/js/58005X1352817.skimlinks.js", purpose()
)
)
window.REBELMOUSE_Energetic_Responsibilities_QUEUE.push(function()
window.REBELMOUSE_STDLIB.loadExternalScript("https://cdn.sendpulse.com/js/thrust/6eebe1b62360a111b4210c09860569b6_1.js", purpose()
)
)
window.REBELMOUSE_Lively_Jobs_QUEUE.push(function(){
var topbannerRendered=false googletag.cmd.drive(operate () {
let topBanner=doc.getElementById("best_ad_banner")
googletag.pubads().addEventListener('slotRenderEnded', operate (evnt) {
enable adElement = topBanner.querySelector('.htl-advertisement > div')
if (evnt.slot.getSlotElementId() === adElement.id && !evnt.isEmpty) {
topBanner.type.show="block" topBanner.style.top = adElement.parentElement.clientHeight + 'px' //topBanner.nextElementSibling.design.marginTop = adElement.clientHeight + 'px' if(!topbannerRendered) topbannerRendered= legitimate topBanner.classList.incorporate('sticky-banner')
topBanner.classList.clear away('non-sticky-banner')
setTimeout(function () topBanner.classList.eliminate('sticky-banner') topBanner.classList.add('non-sticky-banner') /* topBanner.classList.add('mobile-sticky-banner') if(window.innerWidth { entries.forEach((entry) => { var CTASponsor = entry.focus on.querySelector(".aclu-cta")
if (entry.isIntersecting) console.log("in") if(window.impsTracker == ) googletag.cmd.drive(perform() googletag.pubads().refresh(googletag.pubads().getSlots().filter(s => s.getSlotElementId() === 'gpt-passback')) ) window.impsTracker = 1
//CTASponsor.design.width = window.ctaWidth + "px" CTASponsor.classList.take out("cta-sticky")
else console.log("out") if (CTASponsor.getBoundingClientRect().y callback(node) initializedNodes.incorporate(node) )
const mutationObserver = new MutationObserver(() => const nodes = doc.querySelectorAll(selector) nodes.forEach(node => if (!initializedNodes.has(node)) callback(node) initializedNodes.increase(node)
) )
mutationObserver.notice(document.human body, childList: true, subtree: accurate ) }
const acluPostConfig = root: null, rootMargin: "0px", threshold: .01,
var acluPostObserver = new IntersectionObserver((entries) => entries.forEach((entry) => var CTASponsor = document.querySelector(".aclu-cta") if (entry.isIntersecting) CTASponsor.hidden = fake else CTASponsor.concealed = true
) , acluPostConfig)
createElChangeListener('.aclu-inf-post', (el) => acluPostObserver.observe(el) )
})
The post Starting A New Business – Big Idea Bootcamp appeared first on dansealsforcongress.
from WordPress https://ift.tt/34OGVbW via IFTTT
0 notes
Text
Practice GraphQL Queries With the State of JavaScript API
Learning how to build GraphQL APIs can be quite challenging. But you can learn how to use GraphQL APIs in 10 minutes! And it so happens I've got the perfect API for that: the brand new, fresh-of-the-VS-Code State of JavaScript GraphQL API.
The State of JavaScript survey is an annual survey of the JavaScript landscape. We've been doing it for four years now, and the most recent edition reached over 20,000 developers.
We've always relied on Gatsby to build our showcase site, but until this year, we were feeding our data to Gatsby in the form of static YAML files generated through some kind of arcane magic known to mere mortals as "ElasticSearch."
But since Gatsby poops out all the data sources it eats as GraphQL anyway, we though we might as well skip the middleman and feed it GraphQL directly! Yes I know, this metaphor is getting grosser by the second and I already regret it. My point is: we built an internal GraphQL API for our data, and now we're making it available to everybody so that you too can easily exploit out dataset!
"But wait," you say. "I've spent all my life studying the blade which has left me no time to learn GraphQL!" Not to worry: that's where this article comes in.
What is GraphQL?
At its core, GraphQL is a syntax that lets you specify what data you want to receive from an API. Note that I said API, and not database. Unlike SQL, a GraphQL query does not go to your database directly but to your GraphQL API endpoint which, in turn, can connect to a database or any other data source.
The big advantage of GraphQL over older paradigms like REST is that it lets you ask for what you want. For example:
query { user(id: "foo123") { name } }
Would get you a user object with a single name field. Also need the email? Just do:
query { user(id: "foo123") { name email } }
As you can see, the user field in this example supports an id argument. And now we come to the coolest feature of GraphQL, nesting:
query { user(id: "foo123") { name email posts { title body } } }
Here, we're saying that we want to find the user's posts, and load their title and body. The nice thing about GraphQL is that our API layer can do the work of figuring out how to fetch that extra information in that specific format since we're not talking to the database directly, even if it's not stored in a nested format inside our actual database.
Sebastian Scholl does a wonderful job explaining GraphQL as if you were meeting it for the first time at a cocktail mixer.
Introducing GraphiQL
Building our first query with GraphiQL, the IDE for GraphQL
GraphiQL (note the "i" in there) is the most common GraphQL IDE out there, and it's the tool we'll use to explore the State of JavaScript API. You can launch it right now at graphiql.stateofjs.com and it'll automatically connect to our endpoint (which is api.stateofjs.com/graphql). The UI consists of three main elements: the Explorer panel, the Query Builder and the Results panels. We'll later add the Docs panels to that but let's keep it simple for now.
The Explorer tab is part of a turbo-boosted version of GraphiQL developed and maintained by OneGraph. Much thanks to them for helping us integrate it. Be sure to check out their example repo if you want to deploy your own GraphiQL instance.
Don't worry, I'm not going to make you write any code just yet. Instead, let's start from an existing GraphQL query, such as the one corresponding to developer experience with React over the past four years.
Remember how I said we were using GraphQL internally to build our site? Not only are we exposing the API, we're also exposing the queries themselves. Click the little "Export" button, copy the query in the "GraphQL" tab, paste it inside GraphiQL's query builder window, and click the "Play" button.
Source URL
The GraphQL tab in the modal that triggers when clicking Export.
If everything went according to plan, you should see your data appear in the Results panel. Let's take a moment to analyze the query.
query react_experienceQuery { survey(survey: js) { tool(id: react) { id entity { homepage name github { url } } experience { allYears { year total completion { count percentage } awarenessInterestSatisfaction { awareness interest satisfaction } buckets { id count percentage } } } } } }
First comes the query keyword which defines the start of our GraphQL query, along with the query's name, react_experienceQuery. Query names are optional in GraphQL, but can be useful for debugging purposes.
We then have our first field, survey, which takes a survey argument. (We also have a State of CSS survey so we needed to specify the survey in question.) We then have a tool field which takes an id argument. And everything after that is related to the API results for that specific tool. entity gives you information on the specific tool selected (e.g. React) while experience contains the actual statistical data.
Now, rather than keep going through all those fields here, I'm going to teach you a little trick: Command + click (or Control + click) any of those fields inside GraphiQL, and it will bring up the Docs panel. Congrats, you've just witnessed another one of GraphQL's nifty tricks, self-documentation! You can write documentation directly into your API definition and GraphiQL will in turn make it available to end users.
Changing variables
Let's tweak things a bit: in the Query Builder, replace "react" with "vuejs" and you should notice another cool GraphQL thing: auto-completion. This is quite helpful to avoid making mistakes or to save time! Press "Play" again and you'll get the same data, but for Vue this time.
Using the Explorer
We'll now unlock one more GraphQL power tool: the Explorer. The Explorer is basically a tree of your entire API that not only lets you visualize its structure, but also build queries without writing a single line of code! So, let's try recreating our React query using the explorer this time.
First, let's open a new browser tab and load graphiql.stateofjs.com in it to start fresh. Click the survey node in the Explorer, and under it the tool node, click "Play." The tool's id field should be automatically added to the results and — by the way — this is a good time to change the default argument value ("typescript") to "react."
Next, let's keep drilling down. If you add entity without any subfields, you should see a little squiggly red line underneath it letting you know you need to also specify at least one or more subfields. So, let's add id, name and homepage at a minimum. Another useful trick: you can automatically tell GraphiQL to add all of a field's subfields by option+control-clicking it in the Explorer.
Next up is experience. Keep adding fields and subfields until you get something that approaches the query you initially copied from the State of JavaScript site. Any item you select is instantly reflected inside the Query Builder panel. There you go, you just wrote your first GraphQL query!
Filtering data
You might have noticed a purple filters item under experience. This is actually they key reason why you'd want to use our GraphQL API as opposed to simply browsing our site: any aggregation provided by the API can be filtered by a number of factors, such as the respondent's gender, company size, salary, or country.
Expand filters and select companySize and then eq and range_more_than_1000. You've just calculated React's popularity among large companies! Select range_1 instead and you can now compare it with the same datapoint among freelancers and independent developers.
It's important to note that GraphQL only defines very low-level primitives, such as fields and arguments, so these eq, in, nin, etc., filters are not part of GraphQL itself, but simply arguments we've defined ourselves when setting up the API. This can be a lot of work at first, but it does give you total control over how clients can query your API.
Conclusion
Hopefully you've seen that querying a GraphQL API isn't that big a deal, especially with awesome tools like GraphiQL to help you do it. Now sure, actually integrating GraphQL data into a real-world app is another matter, but this is mostly due to the complexity of handling data transfers between client and server. The GraphQL part itself is actually quite easy!
Whether you're hoping to get started with GraphQL or just learn enough to query our data and come up with some amazing new insights, I hope this guide will have proven useful!
And if you're interested in taking part in our next survey (which should be the State of CSS 2020) then be sure to sign up for our mailing list so you can be notified when we launch it.
State of JavaScript API Reference
You can find more info about the API (including links to the actual endpoint and the GitHub repo) at api.stateofjs.com.
Here's a quick glossary of the terms used inside the State of JS API.
Top-Level Fields
Demographics: Regroups all demographics info such as gender, company size, salary, etc.
Entity: Gives access to more info about a specific "entity" (library, framework, programming language, etc.).
Feature: Usage data for a specific JavaScript or CSS feature.
Features: Same, but across a range of features.
Matrices: Gives access to the data used to populate our cross-referential heatmaps.
Opinion: Opinion data for a specific question (e.g. "Do you think JavaScript is moving in the right direction?").
OtherTools: Data for the "other tools" section (text editors, browsers, bundlers, etc.).
Resources: Data for the "resources" section (sites, blogs, podcasts, etc.).
Tool: Experience data for a specific tool (library, framework, etc.).
Tools: Same, but across a range of tools.
ToolsRankings: Rankings (awareness, interest, satisfaction) across a range of tools.
Common Fields
Completion: Which proportion of survey respondents answered any given question.
Buckets: The array containing the actual data.
Year/allYears: Whether to get the data for a specific survey year; or an array containing all years.
The post Practice GraphQL Queries With the State of JavaScript API appeared first on CSS-Tricks.
via CSS-Tricks https://ift.tt/2S05TOQ
0 notes
Text
Practice GraphQL Queries With the State of JavaScript API
Learning how to build GraphQL APIs can be quite challenging. But you can learn how to use GraphQL APIs in 10 minutes! And it so happens I've got the perfect API for that: the brand new, fresh-of-the-VS-Code State of JavaScript GraphQL API.
The State of JavaScript survey is an annual survey of the JavaScript landscape. We've been doing it for four years now, and the most recent edition reached over 20,000 developers.
We've always relied on Gatsby to build our showcase site, but until this year, we were feeding our data to Gatsby in the form of static YAML files generated through some kind of arcane magic known to mere mortals as "ElasticSearch."
But since Gatsby poops out all the data sources it eats as GraphQL anyway, we though we might as well skip the middleman and feed it GraphQL directly! Yes I know, this metaphor is getting grosser by the second and I already regret it. My point is: we built an internal GraphQL API for our data, and now we're making it available to everybody so that you too can easily exploit out dataset!
"But wait," you say. "I've spent all my life studying the blade which has left me no time to learn GraphQL!" Not to worry: that's where this article comes in.
What is GraphQL?
At its core, GraphQL is a syntax that lets you specify what data you want to receive from an API. Note that I said API, and not database. Unlike SQL, a GraphQL query does not go to your database directly but to your GraphQL API endpoint which, in turn, can connect to a database or any other data source.
The big advantage of GraphQL over older paradigms like REST is that it lets you ask for what you want. For example:
query { user(id: "foo123") { name } }
Would get you a user object with a single name field. Also need the email? Just do:
query { user(id: "foo123") { name email } }
As you can see, the user field in this example supports an id argument. And now we come to the coolest feature of GraphQL, nesting:
query { user(id: "foo123") { name email posts { title body } } }
Here, we're saying that we want to find the user's posts, and load their title and body. The nice thing about GraphQL is that our API layer can do the work of figuring out how to fetch that extra information in that specific format since we're not talking to the database directly, even if it's not stored in a nested format inside our actual database.
Sebastian Scholl does a wonderful job explaining GraphQL as if you were meeting it for the first time at a cocktail mixer.
Introducing GraphiQL
Building our first query with GraphiQL, the IDE for GraphQL
GraphiQL (note the "i" in there) is the most common GraphQL IDE out there, and it's the tool we'll use to explore the State of JavaScript API. You can launch it right now at graphiql.stateofjs.com and it'll automatically connect to our endpoint (which is api.stateofjs.com/graphql). The UI consists of three main elements: the Explorer panel, the Query Builder and the Results panels. We'll later add the Docs panels to that but let's keep it simple for now.
The Explorer tab is part of a turbo-boosted version of GraphiQL developed and maintained by OneGraph. Much thanks to them for helping us integrate it. Be sure to check out their example repo if you want to deploy your own GraphiQL instance.
Don't worry, I'm not going to make you write any code just yet. Instead, let's start from an existing GraphQL query, such as the one corresponding to developer experience with React over the past four years.
Remember how I said we were using GraphQL internally to build our site? Not only are we exposing the API, we're also exposing the queries themselves. Click the little "Export" button, copy the query in the "GraphQL" tab, paste it inside GraphiQL's query builder window, and click the "Play" button.
Source URL
The GraphQL tab in the modal that triggers when clicking Export.
If everything went according to plan, you should see your data appear in the Results panel. Let's take a moment to analyze the query.
query react_experienceQuery { survey(survey: js) { tool(id: react) { id entity { homepage name github { url } } experience { allYears { year total completion { count percentage } awarenessInterestSatisfaction { awareness interest satisfaction } buckets { id count percentage } } } } } }
First comes the query keyword which defines the start of our GraphQL query, along with the query's name, react_experienceQuery. Query names are optional in GraphQL, but can be useful for debugging purposes.
We then have our first field, survey, which takes a survey argument. (We also have a State of CSS survey so we needed to specify the survey in question.) We then have a tool field which takes an id argument. And everything after that is related to the API results for that specific tool. entity gives you information on the specific tool selected (e.g. React) while experience contains the actual statistical data.
Now, rather than keep going through all those fields here, I'm going to teach you a little trick: Command + click (or Control + click) any of those fields inside GraphiQL, and it will bring up the Docs panel. Congrats, you've just witnessed another one of GraphQL's nifty tricks, self-documentation! You can write documentation directly into your API definition and GraphiQL will in turn make it available to end users.
Changing variables
Let's tweak things a bit: in the Query Builder, replace "react" with "vuejs" and you should notice another cool GraphQL thing: auto-completion. This is quite helpful to avoid making mistakes or to save time! Press "Play" again and you'll get the same data, but for Vue this time.
Using the Explorer
We'll now unlock one more GraphQL power tool: the Explorer. The Explorer is basically a tree of your entire API that not only lets you visualize its structure, but also build queries without writing a single line of code! So, let's try recreating our React query using the explorer this time.
First, let's open a new browser tab and load graphiql.stateofjs.com in it to start fresh. Click the survey node in the Explorer, and under it the tool node, click "Play." The tool's id field should be automatically added to the results and — by the way — this is a good time to change the default argument value ("typescript") to "react."
Next, let's keep drilling down. If you add entity without any subfields, you should see a little squiggly red line underneath it letting you know you need to also specify at least one or more subfields. So, let's add id, name and homepage at a minimum. Another useful trick: you can automatically tell GraphiQL to add all of a field's subfields by option+control-clicking it in the Explorer.
Next up is experience. Keep adding fields and subfields until you get something that approaches the query you initially copied from the State of JavaScript site. Any item you select is instantly reflected inside the Query Builder panel. There you go, you just wrote your first GraphQL query!
Filtering data
You might have noticed a purple filters item under experience. This is actually they key reason why you'd want to use our GraphQL API as opposed to simply browsing our site: any aggregation provided by the API can be filtered by a number of factors, such as the respondent's gender, company size, salary, or country.
Expand filters and select companySize and then eq and range_more_than_1000. You've just calculated React's popularity among large companies! Select range_1 instead and you can now compare it with the same datapoint among freelancers and independent developers.
It's important to note that GraphQL only defines very low-level primitives, such as fields and arguments, so these eq, in, nin, etc., filters are not part of GraphQL itself, but simply arguments we've defined ourselves when setting up the API. This can be a lot of work at first, but it does give you total control over how clients can query your API.
Conclusion
Hopefully you've seen that querying a GraphQL API isn't that big a deal, especially with awesome tools like GraphiQL to help you do it. Now sure, actually integrating GraphQL data into a real-world app is another matter, but this is mostly due to the complexity of handling data transfers between client and server. The GraphQL part itself is actually quite easy!
Whether you're hoping to get started with GraphQL or just learn enough to query our data and come up with some amazing new insights, I hope this guide will have proven useful!
And if you're interested in taking part in our next survey (which should be the State of CSS 2020) then be sure to sign up for our mailing list so you can be notified when we launch it.
State of JavaScript API Reference
You can find more info about the API (including links to the actual endpoint and the GitHub repo) at api.stateofjs.com.
Here's a quick glossary of the terms used inside the State of JS API.
Top-Level Fields
Demographics: Regroups all demographics info such as gender, company size, salary, etc.
Entity: Gives access to more info about a specific "entity" (library, framework, programming language, etc.).
Feature: Usage data for a specific JavaScript or CSS feature.
Features: Same, but across a range of features.
Matrices: Gives access to the data used to populate our cross-referential heatmaps.
Opinion: Opinion data for a specific question (e.g. "Do you think JavaScript is moving in the right direction?").
OtherTools: Data for the "other tools" section (text editors, browsers, bundlers, etc.).
Resources: Data for the "resources" section (sites, blogs, podcasts, etc.).
Tool: Experience data for a specific tool (library, framework, etc.).
Tools: Same, but across a range of tools.
ToolsRankings: Rankings (awareness, interest, satisfaction) across a range of tools.
Common Fields
Completion: Which proportion of survey respondents answered any given question.
Buckets: The array containing the actual data.
Year/allYears: Whether to get the data for a specific survey year; or an array containing all years.
The post Practice GraphQL Queries With the State of JavaScript API appeared first on CSS-Tricks.
Practice GraphQL Queries With the State of JavaScript API published first on https://deskbysnafu.tumblr.com/
0 notes
Link
In an attempt to dispel the idea that if you have to google stuff you’re not a proper engineer, this is a list of nearly everything I googled in a week at work, where I’m a software engineer with several years’ experience. Obviously these weren’t all googled in a row (although you can probably spot that a few were), but throughout the day. I can’t remember the context of everything I was googling, but hopefully it’ll make you feel a little better next time you have to google something. Mondaynpm react-testing-library - during a React upgrade, looking at dependencies to see latest versions and checking for breaking changes. Expecting a parsed GraphQL document. Perhaps you need to wrap the query string in a "gql" tag? - said React upgrade then started causing some super fun errors. react-apollo release notes react-apollo/test-utils - tests were throwing some odd errors with our graphQL components. undo a rebase - oops. react testing library apollo "invariant violation" - package upgrades are so much fun! jest silence warnings - don’t judge me, ok? semantic HTML contact details - wanted to check if the tag was relevant here aa contrast checker temporary visual impairment - fact checking for an accessibility talk I was giving that week dominos accessibility - popcorn.gif shame gif - an important part of any presentation Tuesdayjavascript get array of unique dates - if I have an array of Dates, how can I filter them so they are unique? (reduce, naturally, but I can rarely use that without googling it first) date to locale string js date to locale string - after I got a load of Java results alternatives to Moment.js - it’s large group array items by date - more reduce fun sort object keys javascript react fragment keys next link - needed a reminder of how to use the Link component in Next.JS React.Children.only expected to receive a single React element child. visual studio code disable autocomplete html - it keeps autoclosing HTML elements on the same line, and I still can’t switch it off dt dd dl - couldn’t remember what the example use for these was. html nested sections - is it ok to have inside ? display dl in pairs veggie ipsum - the best lorem ipsum generator css keyframes css animate underline text dl vs ul react generating keys - should I use some kind of hash, or should I use data in the props? (I ended up constructing a string with unique timestamp data) css checkbox - can we style checkboxes yet? (no) flexbox center span - it was 17:24 and I was tired by this point grid minmax flexible grid row - I don’t have a whole lot of CSS Grid experience, so I always end up googling a ton with this. grid row height auto cauliflower shortage - someone told me about this and I panicked next.js hooks - we can use them, right? (we can, and I did) Wednesdaycors - today is going to be bleak the corrs - once I hit some CORS errors I decided I needed to make a meme, and I needed to find the perfect image. It took a surprisingly long time. Worth itgit patch trailing whitespace - I was sent a git patch with some whitespace that prevented it from actually patching jsx annotation web api fetch preflight - in my CORS adventures I wanted to read up a bit more about preflight requests. web api fetch origin header discriminated union flow - trying to diagnose problems with my Flow types. whitespace regex - is it \w? (no, that’s a word - it’s \s) regex not letter pat butcher emoji - what can I say, I google important things woman shouting at cat google oauth next.js authentication - sometimes it’s helpful to google stuff to see if anyone has written examples of how to do common flows in the framework or tool that you’re using component displayname - do I need to do this with my higher-order components? nextCookie - starting to mess around with oauth cookies reading cookies in react - there must be a better way than document.cookie js-cookie npm cookies-js npm cookie universal-cookie google oauth cookie 🍪 Thursday"log in with google" localhost - was having all sorts of problems getting this to work httpserverrequest javascript - I have a feeling this was something to do with Flow types nextjs flowtypes - yep, there you go "python-social-auth" react - trying to figure out if the django backend I was working with would play nicely with my React frontend google social login vary header get cookie from 302 google social login cookies - I was having a really fun time with this as you can tell google oauth cookie python-social-auth set-cookie python-social-auth site:stackoverflow.com python-social-auth react site:stackoverflow.com django - I think I gave up at this point and just googled Django because I have literally never used it fetch send cookies testing same origin credentials locally cross origin cookies - spoiler alert: not a thing useState default value "The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when when the request's credentials mode is 'include'. - googling error messages is only second to console.log() as a debugging method useState with empty array react hooks initial state empty array "Provisional headers are shown" - this is where the requests weren’t going through and I couldn’t see what the actual headers being sent were fetch send cookies how to see request headers in chrome fetch not sending cookies Thursday was a whole lot of fun D: Fridayprovisional headers are shown - still at it. sending cookies from localhost - have I mentioned that I hate cookies? editing host file - desperate times (and it didn’t even work) sending cookies with different domain next cookie getinitialprops functional component getting cookies from document js find - to check the usage and return types string contains string methods js - I can’t keep any of these in my head js string methods - 20 mins later js fetch manual cookie django react cookies localhost django react cookies localhost site:stackoverflow.com httponly cookie django httponly async await promise.all nextjs port google appengine node ports next rename static install gcloud cli method patch - couldn’t remember what the HTTP method PATCH does. nextjs env next.js environment variables next js docs editing data with hooks - literally no idea what I was trying to google here but this was past 5pm so I was evidently quite tired react form submit dayjs - I needed the documentation again. What I’m trying to show with all this is that you can do something 100 times but still not remember how to do it off the top of your head. Never be ashamed of googling, even if it seems like the most basic thing you’re looking up. I can never remember how Date works. I’ve built plenty of forms in React but couldn’t remember how onSubmit worked on the Friday evening at 5:30pm. I constantly have to google JS string methods. Cookies are terrible. (Incidentally, we fixed the cookie issue by running everything in a docker container and tunneling with ngrok, so everything’s on the same domain.)
0 notes
Text
jQuery Form Plugins To Use In Your Websites (46 Options)
Have you tried creating the forms from scratch on your website? Why not use jQuery form plugins?
Having forms on your website just doesn’t really cut it. You need those forms to be validated to receive the appropriate data from the sender.
This way you don’t only stave off unwanted submissions, but you also guide your senders to fill out the forms.
Validating the date is just as important as having the forms themselves.
There are a few ways to create flawless forms, and the good news is that if you use some of the jQuery Form Plugins available, things get much easier.
jQuery form plugins to check out
Fileuploader
Fileuploader is a beautiful and powerful HTML5 file uploading tool. A jQuery and PHP plugin that transforms the standard file input into a revolutionary and fancy field on your page.
File preview with image thumbnail or icon
File image thumbnail can be generated in canvas to resize it perfectly for given with and height
Render synchron the file preview
File icon background is generated from file extension
Customize your own input and thumbnail elements
Responsive and fancy animations
Choose multiple files from different folders
Drag&Drop feature
Upload each file with Ajax
Upload synchron the files
Upload progressbar with many data available
Start, retry and cancel upload actions
Paste images from clipboard (only in Chrome)
Validate the file’s limit, size and extension. You can also use your own function
Edit mode for already uploaded files
All files are in one list in a hidden input
Use input HTML attributes to configurate it
HTML template renderer using Text variables
CSS file icon
PHP upload helper
PHP generates an array with many file informations
PHP can create a custom file name
API and more than 24 Callbacks to manipulate freely the appearance and functionality of your file input
Conditionize.js
A small jQuery plugin for handling showing and hiding things conditionally based on input – typically groups of form fields. It works using data attributes to keep all of the name/values for inputs directly in the markup and saves you the trouble of having to manually show/hide a bunch of stuff through JS, as well as improving maintenance if you need to change the name or value of an input you were listening to.
Cleave.js
Cleave.js has a simple purpose: to help you format input text content automatically.
Credit card number formatting
Phone number formatting (i18n js lib separated for each country to reduce size)
Date formatting
Numeral formatting
Custom delimiter, prefix and blocks pattern
CommonJS / AMD mode
AttrValidate
A lightweight jQuery plugin for basic form validation using HTML5 form attributes. Recommended as a polyfill for older browsers which do not provide built-in validation.
Mobiscroll Forms
Mobiscroll Forms supports multiple themes for different platforms and the web – iOS, Android, Windows Phone.
Shipping with 13 elements for:
Single line and multiline text
Select styling
Buttons
Segmented control
Checkbox and checklist
Radio buttons
Switch
Stepper
Page styling & Typography
Slider
Progress
Alert, confirm and prompt
Toast and snackbar
Multipicker
Multipicker is jQuery plugin for selecting days, numbers or other elements, it supports multi selecting (like checkboxes) or single element selection (like radio buttons).
SmartWizard
Smart Wizard is a flexible and heavily customizable jQuery step wizard plugin with Bootstrap support. It is easy to implement and gives a neat and stylish interface for your forms, checkout screen, registration steps etc. Based on the feedback from our users over the past years we have come up with the best ever built jQuery wizard plugin of all time.
Features:
Bootstrap support
Responsive themes
Heavily customizable toolbar, option to add extra buttons
Theme support with various themes included
Customizable css styles
Url navigation and step selection
Public methods for external function call
Enhanced event support
In-built wizard reset method
Ajax content loading with option to specify individual url for steps
Keyboard navigation
Contact Form to Google Spreadsheet
Create Contact Form in HTML and submit the data to Google Spreadsheet. Google re-captcha has been integrated to protect forms to be submitted by robots. Check the demo and documentation for more details.
Features:
Google Spreadsheet as database: Uses Google Spreadsheet to capture form responses. New responses can be appended at the top.
Simple Form: Designed with simple HTML5, CSS3 and bootstrap.
Protection: Google re-captcha to prevent spamming.
Customization: You can customize the form according to your own requirement.
Look and feel: Bootstrap two column layout, responsive. Shows status loader when the form is being submitted.
Notification: Can send notification email to the admin with submitted form data.
Hierarchy Select
A jQuery hierarchy select plugin used for selecting hierarchy structures in a selectbox format with autocomplete search.
SmartMenu
SmartMenu is a user-friendly, highly customizable and responsive jQuery mega menu plugin. It allows you to use multiple menus with different submenus.
Features:
Responsive design
Supports multiple instances
Horizontal (top, bottom) or Vertical (left, right) menu layouts
Mega / Flyout submenus
Pure CSS3 animations (fade, slide)
3 ways of dropdown (hover, click, toggle)
7 color skins which can be changed easily
Custom mega dropdowns, forms, search bar, social icons or HTML
12 columns fluid grid
You can add images, maps or videos
BunnyJS
BunnyJS is a modern Vanilla JS and ES6 library and next-generation front-end framework, package of small stand-alone components without dependencies.
No dependencies – can be used in any project anywhere anytime
0 learning curve – you can start right now, just plain JavaScript with simple architecture easy to maintain and extend
Designed in mind to build modern, complicated, real world business apps
Faster, simpler, enjoyable than any frontend framework
Large set of ready components, custom UI elements and utils
Dirrty
Dirrty lightweight jquery plugin to detect if the fields of a form had been modified.
If a field has been modified then the form is dirrty
Detect the moment when the form gets dirty, and trigger a custom event, for example enable a “save changes” button
Detect the moment when the form gets clean again, and trigger a custom event, for example disable the “save changes” button, cause is not necesary
Prompt the user to save changes before leaving if the form is dirty
Inputmask
jQuery inputmask is a jquery plugin which create an input mask.
An inputmask helps the user with the input by ensuring a predefined format. This can be usefull for dates, numerics, phone numbers, …
Features:
easy to use
optional parts anywere in the mask
possibility to define aliases which hide complexity
date / datetime masks
numeric masks
lots of callbacks
non-greedy masks
many features can be enabled/disabled/configured by options
supports readonly/disabled/dir=”rtl” attributes
support data-inputmask attribute
multi-mask support
Formbase
Formbase is a better default styles for common input elements.Formbase eliminates cross browser bugs, inconsistencies across systems and applies a beautiful default styling to several input elements.
Works in all modern browsers (and IE11)
No JavaScript, just CSS
Works with inputs, textareas, checkboxes and radio buttons
Zero dependencies
File Input
File input fields look differently in all browsers. It’s a pain in the arse to design something that looks nice in all browsers and it sucks that support for this is not available in Twitter Bootstrap. This jQuery plugin is designed to make all file input fields look like standard Twitter Bootstrap buttons.
Form Designer
FORM-DESIGNER is a jQuery form builder tool which will help you to build an interactive form to use in your website template. This is mainly a HTML developer’s tool, but anyone who have a little knowledge about CSS and HTML structure and use of them, can use this tool.
I try to keep this jquery application very simple and user-friendly so that anyone can understand it within one or two tries.In this tool you will get total 7 option to create form from 7 different template and one option to create a custom form. As a final output, you will get the HTML,CSS and jQuery code here.
Choices.js
A vanilla, lightweight (~15kb gzipped), configurable select box/text input plugin. Similar to Select2 and Selectize but without the jQuery dependency.
Lightweight
No jQuery dependency
Configurable sorting
Flexible styling
Fast search/filtering
Clean API
Right-to-left support
JSON Manager
JSON manager: jQuery plug-in that converts JS & JSON objects to HTML forms and back again.
Medea loves JSON. Give Medea a JSON object, even one with nested objects, and it will be converted into an HTML form. The form allows fields in the object to be edited, or deleted, or for new ones to be created. The modified object is returned via the submit event.
Spider
Mailgun API for mail validation online
50+ Form templates
Ajax form
Remote/server validation
Php ready form
Dynamic field
Credit card validator
Zip/Pin code validator
Semantic ui integrated
Custom error container
custom error handler
Multiple input validator As one
button style included
60+ button style included in package
TextArea
One of the most used, but under featured HTML controls, is the humble TEXTAREA control. This control is designed to accept large blocks of text from the user. A wide variety of plugins exist for the TEXTAREA that layer it with toolbars, auto-resizing, rich-text editing and the works.
More jQuery form plugins?
Keep scrolling.
There are more.
Character and Word Counter
This jQuery Word and character counter plug-in allows you to count characters or words, up or down. You can set a minimum or maximum goal for the counter to reach.
Create a custom message for your counter’s message
Force character/word limit on user to prevent typing
Works against copy/paster’s!
Addel
Addel is a simple & lightweight jQuery form plugin for powering UIs that enable dynamic addition & deletion of HTML elements, conceived with form elements in mind.
PopSelect
A jQuery plugin to replace the traditional <select> box with a sleek Popover with options pre-populated. Better User interface than any other multiselects.
Timon
With Timon – Step Form Wizard you will have power combo of 21 different styles, 8 different transition effects, validation in your step form, titles and subtitles with multiple step. , also Timon – Step Form Wizard has predefined set of form sizes from tiny to large. You can easily create and customize any form to fit your needs.
Features:
Step navigation
Fully responsive
Many options for design and function
Can be used for tabs
Step navigation
21 Style
8 transition effect
Select.js
Another one of these jQuery form plugins is Select.js. It is a Javascript and CSS library for creating styleable select elements. It aims to reproduce the behavior of native controls as much as is possible, while allowing for complete styling with CSS.
Tagger Widget
jQuery plugin to turn a HTML select into an auto-suggesting, tagging widget. It was written from the ground up and has support for hierachical data, searching for data that isn’t displayed, displaying arbitrary HTML in the suggestion list, running the original onChange actions, displaying tags for items previously selected but no longer in the list, keyboard accessibility and many other features.
formBuilder
A jQuery plugin for drag and drop form creation. To start building forms with this plugin call formBuilder() on the textarea you would like to make your editor. FormBuilder takes a number of options and is translatable.
OrderNow
PHP Order Form will helps to get project orders from the clients for the people like web developers, corporates and freelancers easily. This form is PayPal integrated and admin functionalities are integrated.
Features:
Responsive design layout
PHP order form with MySql database
Multitab features
Cross-browser platform
Contents are organized in a user-friendly format
Admin can manage all contents and order management
Mail Templates are available in admin side
Easy Forms
Easy Forms is one of the jQuery form plugins in this article that will help you design and develop web forms quickly and easily. Actually, you will not need programming skills to make your forms work in minutes.
Build any type of online forms: Contact forms, Order forms, Registration forms, Online surveys, Trivias and more.
Drag & Drop Fields. No coding skills required.
HTML5 Fields Support
Create Multi-Step Forms
Bootstrap CSS Support
Theme & Template Managers
Advanced CSS Editor with Form Live Preview
Parsley
Parsley.js is a lightweight and feature-rich library that instead of validating forms with Javascript, it uses data attributes embedded in the DOM to achieve the same function. The surprisingly easy to configure plugin also allows you to override almost every default behavior so that it will fit in with your form requirements.
jQuery Validation Engine
When it comes to the jQuery Validation Engine, you don’t need to worry about the structure of your form as the plugin will create an error DIV and position it in the top right corner of the specified input, keeping both the forms code and validations seperate. Phis is probably the easiest validation solution in this article.
Validatr
Validatr uses HTML5 input attributes to perform validation, with support for color, date, email, number and range. The input types text, checkbox, radio…. are supported, but do not require the same level of validation.
Where possible, Validatr will use native validation, using Modernizr to test for support. If an input type is not supported it will use it’s own ruleset to supplement native validation. In both cases case, the validation message is shown.
Smoke
Smoke is a collection of components for Bootstrap – including a form validator. In comparison to the other Bootstrap validator (#4), it doesn’t use native browser validation – therefore error messages aren’t automatically localized and validation rules have to be specified using HTML5 and data attributes, as well as JavaScript.
Validetta
This plugin offers validation using a data attribute, with quite limited options. It comes with just the basic validation rules, everything else can be added with custom regular expressions – but there is no example demonstrating it. Compared to the other plugins, the only unique feature is that error messages are displayed in a bubble (see demo below).
jQuery.validity
A plugin to control validation with JavaScript only – no HTML5 or data attributes. While this may be helpful for dynamic validation rules, the plugin doesn’t offer enough options to make writing efficient. It even doesn’t allow using new HTML5 type attributes like email, nor does it provide a function to check if a form is valid – necessary in order to show a success message.
h5Validate
This plugin has unfortunately been abandoned by its creator (Eric Elliott). Consequently, the demo/documentation website returns a 404 and there are two dozen open issues. The plugin doesn’t automatically validate inputs by type and the following example even doesn’t show error messages. We’ve included it in the list, as Eric is looking for a new maintainer for the project, so there’s a chance that at some point in the future, it might get some life breathed back into it.
SkipOnTab
A jQuery plugin to exempt selected shape fields from the ahead tab order.This library is maximum beneficial while the customers are familiar with the shape, and makes use of it frequently.
Contact Tabs
A jQuery shape generator for creating limitless slide-out or static touch tabs containing AJAX powered customised bureaucracy. Plugin consists of 12 one-of-a-kind form factors and consumer-aspect validation.
Simple Contact Form
With jQuery Simple Contact Form, you could installation an ajax touch form for your website, writing only the form html code and one js code line. Email is generated and ship by using the plugin (php report blanketed) .
Form Recover
By installing this plugin you’ll permit your users to have a draft of their shape saved and restored automatically in cases of unintended refresh or browser crash.
Forms Plus
Forms Plus is a form framework. JS version includes everything CSS has, plus date/time pickers, shade pickers, sliders, captcha fields, spinners, area groups (for code, credit card number, and many others.)
Prosto Forms
Prosto Forms is a responsive Form Framework and set of beautiful shape factors with large quantity of javascript capabilities: validation, protecting, modals, ajax put up, datepickers.
Simple Subscription Popup
Simple Signup jQuery Form Plugins will gather the visitor’s electronic mail deal with in your internet site with an attention-grabber, effective manner. It has a number of elective customization alternatives and you may setup truely in mins.
Foggle
jQuery Foggle is a plugin that helps you to interact with various shape factors primarily based on consumer-enter. It helps you to pick which elements to allow (or disable) whilst the person fills out the shape.
WizardPro
WizardPro lets in you to create website wizards in only a few mins. You can use this plugin for nearly some thing that requires some steps, like a utility installer, a signup or touch form.
Virtual Phone Number Selling Form
Virtual Phone Number Selling Form is a selling form for those voip commercial enterprise who’re promoting virtual telephone numbers designed for All styles of VOIP Business. It’s an jQuery Plugin based totally on present day Bootstrap 3.3.7.
If you liked this article with jQuery form plugins, you should check out these as well:
jQuery Bootstrap Plugins (51 Great Examples)
Charts And Graphs Javascript Libraries
jQuery Lightbox Plugins (19 Examples)
jQuery Gallery Plugins For Showcasing Images Better
The post jQuery Form Plugins To Use In Your Websites (46 Options) appeared first on Design your way.
from Web Development & Designing http://www.designyourway.net/blog/resources/jquery-form-plugins/
0 notes
Text
90% off #Angular 2 Crash Course with TypeScript – $10
Get in-depth knowledge of Angular 2 and TypeScript with this crash course for all skill levels.
All Levels, – 4 hours, 72 lectures
Average rating 4.0/5 (4.0 (400 ratings) Instead of using a simple lifetime average, Udemy calculates a course’s star rating by considering a number of different factors such as the number of ratings, the age of ratings, and the likelihood of fraudulent ratings.)
Course requirements:
Before taking this course, a student should ideally (but not absolutely) have some experience in: Creating web UI’s with normal Javascript tools (i.e. jQuery, Bootstrap, ASP.NET, AngularJS, etc.) Programming with a common object-oriented or scripting language (i.e. Java, C#, Python, PHP, etc.) JavaScript development of complete client-side solutions. ANGULAR1 EXPERIENCE IS NOT REQUIRED!!!
Course description:
There’s no way around it. If you want to gain a competitive edge in UI/UX design, web development, or anything to do with mobile and desktop web apps, then you need to know Angular JS. Better yet, you need to know Angular 2, the latest version. This Angular 2 crash course will refresh your memory and get you updated on the essentials of the latest version. And if you’re just getting started with Angular JS, don’t worry = this is the perfect introduction too.
Get Up to Speed with Angular 2
Understand Angular 2 and how it can help you as a developer Code an Angular 2 project with an online IDE Get to grips with Angular 2’s many powerful features Improve your UI/UX design and development skills Discover what’s new in the latest version of Angular
Upgrade your Programming Skills
With 71 lectures and 5 hours of content, this Angular 2 online course will give you a thorough understanding of how Angular 2 solutions are designed, administered, and developed. If you’re a web, mobile or service app developer, architect, UI designer, tester or administrator, or if you just want to know how to get Angular 2 projects up and running, then this is the course for you.
You don’t need any Angular 1 or UI experience to take this course, although if you’re familiar with creating web UIs with normal JavaScript tools (jQuery, Bootstrap, etc.), or object-oriented scripting languages like Java, C#, Python etc., you’ll already have a head start.
The course will begin with an introduction to TypeScript, the Cloud9 IDE and using Angular 2 modules. Then you’ll get stuck into Angular 2’s components, building a UI and binding your data. After that things get a little more challenging with a breakdown of advanced component concepts and component composition. From there you’ll jump into services, web services, and routing before setting up Angular 2 from scratch.
By the end of this course you’ll be able to set up and get going on your own Angular 2 projects quickly, easily, and efficiently.
About Angular JS
Angular is a development platform for building mobile and desktop web applications. It’s a structural framework that allows you to use HTML as your template language, and is JavaScript based. It has many high-power features like data binding and dependency injection that eliminates huge chunks of coding for the developer, making the process much more efficient and streamlined. It’s mostly maintained by Google and a wide network of users. Angular 2 is the latest version of the framework, first released in September 2014.
Full details Code an Angular2 Project with an Online IDE Learn to code with TypeScript and use it’s data typing features Understand and use Angular2’s Component paradigm Use Angular2’s powerful data binding features Use Angular2’s improved Pipes to transform displayed data Implement Interfaces in Angular2 Compose Components with Angular2’s Component Nesting capabilities Implement Services in an Angular2 application Use Dependency Injection to keep an Angular2 application lean Integrate with Web Services using Reactive Extension’s Observables Implement Routing in Angular2 Understand what Angular2 is, and how it can help you as a developer … and much, much more!
Full details This course was built for web developers who design and build UI/UX solutions for mobile and the web. This course is designed for those developers who want to design with Angular2 as easily as they can with other JavaScript frameworks. Of course, the info presented here is just as valuable for architects, testers, and product managers as they too should understand how Angular2 is designed and used in a complete web solution.
Full details
Reviews:
“Great lessons. On the downside, the colors sometimes do look weird. Like saturated green or face looking orangish. Sometimes the camera changes focus when the presenter is on the screen. Kind of distracting. These are minor irritations. Otherwise great lessons. Nice examples.” (Narayanan AM)
“A really useful course in which you will learn a lot of different concepts, to end up with a solid view of Angular 2 platform.” (Mario Prieto)
“- 1 point for teaching angular beta version and demanding 100$ for it – 1 point for not working gulp task – i had to correct it myself When it’s about course content – it was very good. Routing / http / filters / services / components / bindings – all of these concepts are covered – great work. Also a very good explanation of project technical files was useful (tsconfig / typings / package.json and so on). Thanks.” (Tomek.Szewcow)
About Instructor:
Stone River eLearning
At Stone River eLearning, technology is all we teach. If you’re interested in programming, development or design – we have it covered. Check out our huge catalog of courses and join the over 370,000 students currently taking Stone River eLearning courses. We currently offer 100+ different technology training courses on our Stone River eLearning website and are adding new courses on hot and trending topics every month. A subscription option is available for those with a real passion for learning.
Instructor Other Courses:
Python BeautifulSoup Stone River eLearning, 200,000+ Happy Udemy Students (0) $10 $50 Learn iPython: The Full Python IDE Python NumPy: Scientific computing with Python …………………………………………………………… Stone River eLearning coupons Development course coupon Udemy Development course coupon Web Development course coupon Udemy Web Development course coupon Angular 2 Crash Course with TypeScript Angular 2 Crash Course with TypeScript course coupon Angular 2 Crash Course with TypeScript coupon coupons
The post 90% off #Angular 2 Crash Course with TypeScript – $10 appeared first on Udemy Cupón/ Udemy Coupon/.
from Udemy Cupón/ Udemy Coupon/ http://coursetag.com/udemy/coupon/90-off-angular-2-crash-course-with-typescript-10/ from Course Tag https://coursetagcom.tumblr.com/post/156391969688
0 notes
Link
One of the most important things which is also often neglected by developers - the performance. One of the key focus area for the 1.0 release was making it blazingly fast ⚡
TypeGraphQL is basically an abstraction layer built on top of the reference GraphQL implementation for JavaScript - graphql-js. To measure the overhead of the abstraction, a few demo examples were made to compare it against the "bare metal" - using raw graphql-js library.
It turned out that in the most demanding cases like returning an array of 25 000 nested objects, the old version 0.17 was even about 5 times slower!
library execution time TypeGraphQL v0.17 1253.28 ms graphql-js 265.52 ms
After profiling the code and finding all the root causes (like always using async execution path), the overhead was reduced from 500% to just 17% in v1.0.0! By using simpleResolvers it can be reduced even further, up to 13%:
execution time graphql-js 265.52 ms TypeGraphQL v1.0 310.36 ms with "simpleResolvers" 299.61 ms with a global middleware 1267.82 ms
Such small overhead is much easier to accept than the initial 500%! More info about how to enable the performance optimizations in the more complex cases can be found in the docs 📖.
Schema isolation
This is another feature that is not visible from the first sight but gives new possibilities like splitting the schema to public and private ones 👀
In 0.17.x and before, the schema was built from all the metadata collected by evaluating the TypeGraphQL decorators. The drawback of this approach was the schema leaks - every subsequent calls of buildSchema was returning the same schema which was combined from all the types and resolvers that could be find in the metadata storage.
In TypeGraphQL 1.0 it's no longer true! The schemas are now isolated which means that the buildSchema call takes theresolvers array from options and emit only the queries, mutation and types that are related to those resolvers.
const firstSchema = await buildSchema({ resolvers: [FirstResolver], }); const secondSchema = await buildSchema({ resolvers: [SecondResolver], });
So just by modifying the resolvers option we can have different sets of operations exposed in the GraphQL schemas! Proper isolation also makes serverless development easier as it allows to get rid of the "Schema must contain uniquely named types" errors and others.
Directives and extensions
This two new features are two complementary ways to put some metadata about the schema items.
GraphQL directives though the syntax might remind the TS decorators, as "a directive is an identifier preceded by a @ character", but in fact, they are a purely Schema Definition Language feature. Apart from the metadata capabilities, they can also modify the schema and e.g. generate the connection type for pagination purposes. Basically, the looks like this:
type Query { foobar: String! @auth(requires: USER) }
To apply them, we just need to put the @Directive decorator above and supply the string argument, e.g.:
@Resolver() class FooBarResolver { @Directive("@auth(requires: USER)") @Query() foobar(): string { return "foobar"; } }
However, on the other side we have the GraphQL extensions which are the JS way to achieve the same goal. It's the recommended way of putting the metadata about the types when applying some custom logic.
To declare the extensions for type or selected field, we need to use @Extensionsdecorator, e.g.:
@ObjectType() class Foo { @Extensions({ roles: [Role.User] }) @Field() bar: string; }
We can then read that metadata in the resolvers or middlewares, just by exploring the GraphQLResolveInfo object, e.g.:
export const ExtensionsMiddleware: MiddlewareFn = async ({ info }, next) => { const { extensions } = info.parentType.getFields()[info.fieldName]; console.log(extensions?.roles); // log the metadata return next(); };
More info about directives and extensions features can be found in docs 📖
Resolvers and arguments for interface fields
The last thing that was preventing TypeGraphQL from being fully GraphQL compliant thus blocking the 1.0 release - an ability to provide interface fields resolvers implementations and declare its arguments.
Basically, we can define resolvers for the interface fields using the same syntax we would use in case of the @ObjectType, e.g.:
@InterfaceType() abstract class IPerson { @Field() avatar(@Arg("size") size: number): string { return `http://i.pravatar.cc/${size}`; } }
...with only a few exceptions for cases like abstract methods and inheritance, which you can read about in the docs.
More descriptive errors messages
One of the most irritating issues for newcomers were the laconic error messages that haven't provided enough info to easily find the mistakes in the code.
Messages like "Cannot determine GraphQL input type for users" or even the a generic "Generating schema error" were clearly not helpful enough while searching for the place where the flaws were located.
Now, when the error occurs, it is broadly explained, why it happened and what could we do to fix that, e.g.:
Unable to infer GraphQL type from TypeScript reflection system. You need to provide explicit type for argument named 'filter' of 'getUsers' of 'UserResolver' class.
or:
Some errors occurred while generating GraphQL schema: Interface field 'IUser.accountBalance' expects type 'String!' but 'Student.accountBalance' is of type 'Float'
That should allow developers to safe tons of time and really speed up the development 🏎
Transforming nested inputs and arrays
In the previous releases, an instance of the input type class was created only on the first level of inputs nesting. So, in cases like this:
@InputType() class SampleInput { @Field() sampleStringField: string; @Field() nestedField: SomeNestedInput; } @Resolver() class SampleResolver { @Query() sampleQuery(@Arg("input") input: SampleInput): boolean { return input.nestedField instanceof SomeNestedInput; } }
the nestedField property of input was just a plain Object, not an instance of the SomeNestedInput class. That behavior was producing some unwanted issues, including limited support for inputs and args validation.
Since 1.0 release, it's no longer an issue and all the nested args and inputs are properly transformed to the corresponding input type classes instances, even including deeply nested arrays
0 notes