graphql-subscriptions-fetcher-client.js 420 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515
  1. var GraphiQLSubscriptionsFetcher =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/
  6. /******/ // The require function
  7. /******/ function __webpack_require__(moduleId) {
  8. /******/
  9. /******/ // Check if module is in cache
  10. /******/ if(installedModules[moduleId])
  11. /******/ return installedModules[moduleId].exports;
  12. /******/
  13. /******/ // Create a new module (and put it into the cache)
  14. /******/ var module = installedModules[moduleId] = {
  15. /******/ i: moduleId,
  16. /******/ l: false,
  17. /******/ exports: {}
  18. /******/ };
  19. /******/
  20. /******/ // Execute the module function
  21. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22. /******/
  23. /******/ // Flag the module as loaded
  24. /******/ module.l = true;
  25. /******/
  26. /******/ // Return the exports of the module
  27. /******/ return module.exports;
  28. /******/ }
  29. /******/
  30. /******/
  31. /******/ // expose the modules object (__webpack_modules__)
  32. /******/ __webpack_require__.m = modules;
  33. /******/
  34. /******/ // expose the module cache
  35. /******/ __webpack_require__.c = installedModules;
  36. /******/
  37. /******/ // identity function for calling harmony imports with the correct context
  38. /******/ __webpack_require__.i = function(value) { return value; };
  39. /******/
  40. /******/ // define getter function for harmony exports
  41. /******/ __webpack_require__.d = function(exports, name, getter) {
  42. /******/ if(!__webpack_require__.o(exports, name)) {
  43. /******/ Object.defineProperty(exports, name, {
  44. /******/ configurable: false,
  45. /******/ enumerable: true,
  46. /******/ get: getter
  47. /******/ });
  48. /******/ }
  49. /******/ };
  50. /******/
  51. /******/ // getDefaultExport function for compatibility with non-harmony modules
  52. /******/ __webpack_require__.n = function(module) {
  53. /******/ var getter = module && module.__esModule ?
  54. /******/ function getDefault() { return module['default']; } :
  55. /******/ function getModuleExports() { return module; };
  56. /******/ __webpack_require__.d(getter, 'a', getter);
  57. /******/ return getter;
  58. /******/ };
  59. /******/
  60. /******/ // Object.prototype.hasOwnProperty.call
  61. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  62. /******/
  63. /******/ // __webpack_public_path__
  64. /******/ __webpack_require__.p = "";
  65. /******/
  66. /******/ // Load entry module and return exports
  67. /******/ return __webpack_require__(__webpack_require__.s = 37);
  68. /******/ })
  69. /************************************************************************/
  70. /******/ ([
  71. /* 0 */
  72. /***/ (function(module, exports, __webpack_require__) {
  73. "use strict";
  74. Object.defineProperty(exports, "__esModule", {
  75. value: true
  76. });
  77. var _GraphQLError = __webpack_require__(13);
  78. Object.defineProperty(exports, 'GraphQLError', {
  79. enumerable: true,
  80. get: function get() {
  81. return _GraphQLError.GraphQLError;
  82. }
  83. });
  84. var _syntaxError = __webpack_require__(40);
  85. Object.defineProperty(exports, 'syntaxError', {
  86. enumerable: true,
  87. get: function get() {
  88. return _syntaxError.syntaxError;
  89. }
  90. });
  91. var _locatedError = __webpack_require__(39);
  92. Object.defineProperty(exports, 'locatedError', {
  93. enumerable: true,
  94. get: function get() {
  95. return _locatedError.locatedError;
  96. }
  97. });
  98. var _formatError = __webpack_require__(38);
  99. Object.defineProperty(exports, 'formatError', {
  100. enumerable: true,
  101. get: function get() {
  102. return _formatError.formatError;
  103. }
  104. });
  105. /***/ }),
  106. /* 1 */
  107. /***/ (function(module, exports, __webpack_require__) {
  108. "use strict";
  109. Object.defineProperty(exports, "__esModule", {
  110. value: true
  111. });
  112. exports.GraphQLNonNull = exports.GraphQLList = exports.GraphQLInputObjectType = exports.GraphQLEnumType = exports.GraphQLUnionType = exports.GraphQLInterfaceType = exports.GraphQLObjectType = exports.GraphQLScalarType = undefined;
  113. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  114. exports.isType = isType;
  115. exports.assertType = assertType;
  116. exports.isInputType = isInputType;
  117. exports.assertInputType = assertInputType;
  118. exports.isOutputType = isOutputType;
  119. exports.assertOutputType = assertOutputType;
  120. exports.isLeafType = isLeafType;
  121. exports.assertLeafType = assertLeafType;
  122. exports.isCompositeType = isCompositeType;
  123. exports.assertCompositeType = assertCompositeType;
  124. exports.isAbstractType = isAbstractType;
  125. exports.assertAbstractType = assertAbstractType;
  126. exports.getNullableType = getNullableType;
  127. exports.isNamedType = isNamedType;
  128. exports.assertNamedType = assertNamedType;
  129. exports.getNamedType = getNamedType;
  130. var _invariant = __webpack_require__(3);
  131. var _invariant2 = _interopRequireDefault(_invariant);
  132. var _isNullish = __webpack_require__(6);
  133. var _isNullish2 = _interopRequireDefault(_isNullish);
  134. var _kinds = __webpack_require__(2);
  135. var _assertValidName = __webpack_require__(28);
  136. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  137. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  138. /**
  139. * Copyright (c) 2015, Facebook, Inc.
  140. * All rights reserved.
  141. *
  142. * This source code is licensed under the BSD-style license found in the
  143. * LICENSE file in the root directory of this source tree. An additional grant
  144. * of patent rights can be found in the PATENTS file in the same directory.
  145. */
  146. // Predicates & Assertions
  147. /**
  148. * These are all of the possible kinds of types.
  149. */
  150. function isType(type) {
  151. return type instanceof GraphQLScalarType || type instanceof GraphQLObjectType || type instanceof GraphQLInterfaceType || type instanceof GraphQLUnionType || type instanceof GraphQLEnumType || type instanceof GraphQLInputObjectType || type instanceof GraphQLList || type instanceof GraphQLNonNull;
  152. }
  153. function assertType(type) {
  154. (0, _invariant2.default)(isType(type), 'Expected ' + String(type) + ' to be a GraphQL type.');
  155. return type;
  156. }
  157. /**
  158. * These types may be used as input types for arguments and directives.
  159. */
  160. function isInputType(type) {
  161. var namedType = getNamedType(type);
  162. return namedType instanceof GraphQLScalarType || namedType instanceof GraphQLEnumType || namedType instanceof GraphQLInputObjectType;
  163. }
  164. function assertInputType(type) {
  165. (0, _invariant2.default)(isInputType(type), 'Expected ' + String(type) + ' to be a GraphQL input type.');
  166. return type;
  167. }
  168. /**
  169. * These types may be used as output types as the result of fields.
  170. */
  171. function isOutputType(type) {
  172. var namedType = getNamedType(type);
  173. return namedType instanceof GraphQLScalarType || namedType instanceof GraphQLObjectType || namedType instanceof GraphQLInterfaceType || namedType instanceof GraphQLUnionType || namedType instanceof GraphQLEnumType;
  174. }
  175. function assertOutputType(type) {
  176. (0, _invariant2.default)(isOutputType(type), 'Expected ' + String(type) + ' to be a GraphQL output type.');
  177. return type;
  178. }
  179. /**
  180. * These types may describe types which may be leaf values.
  181. */
  182. function isLeafType(type) {
  183. var namedType = getNamedType(type);
  184. return namedType instanceof GraphQLScalarType || namedType instanceof GraphQLEnumType;
  185. }
  186. function assertLeafType(type) {
  187. (0, _invariant2.default)(isLeafType(type), 'Expected ' + String(type) + ' to be a GraphQL leaf type.');
  188. return type;
  189. }
  190. /**
  191. * These types may describe the parent context of a selection set.
  192. */
  193. function isCompositeType(type) {
  194. return type instanceof GraphQLObjectType || type instanceof GraphQLInterfaceType || type instanceof GraphQLUnionType;
  195. }
  196. function assertCompositeType(type) {
  197. (0, _invariant2.default)(isCompositeType(type), 'Expected ' + String(type) + ' to be a GraphQL composite type.');
  198. return type;
  199. }
  200. /**
  201. * These types may describe the parent context of a selection set.
  202. */
  203. function isAbstractType(type) {
  204. return type instanceof GraphQLInterfaceType || type instanceof GraphQLUnionType;
  205. }
  206. function assertAbstractType(type) {
  207. (0, _invariant2.default)(isAbstractType(type), 'Expected ' + String(type) + ' to be a GraphQL abstract type.');
  208. return type;
  209. }
  210. /**
  211. * These types can all accept null as a value.
  212. */
  213. function getNullableType(type) {
  214. return type instanceof GraphQLNonNull ? type.ofType : type;
  215. }
  216. /**
  217. * These named types do not include modifiers like List or NonNull.
  218. */
  219. function isNamedType(type) {
  220. return type instanceof GraphQLScalarType || type instanceof GraphQLObjectType || type instanceof GraphQLInterfaceType || type instanceof GraphQLUnionType || type instanceof GraphQLEnumType || type instanceof GraphQLInputObjectType;
  221. }
  222. function assertNamedType(type) {
  223. (0, _invariant2.default)(isNamedType(type), 'Expected ' + String(type) + ' to be a GraphQL named type.');
  224. return type;
  225. }
  226. function getNamedType(type) {
  227. var unmodifiedType = type;
  228. while (unmodifiedType instanceof GraphQLList || unmodifiedType instanceof GraphQLNonNull) {
  229. unmodifiedType = unmodifiedType.ofType;
  230. }
  231. return unmodifiedType;
  232. }
  233. /**
  234. * Used while defining GraphQL types to allow for circular references in
  235. * otherwise immutable type definitions.
  236. */
  237. function resolveThunk(thunk) {
  238. return typeof thunk === 'function' ? thunk() : thunk;
  239. }
  240. /**
  241. * Scalar Type Definition
  242. *
  243. * The leaf values of any request and input values to arguments are
  244. * Scalars (or Enums) and are defined with a name and a series of functions
  245. * used to parse input from ast or variables and to ensure validity.
  246. *
  247. * Example:
  248. *
  249. * const OddType = new GraphQLScalarType({
  250. * name: 'Odd',
  251. * serialize(value) {
  252. * return value % 2 === 1 ? value : null;
  253. * }
  254. * });
  255. *
  256. */
  257. var GraphQLScalarType = exports.GraphQLScalarType = function () {
  258. function GraphQLScalarType(config) {
  259. _classCallCheck(this, GraphQLScalarType);
  260. (0, _assertValidName.assertValidName)(config.name);
  261. this.name = config.name;
  262. this.description = config.description;
  263. (0, _invariant2.default)(typeof config.serialize === 'function', this.name + ' must provide "serialize" function. If this custom Scalar ' + 'is also used as an input type, ensure "parseValue" and "parseLiteral" ' + 'functions are also provided.');
  264. if (config.parseValue || config.parseLiteral) {
  265. (0, _invariant2.default)(typeof config.parseValue === 'function' && typeof config.parseLiteral === 'function', this.name + ' must provide both "parseValue" and "parseLiteral" ' + 'functions.');
  266. }
  267. this._scalarConfig = config;
  268. }
  269. // Serializes an internal value to include in a response.
  270. GraphQLScalarType.prototype.serialize = function serialize(value) {
  271. var serializer = this._scalarConfig.serialize;
  272. return serializer(value);
  273. };
  274. // Parses an externally provided value to use as an input.
  275. GraphQLScalarType.prototype.parseValue = function parseValue(value) {
  276. var parser = this._scalarConfig.parseValue;
  277. return parser ? parser(value) : null;
  278. };
  279. // Parses an externally provided literal value to use as an input.
  280. GraphQLScalarType.prototype.parseLiteral = function parseLiteral(valueNode) {
  281. var parser = this._scalarConfig.parseLiteral;
  282. return parser ? parser(valueNode) : null;
  283. };
  284. GraphQLScalarType.prototype.toString = function toString() {
  285. return this.name;
  286. };
  287. return GraphQLScalarType;
  288. }();
  289. // Also provide toJSON and inspect aliases for toString.
  290. GraphQLScalarType.prototype.toJSON = GraphQLScalarType.prototype.inspect = GraphQLScalarType.prototype.toString;
  291. /**
  292. * Object Type Definition
  293. *
  294. * Almost all of the GraphQL types you define will be object types. Object types
  295. * have a name, but most importantly describe their fields.
  296. *
  297. * Example:
  298. *
  299. * const AddressType = new GraphQLObjectType({
  300. * name: 'Address',
  301. * fields: {
  302. * street: { type: GraphQLString },
  303. * number: { type: GraphQLInt },
  304. * formatted: {
  305. * type: GraphQLString,
  306. * resolve(obj) {
  307. * return obj.number + ' ' + obj.street
  308. * }
  309. * }
  310. * }
  311. * });
  312. *
  313. * When two types need to refer to each other, or a type needs to refer to
  314. * itself in a field, you can use a function expression (aka a closure or a
  315. * thunk) to supply the fields lazily.
  316. *
  317. * Example:
  318. *
  319. * const PersonType = new GraphQLObjectType({
  320. * name: 'Person',
  321. * fields: () => ({
  322. * name: { type: GraphQLString },
  323. * bestFriend: { type: PersonType },
  324. * })
  325. * });
  326. *
  327. */
  328. var GraphQLObjectType = exports.GraphQLObjectType = function () {
  329. function GraphQLObjectType(config) {
  330. _classCallCheck(this, GraphQLObjectType);
  331. (0, _assertValidName.assertValidName)(config.name, config.isIntrospection);
  332. this.name = config.name;
  333. this.description = config.description;
  334. if (config.isTypeOf) {
  335. (0, _invariant2.default)(typeof config.isTypeOf === 'function', this.name + ' must provide "isTypeOf" as a function.');
  336. }
  337. this.isTypeOf = config.isTypeOf;
  338. this._typeConfig = config;
  339. }
  340. GraphQLObjectType.prototype.getFields = function getFields() {
  341. return this._fields || (this._fields = defineFieldMap(this, this._typeConfig.fields));
  342. };
  343. GraphQLObjectType.prototype.getInterfaces = function getInterfaces() {
  344. return this._interfaces || (this._interfaces = defineInterfaces(this, this._typeConfig.interfaces));
  345. };
  346. GraphQLObjectType.prototype.toString = function toString() {
  347. return this.name;
  348. };
  349. return GraphQLObjectType;
  350. }();
  351. // Also provide toJSON and inspect aliases for toString.
  352. GraphQLObjectType.prototype.toJSON = GraphQLObjectType.prototype.inspect = GraphQLObjectType.prototype.toString;
  353. function defineInterfaces(type, interfacesThunk) {
  354. var interfaces = resolveThunk(interfacesThunk);
  355. if (!interfaces) {
  356. return [];
  357. }
  358. (0, _invariant2.default)(Array.isArray(interfaces), type.name + ' interfaces must be an Array or a function which returns ' + 'an Array.');
  359. interfaces.forEach(function (iface) {
  360. (0, _invariant2.default)(iface instanceof GraphQLInterfaceType, type.name + ' may only implement Interface types, it cannot ' + ('implement: ' + String(iface) + '.'));
  361. if (typeof iface.resolveType !== 'function') {
  362. (0, _invariant2.default)(typeof type.isTypeOf === 'function', 'Interface Type ' + iface.name + ' does not provide a "resolveType" ' + ('function and implementing Type ' + type.name + ' does not provide a ') + '"isTypeOf" function. There is no way to resolve this implementing ' + 'type during execution.');
  363. }
  364. });
  365. return interfaces;
  366. }
  367. function defineFieldMap(type, fieldsThunk) {
  368. var fieldMap = resolveThunk(fieldsThunk);
  369. (0, _invariant2.default)(isPlainObj(fieldMap), type.name + ' fields must be an object with field names as keys or a ' + 'function which returns such an object.');
  370. var fieldNames = Object.keys(fieldMap);
  371. (0, _invariant2.default)(fieldNames.length > 0, type.name + ' fields must be an object with field names as keys or a ' + 'function which returns such an object.');
  372. var resultFieldMap = {};
  373. fieldNames.forEach(function (fieldName) {
  374. (0, _assertValidName.assertValidName)(fieldName);
  375. var fieldConfig = fieldMap[fieldName];
  376. (0, _invariant2.default)(!fieldConfig.hasOwnProperty('isDeprecated'), type.name + '.' + fieldName + ' should provide "deprecationReason" instead ' + 'of "isDeprecated".');
  377. var field = _extends({}, fieldConfig, {
  378. isDeprecated: Boolean(fieldConfig.deprecationReason),
  379. name: fieldName
  380. });
  381. (0, _invariant2.default)(isOutputType(field.type), type.name + '.' + fieldName + ' field type must be Output Type but ' + ('got: ' + String(field.type) + '.'));
  382. (0, _invariant2.default)(isValidResolver(field.resolve), type.name + '.' + fieldName + ' field resolver must be a function if ' + ('provided, but got: ' + String(field.resolve) + '.'));
  383. var argsConfig = fieldConfig.args;
  384. if (!argsConfig) {
  385. field.args = [];
  386. } else {
  387. (0, _invariant2.default)(isPlainObj(argsConfig), type.name + '.' + fieldName + ' args must be an object with argument ' + 'names as keys.');
  388. field.args = Object.keys(argsConfig).map(function (argName) {
  389. (0, _assertValidName.assertValidName)(argName);
  390. var arg = argsConfig[argName];
  391. (0, _invariant2.default)(isInputType(arg.type), type.name + '.' + fieldName + '(' + argName + ':) argument type must be ' + ('Input Type but got: ' + String(arg.type) + '.'));
  392. return {
  393. name: argName,
  394. description: arg.description === undefined ? null : arg.description,
  395. type: arg.type,
  396. defaultValue: arg.defaultValue
  397. };
  398. });
  399. }
  400. resultFieldMap[fieldName] = field;
  401. });
  402. return resultFieldMap;
  403. }
  404. function isPlainObj(obj) {
  405. return obj && typeof obj === 'object' && !Array.isArray(obj);
  406. }
  407. // If a resolver is defined, it must be a function.
  408. function isValidResolver(resolver) {
  409. return resolver == null || typeof resolver === 'function';
  410. }
  411. /**
  412. * Interface Type Definition
  413. *
  414. * When a field can return one of a heterogeneous set of types, a Interface type
  415. * is used to describe what types are possible, what fields are in common across
  416. * all types, as well as a function to determine which type is actually used
  417. * when the field is resolved.
  418. *
  419. * Example:
  420. *
  421. * const EntityType = new GraphQLInterfaceType({
  422. * name: 'Entity',
  423. * fields: {
  424. * name: { type: GraphQLString }
  425. * }
  426. * });
  427. *
  428. */
  429. var GraphQLInterfaceType = exports.GraphQLInterfaceType = function () {
  430. function GraphQLInterfaceType(config) {
  431. _classCallCheck(this, GraphQLInterfaceType);
  432. (0, _assertValidName.assertValidName)(config.name);
  433. this.name = config.name;
  434. this.description = config.description;
  435. if (config.resolveType) {
  436. (0, _invariant2.default)(typeof config.resolveType === 'function', this.name + ' must provide "resolveType" as a function.');
  437. }
  438. this.resolveType = config.resolveType;
  439. this._typeConfig = config;
  440. }
  441. GraphQLInterfaceType.prototype.getFields = function getFields() {
  442. return this._fields || (this._fields = defineFieldMap(this, this._typeConfig.fields));
  443. };
  444. GraphQLInterfaceType.prototype.toString = function toString() {
  445. return this.name;
  446. };
  447. return GraphQLInterfaceType;
  448. }();
  449. // Also provide toJSON and inspect aliases for toString.
  450. GraphQLInterfaceType.prototype.toJSON = GraphQLInterfaceType.prototype.inspect = GraphQLInterfaceType.prototype.toString;
  451. /**
  452. * Union Type Definition
  453. *
  454. * When a field can return one of a heterogeneous set of types, a Union type
  455. * is used to describe what types are possible as well as providing a function
  456. * to determine which type is actually used when the field is resolved.
  457. *
  458. * Example:
  459. *
  460. * const PetType = new GraphQLUnionType({
  461. * name: 'Pet',
  462. * types: [ DogType, CatType ],
  463. * resolveType(value) {
  464. * if (value instanceof Dog) {
  465. * return DogType;
  466. * }
  467. * if (value instanceof Cat) {
  468. * return CatType;
  469. * }
  470. * }
  471. * });
  472. *
  473. */
  474. var GraphQLUnionType = exports.GraphQLUnionType = function () {
  475. function GraphQLUnionType(config) {
  476. _classCallCheck(this, GraphQLUnionType);
  477. (0, _assertValidName.assertValidName)(config.name);
  478. this.name = config.name;
  479. this.description = config.description;
  480. if (config.resolveType) {
  481. (0, _invariant2.default)(typeof config.resolveType === 'function', this.name + ' must provide "resolveType" as a function.');
  482. }
  483. this.resolveType = config.resolveType;
  484. this._typeConfig = config;
  485. }
  486. GraphQLUnionType.prototype.getTypes = function getTypes() {
  487. return this._types || (this._types = defineTypes(this, this._typeConfig.types));
  488. };
  489. GraphQLUnionType.prototype.toString = function toString() {
  490. return this.name;
  491. };
  492. return GraphQLUnionType;
  493. }();
  494. // Also provide toJSON and inspect aliases for toString.
  495. GraphQLUnionType.prototype.toJSON = GraphQLUnionType.prototype.inspect = GraphQLUnionType.prototype.toString;
  496. function defineTypes(unionType, typesThunk) {
  497. var types = resolveThunk(typesThunk);
  498. (0, _invariant2.default)(Array.isArray(types) && types.length > 0, 'Must provide Array of types or a function which returns ' + ('such an array for Union ' + unionType.name + '.'));
  499. types.forEach(function (objType) {
  500. (0, _invariant2.default)(objType instanceof GraphQLObjectType, unionType.name + ' may only contain Object types, it cannot contain: ' + (String(objType) + '.'));
  501. if (typeof unionType.resolveType !== 'function') {
  502. (0, _invariant2.default)(typeof objType.isTypeOf === 'function', 'Union type "' + unionType.name + '" does not provide a "resolveType" ' + ('function and possible type "' + objType.name + '" does not provide an ') + '"isTypeOf" function. There is no way to resolve this possible type ' + 'during execution.');
  503. }
  504. });
  505. return types;
  506. }
  507. /**
  508. * Enum Type Definition
  509. *
  510. * Some leaf values of requests and input values are Enums. GraphQL serializes
  511. * Enum values as strings, however internally Enums can be represented by any
  512. * kind of type, often integers.
  513. *
  514. * Example:
  515. *
  516. * const RGBType = new GraphQLEnumType({
  517. * name: 'RGB',
  518. * values: {
  519. * RED: { value: 0 },
  520. * GREEN: { value: 1 },
  521. * BLUE: { value: 2 }
  522. * }
  523. * });
  524. *
  525. * Note: If a value is not provided in a definition, the name of the enum value
  526. * will be used as its internal value.
  527. */
  528. var GraphQLEnumType /* <T> */ = exports.GraphQLEnumType = function () {
  529. function GraphQLEnumType(config /* <T> */) {
  530. _classCallCheck(this, GraphQLEnumType);
  531. this.name = config.name;
  532. (0, _assertValidName.assertValidName)(config.name, config.isIntrospection);
  533. this.description = config.description;
  534. this._values = defineEnumValues(this, config.values);
  535. this._enumConfig = config;
  536. }
  537. GraphQLEnumType.prototype.getValues = function getValues() {
  538. return this._values;
  539. };
  540. GraphQLEnumType.prototype.getValue = function getValue(name) {
  541. return this._getNameLookup()[name];
  542. };
  543. GraphQLEnumType.prototype.serialize = function serialize(value /* T */) {
  544. var enumValue = this._getValueLookup().get(value);
  545. return enumValue ? enumValue.name : null;
  546. };
  547. GraphQLEnumType.prototype.parseValue = function parseValue(value) /* T */{
  548. if (typeof value === 'string') {
  549. var enumValue = this._getNameLookup()[value];
  550. if (enumValue) {
  551. return enumValue.value;
  552. }
  553. }
  554. };
  555. GraphQLEnumType.prototype.parseLiteral = function parseLiteral(valueNode) /* T */{
  556. if (valueNode.kind === _kinds.ENUM) {
  557. var enumValue = this._getNameLookup()[valueNode.value];
  558. if (enumValue) {
  559. return enumValue.value;
  560. }
  561. }
  562. };
  563. GraphQLEnumType.prototype._getValueLookup = function _getValueLookup() {
  564. var _this = this;
  565. if (!this._valueLookup) {
  566. (function () {
  567. var lookup = new Map();
  568. _this.getValues().forEach(function (value) {
  569. lookup.set(value.value, value);
  570. });
  571. _this._valueLookup = lookup;
  572. })();
  573. }
  574. return this._valueLookup;
  575. };
  576. GraphQLEnumType.prototype._getNameLookup = function _getNameLookup() {
  577. var _this2 = this;
  578. if (!this._nameLookup) {
  579. (function () {
  580. var lookup = Object.create(null);
  581. _this2.getValues().forEach(function (value) {
  582. lookup[value.name] = value;
  583. });
  584. _this2._nameLookup = lookup;
  585. })();
  586. }
  587. return this._nameLookup;
  588. };
  589. GraphQLEnumType.prototype.toString = function toString() {
  590. return this.name;
  591. };
  592. return GraphQLEnumType;
  593. }();
  594. // Also provide toJSON and inspect aliases for toString.
  595. GraphQLEnumType.prototype.toJSON = GraphQLEnumType.prototype.inspect = GraphQLEnumType.prototype.toString;
  596. function defineEnumValues(type, valueMap /* <T> */
  597. ) {
  598. (0, _invariant2.default)(isPlainObj(valueMap), type.name + ' values must be an object with value names as keys.');
  599. var valueNames = Object.keys(valueMap);
  600. (0, _invariant2.default)(valueNames.length > 0, type.name + ' values must be an object with value names as keys.');
  601. return valueNames.map(function (valueName) {
  602. (0, _assertValidName.assertValidName)(valueName);
  603. var value = valueMap[valueName];
  604. (0, _invariant2.default)(isPlainObj(value), type.name + '.' + valueName + ' must refer to an object with a "value" key ' + ('representing an internal value but got: ' + String(value) + '.'));
  605. (0, _invariant2.default)(!value.hasOwnProperty('isDeprecated'), type.name + '.' + valueName + ' should provide "deprecationReason" instead ' + 'of "isDeprecated".');
  606. return {
  607. name: valueName,
  608. description: value.description,
  609. isDeprecated: Boolean(value.deprecationReason),
  610. deprecationReason: value.deprecationReason,
  611. value: (0, _isNullish2.default)(value.value) ? valueName : value.value
  612. };
  613. });
  614. } /* <T> */
  615. /**
  616. * Input Object Type Definition
  617. *
  618. * An input object defines a structured collection of fields which may be
  619. * supplied to a field argument.
  620. *
  621. * Using `NonNull` will ensure that a value must be provided by the query
  622. *
  623. * Example:
  624. *
  625. * const GeoPoint = new GraphQLInputObjectType({
  626. * name: 'GeoPoint',
  627. * fields: {
  628. * lat: { type: new GraphQLNonNull(GraphQLFloat) },
  629. * lon: { type: new GraphQLNonNull(GraphQLFloat) },
  630. * alt: { type: GraphQLFloat, defaultValue: 0 },
  631. * }
  632. * });
  633. *
  634. */
  635. var GraphQLInputObjectType = exports.GraphQLInputObjectType = function () {
  636. function GraphQLInputObjectType(config) {
  637. _classCallCheck(this, GraphQLInputObjectType);
  638. (0, _assertValidName.assertValidName)(config.name);
  639. this.name = config.name;
  640. this.description = config.description;
  641. this._typeConfig = config;
  642. }
  643. GraphQLInputObjectType.prototype.getFields = function getFields() {
  644. return this._fields || (this._fields = this._defineFieldMap());
  645. };
  646. GraphQLInputObjectType.prototype._defineFieldMap = function _defineFieldMap() {
  647. var _this3 = this;
  648. var fieldMap = resolveThunk(this._typeConfig.fields);
  649. (0, _invariant2.default)(isPlainObj(fieldMap), this.name + ' fields must be an object with field names as keys or a ' + 'function which returns such an object.');
  650. var fieldNames = Object.keys(fieldMap);
  651. (0, _invariant2.default)(fieldNames.length > 0, this.name + ' fields must be an object with field names as keys or a ' + 'function which returns such an object.');
  652. var resultFieldMap = {};
  653. fieldNames.forEach(function (fieldName) {
  654. (0, _assertValidName.assertValidName)(fieldName);
  655. var field = _extends({}, fieldMap[fieldName], {
  656. name: fieldName
  657. });
  658. (0, _invariant2.default)(isInputType(field.type), _this3.name + '.' + fieldName + ' field type must be Input Type but ' + ('got: ' + String(field.type) + '.'));
  659. (0, _invariant2.default)(field.resolve == null, _this3.name + '.' + fieldName + ' field type has a resolve property, but ' + 'Input Types cannot define resolvers.');
  660. resultFieldMap[fieldName] = field;
  661. });
  662. return resultFieldMap;
  663. };
  664. GraphQLInputObjectType.prototype.toString = function toString() {
  665. return this.name;
  666. };
  667. return GraphQLInputObjectType;
  668. }();
  669. // Also provide toJSON and inspect aliases for toString.
  670. GraphQLInputObjectType.prototype.toJSON = GraphQLInputObjectType.prototype.inspect = GraphQLInputObjectType.prototype.toString;
  671. /**
  672. * List Modifier
  673. *
  674. * A list is a kind of type marker, a wrapping type which points to another
  675. * type. Lists are often created within the context of defining the fields of
  676. * an object type.
  677. *
  678. * Example:
  679. *
  680. * const PersonType = new GraphQLObjectType({
  681. * name: 'Person',
  682. * fields: () => ({
  683. * parents: { type: new GraphQLList(Person) },
  684. * children: { type: new GraphQLList(Person) },
  685. * })
  686. * })
  687. *
  688. */
  689. var GraphQLList = exports.GraphQLList = function () {
  690. function GraphQLList(type) {
  691. _classCallCheck(this, GraphQLList);
  692. (0, _invariant2.default)(isType(type), 'Can only create List of a GraphQLType but got: ' + String(type) + '.');
  693. this.ofType = type;
  694. }
  695. GraphQLList.prototype.toString = function toString() {
  696. return '[' + String(this.ofType) + ']';
  697. };
  698. return GraphQLList;
  699. }();
  700. // Also provide toJSON and inspect aliases for toString.
  701. GraphQLList.prototype.toJSON = GraphQLList.prototype.inspect = GraphQLList.prototype.toString;
  702. /**
  703. * Non-Null Modifier
  704. *
  705. * A non-null is a kind of type marker, a wrapping type which points to another
  706. * type. Non-null types enforce that their values are never null and can ensure
  707. * an error is raised if this ever occurs during a request. It is useful for
  708. * fields which you can make a strong guarantee on non-nullability, for example
  709. * usually the id field of a database row will never be null.
  710. *
  711. * Example:
  712. *
  713. * const RowType = new GraphQLObjectType({
  714. * name: 'Row',
  715. * fields: () => ({
  716. * id: { type: new GraphQLNonNull(GraphQLString) },
  717. * })
  718. * })
  719. *
  720. * Note: the enforcement of non-nullability occurs within the executor.
  721. */
  722. var GraphQLNonNull = exports.GraphQLNonNull = function () {
  723. function GraphQLNonNull(type) {
  724. _classCallCheck(this, GraphQLNonNull);
  725. (0, _invariant2.default)(isType(type) && !(type instanceof GraphQLNonNull), 'Can only create NonNull of a Nullable GraphQLType but got: ' + (String(type) + '.'));
  726. this.ofType = type;
  727. }
  728. GraphQLNonNull.prototype.toString = function toString() {
  729. return this.ofType.toString() + '!';
  730. };
  731. return GraphQLNonNull;
  732. }();
  733. // Also provide toJSON and inspect aliases for toString.
  734. GraphQLNonNull.prototype.toJSON = GraphQLNonNull.prototype.inspect = GraphQLNonNull.prototype.toString;
  735. /***/ }),
  736. /* 2 */
  737. /***/ (function(module, exports, __webpack_require__) {
  738. "use strict";
  739. Object.defineProperty(exports, "__esModule", {
  740. value: true
  741. });
  742. /**
  743. * Copyright (c) 2015, Facebook, Inc.
  744. * All rights reserved.
  745. *
  746. * This source code is licensed under the BSD-style license found in the
  747. * LICENSE file in the root directory of this source tree. An additional grant
  748. * of patent rights can be found in the PATENTS file in the same directory.
  749. */
  750. // Name
  751. var NAME = exports.NAME = 'Name';
  752. // Document
  753. var DOCUMENT = exports.DOCUMENT = 'Document';
  754. var OPERATION_DEFINITION = exports.OPERATION_DEFINITION = 'OperationDefinition';
  755. var VARIABLE_DEFINITION = exports.VARIABLE_DEFINITION = 'VariableDefinition';
  756. var VARIABLE = exports.VARIABLE = 'Variable';
  757. var SELECTION_SET = exports.SELECTION_SET = 'SelectionSet';
  758. var FIELD = exports.FIELD = 'Field';
  759. var ARGUMENT = exports.ARGUMENT = 'Argument';
  760. // Fragments
  761. var FRAGMENT_SPREAD = exports.FRAGMENT_SPREAD = 'FragmentSpread';
  762. var INLINE_FRAGMENT = exports.INLINE_FRAGMENT = 'InlineFragment';
  763. var FRAGMENT_DEFINITION = exports.FRAGMENT_DEFINITION = 'FragmentDefinition';
  764. // Values
  765. var INT = exports.INT = 'IntValue';
  766. var FLOAT = exports.FLOAT = 'FloatValue';
  767. var STRING = exports.STRING = 'StringValue';
  768. var BOOLEAN = exports.BOOLEAN = 'BooleanValue';
  769. var NULL = exports.NULL = 'NullValue';
  770. var ENUM = exports.ENUM = 'EnumValue';
  771. var LIST = exports.LIST = 'ListValue';
  772. var OBJECT = exports.OBJECT = 'ObjectValue';
  773. var OBJECT_FIELD = exports.OBJECT_FIELD = 'ObjectField';
  774. // Directives
  775. var DIRECTIVE = exports.DIRECTIVE = 'Directive';
  776. // Types
  777. var NAMED_TYPE = exports.NAMED_TYPE = 'NamedType';
  778. var LIST_TYPE = exports.LIST_TYPE = 'ListType';
  779. var NON_NULL_TYPE = exports.NON_NULL_TYPE = 'NonNullType';
  780. // Type System Definitions
  781. var SCHEMA_DEFINITION = exports.SCHEMA_DEFINITION = 'SchemaDefinition';
  782. var OPERATION_TYPE_DEFINITION = exports.OPERATION_TYPE_DEFINITION = 'OperationTypeDefinition';
  783. // Type Definitions
  784. var SCALAR_TYPE_DEFINITION = exports.SCALAR_TYPE_DEFINITION = 'ScalarTypeDefinition';
  785. var OBJECT_TYPE_DEFINITION = exports.OBJECT_TYPE_DEFINITION = 'ObjectTypeDefinition';
  786. var FIELD_DEFINITION = exports.FIELD_DEFINITION = 'FieldDefinition';
  787. var INPUT_VALUE_DEFINITION = exports.INPUT_VALUE_DEFINITION = 'InputValueDefinition';
  788. var INTERFACE_TYPE_DEFINITION = exports.INTERFACE_TYPE_DEFINITION = 'InterfaceTypeDefinition';
  789. var UNION_TYPE_DEFINITION = exports.UNION_TYPE_DEFINITION = 'UnionTypeDefinition';
  790. var ENUM_TYPE_DEFINITION = exports.ENUM_TYPE_DEFINITION = 'EnumTypeDefinition';
  791. var ENUM_VALUE_DEFINITION = exports.ENUM_VALUE_DEFINITION = 'EnumValueDefinition';
  792. var INPUT_OBJECT_TYPE_DEFINITION = exports.INPUT_OBJECT_TYPE_DEFINITION = 'InputObjectTypeDefinition';
  793. // Type Extensions
  794. var TYPE_EXTENSION_DEFINITION = exports.TYPE_EXTENSION_DEFINITION = 'TypeExtensionDefinition';
  795. // Directive Definitions
  796. var DIRECTIVE_DEFINITION = exports.DIRECTIVE_DEFINITION = 'DirectiveDefinition';
  797. /***/ }),
  798. /* 3 */
  799. /***/ (function(module, exports, __webpack_require__) {
  800. "use strict";
  801. Object.defineProperty(exports, "__esModule", {
  802. value: true
  803. });
  804. exports.default = invariant;
  805. /**
  806. * Copyright (c) 2015, Facebook, Inc.
  807. * All rights reserved.
  808. *
  809. * This source code is licensed under the BSD-style license found in the
  810. * LICENSE file in the root directory of this source tree. An additional grant
  811. * of patent rights can be found in the PATENTS file in the same directory.
  812. */
  813. function invariant(condition, message) {
  814. if (!condition) {
  815. throw new Error(message);
  816. }
  817. }
  818. /***/ }),
  819. /* 4 */
  820. /***/ (function(module, exports, __webpack_require__) {
  821. "use strict";
  822. Object.defineProperty(exports, "__esModule", {
  823. value: true
  824. });
  825. exports.print = print;
  826. var _visitor = __webpack_require__(15);
  827. /**
  828. * Converts an AST into a string, using one set of reasonable
  829. * formatting rules.
  830. */
  831. function print(ast) {
  832. return (0, _visitor.visit)(ast, { leave: printDocASTReducer });
  833. } /**
  834. * Copyright (c) 2015, Facebook, Inc.
  835. * All rights reserved.
  836. *
  837. * This source code is licensed under the BSD-style license found in the
  838. * LICENSE file in the root directory of this source tree. An additional grant
  839. * of patent rights can be found in the PATENTS file in the same directory.
  840. */
  841. var printDocASTReducer = {
  842. Name: function Name(node) {
  843. return node.value;
  844. },
  845. Variable: function Variable(node) {
  846. return '$' + node.name;
  847. },
  848. // Document
  849. Document: function Document(node) {
  850. return join(node.definitions, '\n\n') + '\n';
  851. },
  852. OperationDefinition: function OperationDefinition(node) {
  853. var op = node.operation;
  854. var name = node.name;
  855. var varDefs = wrap('(', join(node.variableDefinitions, ', '), ')');
  856. var directives = join(node.directives, ' ');
  857. var selectionSet = node.selectionSet;
  858. // Anonymous queries with no directives or variable definitions can use
  859. // the query short form.
  860. return !name && !directives && !varDefs && op === 'query' ? selectionSet : join([op, join([name, varDefs]), directives, selectionSet], ' ');
  861. },
  862. VariableDefinition: function VariableDefinition(_ref) {
  863. var variable = _ref.variable,
  864. type = _ref.type,
  865. defaultValue = _ref.defaultValue;
  866. return variable + ': ' + type + wrap(' = ', defaultValue);
  867. },
  868. SelectionSet: function SelectionSet(_ref2) {
  869. var selections = _ref2.selections;
  870. return block(selections);
  871. },
  872. Field: function Field(_ref3) {
  873. var alias = _ref3.alias,
  874. name = _ref3.name,
  875. args = _ref3.arguments,
  876. directives = _ref3.directives,
  877. selectionSet = _ref3.selectionSet;
  878. return join([wrap('', alias, ': ') + name + wrap('(', join(args, ', '), ')'), join(directives, ' '), selectionSet], ' ');
  879. },
  880. Argument: function Argument(_ref4) {
  881. var name = _ref4.name,
  882. value = _ref4.value;
  883. return name + ': ' + value;
  884. },
  885. // Fragments
  886. FragmentSpread: function FragmentSpread(_ref5) {
  887. var name = _ref5.name,
  888. directives = _ref5.directives;
  889. return '...' + name + wrap(' ', join(directives, ' '));
  890. },
  891. InlineFragment: function InlineFragment(_ref6) {
  892. var typeCondition = _ref6.typeCondition,
  893. directives = _ref6.directives,
  894. selectionSet = _ref6.selectionSet;
  895. return join(['...', wrap('on ', typeCondition), join(directives, ' '), selectionSet], ' ');
  896. },
  897. FragmentDefinition: function FragmentDefinition(_ref7) {
  898. var name = _ref7.name,
  899. typeCondition = _ref7.typeCondition,
  900. directives = _ref7.directives,
  901. selectionSet = _ref7.selectionSet;
  902. return 'fragment ' + name + ' on ' + typeCondition + ' ' + wrap('', join(directives, ' '), ' ') + selectionSet;
  903. },
  904. // Value
  905. IntValue: function IntValue(_ref8) {
  906. var value = _ref8.value;
  907. return value;
  908. },
  909. FloatValue: function FloatValue(_ref9) {
  910. var value = _ref9.value;
  911. return value;
  912. },
  913. StringValue: function StringValue(_ref10) {
  914. var value = _ref10.value;
  915. return JSON.stringify(value);
  916. },
  917. BooleanValue: function BooleanValue(_ref11) {
  918. var value = _ref11.value;
  919. return JSON.stringify(value);
  920. },
  921. NullValue: function NullValue() {
  922. return 'null';
  923. },
  924. EnumValue: function EnumValue(_ref12) {
  925. var value = _ref12.value;
  926. return value;
  927. },
  928. ListValue: function ListValue(_ref13) {
  929. var values = _ref13.values;
  930. return '[' + join(values, ', ') + ']';
  931. },
  932. ObjectValue: function ObjectValue(_ref14) {
  933. var fields = _ref14.fields;
  934. return '{' + join(fields, ', ') + '}';
  935. },
  936. ObjectField: function ObjectField(_ref15) {
  937. var name = _ref15.name,
  938. value = _ref15.value;
  939. return name + ': ' + value;
  940. },
  941. // Directive
  942. Directive: function Directive(_ref16) {
  943. var name = _ref16.name,
  944. args = _ref16.arguments;
  945. return '@' + name + wrap('(', join(args, ', '), ')');
  946. },
  947. // Type
  948. NamedType: function NamedType(_ref17) {
  949. var name = _ref17.name;
  950. return name;
  951. },
  952. ListType: function ListType(_ref18) {
  953. var type = _ref18.type;
  954. return '[' + type + ']';
  955. },
  956. NonNullType: function NonNullType(_ref19) {
  957. var type = _ref19.type;
  958. return type + '!';
  959. },
  960. // Type System Definitions
  961. SchemaDefinition: function SchemaDefinition(_ref20) {
  962. var directives = _ref20.directives,
  963. operationTypes = _ref20.operationTypes;
  964. return join(['schema', join(directives, ' '), block(operationTypes)], ' ');
  965. },
  966. OperationTypeDefinition: function OperationTypeDefinition(_ref21) {
  967. var operation = _ref21.operation,
  968. type = _ref21.type;
  969. return operation + ': ' + type;
  970. },
  971. ScalarTypeDefinition: function ScalarTypeDefinition(_ref22) {
  972. var name = _ref22.name,
  973. directives = _ref22.directives;
  974. return join(['scalar', name, join(directives, ' ')], ' ');
  975. },
  976. ObjectTypeDefinition: function ObjectTypeDefinition(_ref23) {
  977. var name = _ref23.name,
  978. interfaces = _ref23.interfaces,
  979. directives = _ref23.directives,
  980. fields = _ref23.fields;
  981. return join(['type', name, wrap('implements ', join(interfaces, ', ')), join(directives, ' '), block(fields)], ' ');
  982. },
  983. FieldDefinition: function FieldDefinition(_ref24) {
  984. var name = _ref24.name,
  985. args = _ref24.arguments,
  986. type = _ref24.type,
  987. directives = _ref24.directives;
  988. return name + wrap('(', join(args, ', '), ')') + ': ' + type + wrap(' ', join(directives, ' '));
  989. },
  990. InputValueDefinition: function InputValueDefinition(_ref25) {
  991. var name = _ref25.name,
  992. type = _ref25.type,
  993. defaultValue = _ref25.defaultValue,
  994. directives = _ref25.directives;
  995. return join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' ');
  996. },
  997. InterfaceTypeDefinition: function InterfaceTypeDefinition(_ref26) {
  998. var name = _ref26.name,
  999. directives = _ref26.directives,
  1000. fields = _ref26.fields;
  1001. return join(['interface', name, join(directives, ' '), block(fields)], ' ');
  1002. },
  1003. UnionTypeDefinition: function UnionTypeDefinition(_ref27) {
  1004. var name = _ref27.name,
  1005. directives = _ref27.directives,
  1006. types = _ref27.types;
  1007. return join(['union', name, join(directives, ' '), '= ' + join(types, ' | ')], ' ');
  1008. },
  1009. EnumTypeDefinition: function EnumTypeDefinition(_ref28) {
  1010. var name = _ref28.name,
  1011. directives = _ref28.directives,
  1012. values = _ref28.values;
  1013. return join(['enum', name, join(directives, ' '), block(values)], ' ');
  1014. },
  1015. EnumValueDefinition: function EnumValueDefinition(_ref29) {
  1016. var name = _ref29.name,
  1017. directives = _ref29.directives;
  1018. return join([name, join(directives, ' ')], ' ');
  1019. },
  1020. InputObjectTypeDefinition: function InputObjectTypeDefinition(_ref30) {
  1021. var name = _ref30.name,
  1022. directives = _ref30.directives,
  1023. fields = _ref30.fields;
  1024. return join(['input', name, join(directives, ' '), block(fields)], ' ');
  1025. },
  1026. TypeExtensionDefinition: function TypeExtensionDefinition(_ref31) {
  1027. var definition = _ref31.definition;
  1028. return 'extend ' + definition;
  1029. },
  1030. DirectiveDefinition: function DirectiveDefinition(_ref32) {
  1031. var name = _ref32.name,
  1032. args = _ref32.arguments,
  1033. locations = _ref32.locations;
  1034. return 'directive @' + name + wrap('(', join(args, ', '), ')') + ' on ' + join(locations, ' | ');
  1035. }
  1036. };
  1037. /**
  1038. * Given maybeArray, print an empty string if it is null or empty, otherwise
  1039. * print all items together separated by separator if provided
  1040. */
  1041. function join(maybeArray, separator) {
  1042. return maybeArray ? maybeArray.filter(function (x) {
  1043. return x;
  1044. }).join(separator || '') : '';
  1045. }
  1046. /**
  1047. * Given array, print each item on its own line, wrapped in an
  1048. * indented "{ }" block.
  1049. */
  1050. function block(array) {
  1051. return array && array.length !== 0 ? indent('{\n' + join(array, '\n')) + '\n}' : '{}';
  1052. }
  1053. /**
  1054. * If maybeString is not null or empty, then wrap with start and end, otherwise
  1055. * print an empty string.
  1056. */
  1057. function wrap(start, maybeString, end) {
  1058. return maybeString ? start + maybeString + (end || '') : '';
  1059. }
  1060. function indent(maybeString) {
  1061. return maybeString && maybeString.replace(/\n/g, '\n ');
  1062. }
  1063. /***/ }),
  1064. /* 5 */
  1065. /***/ (function(module, exports, __webpack_require__) {
  1066. "use strict";
  1067. Object.defineProperty(exports, "__esModule", {
  1068. value: true
  1069. });
  1070. exports.specifiedDirectives = exports.GraphQLDeprecatedDirective = exports.DEFAULT_DEPRECATION_REASON = exports.GraphQLSkipDirective = exports.GraphQLIncludeDirective = exports.GraphQLDirective = exports.DirectiveLocation = undefined;
  1071. var _definition = __webpack_require__(1);
  1072. var _scalars = __webpack_require__(7);
  1073. var _invariant = __webpack_require__(3);
  1074. var _invariant2 = _interopRequireDefault(_invariant);
  1075. var _assertValidName = __webpack_require__(28);
  1076. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  1077. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1078. /**
  1079. * Copyright (c) 2015, Facebook, Inc.
  1080. * All rights reserved.
  1081. *
  1082. * This source code is licensed under the BSD-style license found in the
  1083. * LICENSE file in the root directory of this source tree. An additional grant
  1084. * of patent rights can be found in the PATENTS file in the same directory.
  1085. */
  1086. var DirectiveLocation = exports.DirectiveLocation = {
  1087. // Operations
  1088. QUERY: 'QUERY',
  1089. MUTATION: 'MUTATION',
  1090. SUBSCRIPTION: 'SUBSCRIPTION',
  1091. FIELD: 'FIELD',
  1092. FRAGMENT_DEFINITION: 'FRAGMENT_DEFINITION',
  1093. FRAGMENT_SPREAD: 'FRAGMENT_SPREAD',
  1094. INLINE_FRAGMENT: 'INLINE_FRAGMENT',
  1095. // Schema Definitions
  1096. SCHEMA: 'SCHEMA',
  1097. SCALAR: 'SCALAR',
  1098. OBJECT: 'OBJECT',
  1099. FIELD_DEFINITION: 'FIELD_DEFINITION',
  1100. ARGUMENT_DEFINITION: 'ARGUMENT_DEFINITION',
  1101. INTERFACE: 'INTERFACE',
  1102. UNION: 'UNION',
  1103. ENUM: 'ENUM',
  1104. ENUM_VALUE: 'ENUM_VALUE',
  1105. INPUT_OBJECT: 'INPUT_OBJECT',
  1106. INPUT_FIELD_DEFINITION: 'INPUT_FIELD_DEFINITION'
  1107. };
  1108. // eslint-disable-line
  1109. /**
  1110. * Directives are used by the GraphQL runtime as a way of modifying execution
  1111. * behavior. Type system creators will usually not create these directly.
  1112. */
  1113. var GraphQLDirective = exports.GraphQLDirective = function GraphQLDirective(config) {
  1114. _classCallCheck(this, GraphQLDirective);
  1115. (0, _invariant2.default)(config.name, 'Directive must be named.');
  1116. (0, _assertValidName.assertValidName)(config.name);
  1117. (0, _invariant2.default)(Array.isArray(config.locations), 'Must provide locations for directive.');
  1118. this.name = config.name;
  1119. this.description = config.description;
  1120. this.locations = config.locations;
  1121. var args = config.args;
  1122. if (!args) {
  1123. this.args = [];
  1124. } else {
  1125. (0, _invariant2.default)(!Array.isArray(args), '@' + config.name + ' args must be an object with argument names as keys.');
  1126. this.args = Object.keys(args).map(function (argName) {
  1127. (0, _assertValidName.assertValidName)(argName);
  1128. var arg = args[argName];
  1129. (0, _invariant2.default)((0, _definition.isInputType)(arg.type), '@' + config.name + '(' + argName + ':) argument type must be ' + ('Input Type but got: ' + String(arg.type) + '.'));
  1130. return {
  1131. name: argName,
  1132. description: arg.description === undefined ? null : arg.description,
  1133. type: arg.type,
  1134. defaultValue: arg.defaultValue
  1135. };
  1136. });
  1137. }
  1138. };
  1139. /**
  1140. * Used to conditionally include fields or fragments.
  1141. */
  1142. var GraphQLIncludeDirective = exports.GraphQLIncludeDirective = new GraphQLDirective({
  1143. name: 'include',
  1144. description: 'Directs the executor to include this field or fragment only when ' + 'the `if` argument is true.',
  1145. locations: [DirectiveLocation.FIELD, DirectiveLocation.FRAGMENT_SPREAD, DirectiveLocation.INLINE_FRAGMENT],
  1146. args: {
  1147. 'if': {
  1148. type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean),
  1149. description: 'Included when true.'
  1150. }
  1151. }
  1152. });
  1153. /**
  1154. * Used to conditionally skip (exclude) fields or fragments.
  1155. */
  1156. var GraphQLSkipDirective = exports.GraphQLSkipDirective = new GraphQLDirective({
  1157. name: 'skip',
  1158. description: 'Directs the executor to skip this field or fragment when the `if` ' + 'argument is true.',
  1159. locations: [DirectiveLocation.FIELD, DirectiveLocation.FRAGMENT_SPREAD, DirectiveLocation.INLINE_FRAGMENT],
  1160. args: {
  1161. 'if': {
  1162. type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean),
  1163. description: 'Skipped when true.'
  1164. }
  1165. }
  1166. });
  1167. /**
  1168. * Constant string used for default reason for a deprecation.
  1169. */
  1170. var DEFAULT_DEPRECATION_REASON = exports.DEFAULT_DEPRECATION_REASON = 'No longer supported';
  1171. /**
  1172. * Used to declare element of a GraphQL schema as deprecated.
  1173. */
  1174. var GraphQLDeprecatedDirective = exports.GraphQLDeprecatedDirective = new GraphQLDirective({
  1175. name: 'deprecated',
  1176. description: 'Marks an element of a GraphQL schema as no longer supported.',
  1177. locations: [DirectiveLocation.FIELD_DEFINITION, DirectiveLocation.ENUM_VALUE],
  1178. args: {
  1179. reason: {
  1180. type: _scalars.GraphQLString,
  1181. description: 'Explains why this element was deprecated, usually also including a ' + 'suggestion for how to access supported similar data. Formatted ' + 'in [Markdown](https://daringfireball.net/projects/markdown/).',
  1182. defaultValue: DEFAULT_DEPRECATION_REASON
  1183. }
  1184. }
  1185. });
  1186. /**
  1187. * The full list of specified directives.
  1188. */
  1189. var specifiedDirectives = exports.specifiedDirectives = [GraphQLIncludeDirective, GraphQLSkipDirective, GraphQLDeprecatedDirective];
  1190. /***/ }),
  1191. /* 6 */
  1192. /***/ (function(module, exports, __webpack_require__) {
  1193. "use strict";
  1194. Object.defineProperty(exports, "__esModule", {
  1195. value: true
  1196. });
  1197. exports.default = isNullish;
  1198. /**
  1199. * Copyright (c) 2015, Facebook, Inc.
  1200. * All rights reserved.
  1201. *
  1202. * This source code is licensed under the BSD-style license found in the
  1203. * LICENSE file in the root directory of this source tree. An additional grant
  1204. * of patent rights can be found in the PATENTS file in the same directory.
  1205. */
  1206. /**
  1207. * Returns true if a value is null, undefined, or NaN.
  1208. */
  1209. function isNullish(value) {
  1210. return value === null || value === undefined || value !== value;
  1211. }
  1212. /***/ }),
  1213. /* 7 */
  1214. /***/ (function(module, exports, __webpack_require__) {
  1215. "use strict";
  1216. Object.defineProperty(exports, "__esModule", {
  1217. value: true
  1218. });
  1219. exports.GraphQLID = exports.GraphQLBoolean = exports.GraphQLString = exports.GraphQLFloat = exports.GraphQLInt = undefined;
  1220. var _definition = __webpack_require__(1);
  1221. var _kinds = __webpack_require__(2);
  1222. var Kind = _interopRequireWildcard(_kinds);
  1223. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  1224. // As per the GraphQL Spec, Integers are only treated as valid when a valid
  1225. // 32-bit signed integer, providing the broadest support across platforms.
  1226. //
  1227. // n.b. JavaScript's integers are safe between -(2^53 - 1) and 2^53 - 1 because
  1228. // they are internally represented as IEEE 754 doubles.
  1229. /**
  1230. * Copyright (c) 2015, Facebook, Inc.
  1231. * All rights reserved.
  1232. *
  1233. * This source code is licensed under the BSD-style license found in the
  1234. * LICENSE file in the root directory of this source tree. An additional grant
  1235. * of patent rights can be found in the PATENTS file in the same directory.
  1236. */
  1237. var MAX_INT = 2147483647;
  1238. var MIN_INT = -2147483648;
  1239. function coerceInt(value) {
  1240. if (value === '') {
  1241. throw new TypeError('Int cannot represent non 32-bit signed integer value: (empty string)');
  1242. }
  1243. var num = Number(value);
  1244. if (num === num && num <= MAX_INT && num >= MIN_INT) {
  1245. return (num < 0 ? Math.ceil : Math.floor)(num);
  1246. }
  1247. throw new TypeError('Int cannot represent non 32-bit signed integer value: ' + String(value));
  1248. }
  1249. var GraphQLInt = exports.GraphQLInt = new _definition.GraphQLScalarType({
  1250. name: 'Int',
  1251. description: 'The `Int` scalar type represents non-fractional signed whole numeric ' + 'values. Int can represent values between -(2^31) and 2^31 - 1. ',
  1252. serialize: coerceInt,
  1253. parseValue: coerceInt,
  1254. parseLiteral: function parseLiteral(ast) {
  1255. if (ast.kind === Kind.INT) {
  1256. var num = parseInt(ast.value, 10);
  1257. if (num <= MAX_INT && num >= MIN_INT) {
  1258. return num;
  1259. }
  1260. }
  1261. return null;
  1262. }
  1263. });
  1264. function coerceFloat(value) {
  1265. if (value === '') {
  1266. throw new TypeError('Float cannot represent non numeric value: (empty string)');
  1267. }
  1268. var num = Number(value);
  1269. if (num === num) {
  1270. return num;
  1271. }
  1272. throw new TypeError('Float cannot represent non numeric value: ' + String(value));
  1273. }
  1274. var GraphQLFloat = exports.GraphQLFloat = new _definition.GraphQLScalarType({
  1275. name: 'Float',
  1276. description: 'The `Float` scalar type represents signed double-precision fractional ' + 'values as specified by ' + '[IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point). ',
  1277. serialize: coerceFloat,
  1278. parseValue: coerceFloat,
  1279. parseLiteral: function parseLiteral(ast) {
  1280. return ast.kind === Kind.FLOAT || ast.kind === Kind.INT ? parseFloat(ast.value) : null;
  1281. }
  1282. });
  1283. var GraphQLString = exports.GraphQLString = new _definition.GraphQLScalarType({
  1284. name: 'String',
  1285. description: 'The `String` scalar type represents textual data, represented as UTF-8 ' + 'character sequences. The String type is most often used by GraphQL to ' + 'represent free-form human-readable text.',
  1286. serialize: String,
  1287. parseValue: String,
  1288. parseLiteral: function parseLiteral(ast) {
  1289. return ast.kind === Kind.STRING ? ast.value : null;
  1290. }
  1291. });
  1292. var GraphQLBoolean = exports.GraphQLBoolean = new _definition.GraphQLScalarType({
  1293. name: 'Boolean',
  1294. description: 'The `Boolean` scalar type represents `true` or `false`.',
  1295. serialize: Boolean,
  1296. parseValue: Boolean,
  1297. parseLiteral: function parseLiteral(ast) {
  1298. return ast.kind === Kind.BOOLEAN ? ast.value : null;
  1299. }
  1300. });
  1301. var GraphQLID = exports.GraphQLID = new _definition.GraphQLScalarType({
  1302. name: 'ID',
  1303. description: 'The `ID` scalar type represents a unique identifier, often used to ' + 'refetch an object or as key for a cache. The ID type appears in a JSON ' + 'response as a String; however, it is not intended to be human-readable. ' + 'When expected as an input type, any string (such as `"4"`) or integer ' + '(such as `4`) input value will be accepted as an ID.',
  1304. serialize: String,
  1305. parseValue: String,
  1306. parseLiteral: function parseLiteral(ast) {
  1307. return ast.kind === Kind.STRING || ast.kind === Kind.INT ? ast.value : null;
  1308. }
  1309. });
  1310. /***/ }),
  1311. /* 8 */
  1312. /***/ (function(module, exports, __webpack_require__) {
  1313. "use strict";
  1314. Object.defineProperty(exports, "__esModule", {
  1315. value: true
  1316. });
  1317. exports.GraphQLSchema = undefined;
  1318. var _definition = __webpack_require__(1);
  1319. var _directives = __webpack_require__(5);
  1320. var _introspection = __webpack_require__(11);
  1321. var _find = __webpack_require__(10);
  1322. var _find2 = _interopRequireDefault(_find);
  1323. var _invariant = __webpack_require__(3);
  1324. var _invariant2 = _interopRequireDefault(_invariant);
  1325. var _typeComparators = __webpack_require__(19);
  1326. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  1327. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  1328. /**
  1329. * Copyright (c) 2015, Facebook, Inc.
  1330. * All rights reserved.
  1331. *
  1332. * This source code is licensed under the BSD-style license found in the
  1333. * LICENSE file in the root directory of this source tree. An additional grant
  1334. * of patent rights can be found in the PATENTS file in the same directory.
  1335. */
  1336. /**
  1337. * Schema Definition
  1338. *
  1339. * A Schema is created by supplying the root types of each type of operation,
  1340. * query and mutation (optional). A schema definition is then supplied to the
  1341. * validator and executor.
  1342. *
  1343. * Example:
  1344. *
  1345. * const MyAppSchema = new GraphQLSchema({
  1346. * query: MyAppQueryRootType,
  1347. * mutation: MyAppMutationRootType,
  1348. * })
  1349. *
  1350. * Note: If an array of `directives` are provided to GraphQLSchema, that will be
  1351. * the exact list of directives represented and allowed. If `directives` is not
  1352. * provided then a default set of the specified directives (e.g. @include and
  1353. * @skip) will be used. If you wish to provide *additional* directives to these
  1354. * specified directives, you must explicitly declare them. Example:
  1355. *
  1356. * const MyAppSchema = new GraphQLSchema({
  1357. * ...
  1358. * directives: specifiedDirectives.concat([ myCustomDirective ]),
  1359. * })
  1360. *
  1361. */
  1362. var GraphQLSchema = exports.GraphQLSchema = function () {
  1363. function GraphQLSchema(config) {
  1364. var _this = this;
  1365. _classCallCheck(this, GraphQLSchema);
  1366. (0, _invariant2.default)(typeof config === 'object', 'Must provide configuration object.');
  1367. (0, _invariant2.default)(config.query instanceof _definition.GraphQLObjectType, 'Schema query must be Object Type but got: ' + String(config.query) + '.');
  1368. this._queryType = config.query;
  1369. (0, _invariant2.default)(!config.mutation || config.mutation instanceof _definition.GraphQLObjectType, 'Schema mutation must be Object Type if provided but got: ' + String(config.mutation) + '.');
  1370. this._mutationType = config.mutation;
  1371. (0, _invariant2.default)(!config.subscription || config.subscription instanceof _definition.GraphQLObjectType, 'Schema subscription must be Object Type if provided but got: ' + String(config.subscription) + '.');
  1372. this._subscriptionType = config.subscription;
  1373. (0, _invariant2.default)(!config.types || Array.isArray(config.types), 'Schema types must be Array if provided but got: ' + String(config.types) + '.');
  1374. (0, _invariant2.default)(!config.directives || Array.isArray(config.directives) && config.directives.every(function (directive) {
  1375. return directive instanceof _directives.GraphQLDirective;
  1376. }), 'Schema directives must be Array<GraphQLDirective> if provided but got: ' + String(config.directives) + '.');
  1377. // Provide specified directives (e.g. @include and @skip) by default.
  1378. this._directives = config.directives || _directives.specifiedDirectives;
  1379. // Build type map now to detect any errors within this schema.
  1380. var initialTypes = [this.getQueryType(), this.getMutationType(), this.getSubscriptionType(), _introspection.__Schema];
  1381. var types = config.types;
  1382. if (types) {
  1383. initialTypes = initialTypes.concat(types);
  1384. }
  1385. this._typeMap = initialTypes.reduce(typeMapReducer, Object.create(null));
  1386. // Keep track of all implementations by interface name.
  1387. this._implementations = Object.create(null);
  1388. Object.keys(this._typeMap).forEach(function (typeName) {
  1389. var type = _this._typeMap[typeName];
  1390. if (type instanceof _definition.GraphQLObjectType) {
  1391. type.getInterfaces().forEach(function (iface) {
  1392. var impls = _this._implementations[iface.name];
  1393. if (impls) {
  1394. impls.push(type);
  1395. } else {
  1396. _this._implementations[iface.name] = [type];
  1397. }
  1398. });
  1399. }
  1400. });
  1401. // Enforce correct interface implementations.
  1402. Object.keys(this._typeMap).forEach(function (typeName) {
  1403. var type = _this._typeMap[typeName];
  1404. if (type instanceof _definition.GraphQLObjectType) {
  1405. type.getInterfaces().forEach(function (iface) {
  1406. return assertObjectImplementsInterface(_this, type, iface);
  1407. });
  1408. }
  1409. });
  1410. }
  1411. GraphQLSchema.prototype.getQueryType = function getQueryType() {
  1412. return this._queryType;
  1413. };
  1414. GraphQLSchema.prototype.getMutationType = function getMutationType() {
  1415. return this._mutationType;
  1416. };
  1417. GraphQLSchema.prototype.getSubscriptionType = function getSubscriptionType() {
  1418. return this._subscriptionType;
  1419. };
  1420. GraphQLSchema.prototype.getTypeMap = function getTypeMap() {
  1421. return this._typeMap;
  1422. };
  1423. GraphQLSchema.prototype.getType = function getType(name) {
  1424. return this.getTypeMap()[name];
  1425. };
  1426. GraphQLSchema.prototype.getPossibleTypes = function getPossibleTypes(abstractType) {
  1427. if (abstractType instanceof _definition.GraphQLUnionType) {
  1428. return abstractType.getTypes();
  1429. }
  1430. (0, _invariant2.default)(abstractType instanceof _definition.GraphQLInterfaceType);
  1431. return this._implementations[abstractType.name];
  1432. };
  1433. GraphQLSchema.prototype.isPossibleType = function isPossibleType(abstractType, possibleType) {
  1434. var possibleTypeMap = this._possibleTypeMap;
  1435. if (!possibleTypeMap) {
  1436. this._possibleTypeMap = possibleTypeMap = Object.create(null);
  1437. }
  1438. if (!possibleTypeMap[abstractType.name]) {
  1439. var possibleTypes = this.getPossibleTypes(abstractType);
  1440. (0, _invariant2.default)(Array.isArray(possibleTypes), 'Could not find possible implementing types for ' + abstractType.name + ' ' + 'in schema. Check that schema.types is defined and is an array of ' + 'all possible types in the schema.');
  1441. possibleTypeMap[abstractType.name] = possibleTypes.reduce(function (map, type) {
  1442. return map[type.name] = true, map;
  1443. }, Object.create(null));
  1444. }
  1445. return Boolean(possibleTypeMap[abstractType.name][possibleType.name]);
  1446. };
  1447. GraphQLSchema.prototype.getDirectives = function getDirectives() {
  1448. return this._directives;
  1449. };
  1450. GraphQLSchema.prototype.getDirective = function getDirective(name) {
  1451. return (0, _find2.default)(this.getDirectives(), function (directive) {
  1452. return directive.name === name;
  1453. });
  1454. };
  1455. return GraphQLSchema;
  1456. }();
  1457. function typeMapReducer(map, type) {
  1458. if (!type) {
  1459. return map;
  1460. }
  1461. if (type instanceof _definition.GraphQLList || type instanceof _definition.GraphQLNonNull) {
  1462. return typeMapReducer(map, type.ofType);
  1463. }
  1464. if (map[type.name]) {
  1465. (0, _invariant2.default)(map[type.name] === type, 'Schema must contain unique named types but contains multiple ' + ('types named "' + type.name + '".'));
  1466. return map;
  1467. }
  1468. map[type.name] = type;
  1469. var reducedMap = map;
  1470. if (type instanceof _definition.GraphQLUnionType) {
  1471. reducedMap = type.getTypes().reduce(typeMapReducer, reducedMap);
  1472. }
  1473. if (type instanceof _definition.GraphQLObjectType) {
  1474. reducedMap = type.getInterfaces().reduce(typeMapReducer, reducedMap);
  1475. }
  1476. if (type instanceof _definition.GraphQLObjectType || type instanceof _definition.GraphQLInterfaceType) {
  1477. (function () {
  1478. var fieldMap = type.getFields();
  1479. Object.keys(fieldMap).forEach(function (fieldName) {
  1480. var field = fieldMap[fieldName];
  1481. if (field.args) {
  1482. var fieldArgTypes = field.args.map(function (arg) {
  1483. return arg.type;
  1484. });
  1485. reducedMap = fieldArgTypes.reduce(typeMapReducer, reducedMap);
  1486. }
  1487. reducedMap = typeMapReducer(reducedMap, field.type);
  1488. });
  1489. })();
  1490. }
  1491. if (type instanceof _definition.GraphQLInputObjectType) {
  1492. (function () {
  1493. var fieldMap = type.getFields();
  1494. Object.keys(fieldMap).forEach(function (fieldName) {
  1495. var field = fieldMap[fieldName];
  1496. reducedMap = typeMapReducer(reducedMap, field.type);
  1497. });
  1498. })();
  1499. }
  1500. return reducedMap;
  1501. }
  1502. function assertObjectImplementsInterface(schema, object, iface) {
  1503. var objectFieldMap = object.getFields();
  1504. var ifaceFieldMap = iface.getFields();
  1505. // Assert each interface field is implemented.
  1506. Object.keys(ifaceFieldMap).forEach(function (fieldName) {
  1507. var objectField = objectFieldMap[fieldName];
  1508. var ifaceField = ifaceFieldMap[fieldName];
  1509. // Assert interface field exists on object.
  1510. (0, _invariant2.default)(objectField, '"' + iface.name + '" expects field "' + fieldName + '" but "' + object.name + '" ' + 'does not provide it.');
  1511. // Assert interface field type is satisfied by object field type, by being
  1512. // a valid subtype. (covariant)
  1513. (0, _invariant2.default)((0, _typeComparators.isTypeSubTypeOf)(schema, objectField.type, ifaceField.type), iface.name + '.' + fieldName + ' expects type "' + String(ifaceField.type) + '" ' + 'but ' + (object.name + '.' + fieldName + ' provides type "' + String(objectField.type) + '".'));
  1514. // Assert each interface field arg is implemented.
  1515. ifaceField.args.forEach(function (ifaceArg) {
  1516. var argName = ifaceArg.name;
  1517. var objectArg = (0, _find2.default)(objectField.args, function (arg) {
  1518. return arg.name === argName;
  1519. });
  1520. // Assert interface field arg exists on object field.
  1521. (0, _invariant2.default)(objectArg, iface.name + '.' + fieldName + ' expects argument "' + argName + '" but ' + (object.name + '.' + fieldName + ' does not provide it.'));
  1522. // Assert interface field arg type matches object field arg type.
  1523. // (invariant)
  1524. (0, _invariant2.default)((0, _typeComparators.isEqualType)(ifaceArg.type, objectArg.type), iface.name + '.' + fieldName + '(' + argName + ':) expects type ' + ('"' + String(ifaceArg.type) + '" but ') + (object.name + '.' + fieldName + '(' + argName + ':) provides type ') + ('"' + String(objectArg.type) + '".'));
  1525. });
  1526. // Assert additional arguments must not be required.
  1527. objectField.args.forEach(function (objectArg) {
  1528. var argName = objectArg.name;
  1529. var ifaceArg = (0, _find2.default)(ifaceField.args, function (arg) {
  1530. return arg.name === argName;
  1531. });
  1532. if (!ifaceArg) {
  1533. (0, _invariant2.default)(!(objectArg.type instanceof _definition.GraphQLNonNull), object.name + '.' + fieldName + '(' + argName + ':) is of required type ' + ('"' + String(objectArg.type) + '" but is not also provided by the ') + ('interface ' + iface.name + '.' + fieldName + '.'));
  1534. }
  1535. });
  1536. });
  1537. }
  1538. /***/ }),
  1539. /* 9 */
  1540. /***/ (function(module, exports, __webpack_require__) {
  1541. "use strict";
  1542. Object.defineProperty(exports, "__esModule", {
  1543. value: true
  1544. });
  1545. exports.typeFromAST = typeFromAST;
  1546. var _invariant = __webpack_require__(3);
  1547. var _invariant2 = _interopRequireDefault(_invariant);
  1548. var _kinds = __webpack_require__(2);
  1549. var _definition = __webpack_require__(1);
  1550. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  1551. function typeFromAST(schema, typeNode) {
  1552. var innerType = void 0;
  1553. if (typeNode.kind === _kinds.LIST_TYPE) {
  1554. innerType = typeFromAST(schema, typeNode.type);
  1555. return innerType && new _definition.GraphQLList(innerType);
  1556. }
  1557. if (typeNode.kind === _kinds.NON_NULL_TYPE) {
  1558. innerType = typeFromAST(schema, typeNode.type);
  1559. return innerType && new _definition.GraphQLNonNull(innerType);
  1560. }
  1561. (0, _invariant2.default)(typeNode.kind === _kinds.NAMED_TYPE, 'Must be a named type.');
  1562. return schema.getType(typeNode.name.value);
  1563. }
  1564. /**
  1565. * Copyright (c) 2015, Facebook, Inc.
  1566. * All rights reserved.
  1567. *
  1568. * This source code is licensed under the BSD-style license found in the
  1569. * LICENSE file in the root directory of this source tree. An additional grant
  1570. * of patent rights can be found in the PATENTS file in the same directory.
  1571. */
  1572. /***/ }),
  1573. /* 10 */
  1574. /***/ (function(module, exports, __webpack_require__) {
  1575. "use strict";
  1576. Object.defineProperty(exports, "__esModule", {
  1577. value: true
  1578. });
  1579. exports.default = find;
  1580. /**
  1581. * Copyright (c) 2015, Facebook, Inc.
  1582. * All rights reserved.
  1583. *
  1584. * This source code is licensed under the BSD-style license found in the
  1585. * LICENSE file in the root directory of this source tree. An additional grant
  1586. * of patent rights can be found in the PATENTS file in the same directory.
  1587. */
  1588. function find(list, predicate) {
  1589. for (var i = 0; i < list.length; i++) {
  1590. if (predicate(list[i])) {
  1591. return list[i];
  1592. }
  1593. }
  1594. }
  1595. /***/ }),
  1596. /* 11 */
  1597. /***/ (function(module, exports, __webpack_require__) {
  1598. "use strict";
  1599. Object.defineProperty(exports, "__esModule", {
  1600. value: true
  1601. });
  1602. exports.TypeNameMetaFieldDef = exports.TypeMetaFieldDef = exports.SchemaMetaFieldDef = exports.__TypeKind = exports.TypeKind = exports.__EnumValue = exports.__InputValue = exports.__Field = exports.__Type = exports.__DirectiveLocation = exports.__Directive = exports.__Schema = undefined;
  1603. var _isInvalid = __webpack_require__(14);
  1604. var _isInvalid2 = _interopRequireDefault(_isInvalid);
  1605. var _astFromValue = __webpack_require__(29);
  1606. var _printer = __webpack_require__(4);
  1607. var _definition = __webpack_require__(1);
  1608. var _scalars = __webpack_require__(7);
  1609. var _directives = __webpack_require__(5);
  1610. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  1611. /**
  1612. * Copyright (c) 2015, Facebook, Inc.
  1613. * All rights reserved.
  1614. *
  1615. * This source code is licensed under the BSD-style license found in the
  1616. * LICENSE file in the root directory of this source tree. An additional grant
  1617. * of patent rights can be found in the PATENTS file in the same directory.
  1618. */
  1619. var __Schema = exports.__Schema = new _definition.GraphQLObjectType({
  1620. name: '__Schema',
  1621. isIntrospection: true,
  1622. description: 'A GraphQL Schema defines the capabilities of a GraphQL server. It ' + 'exposes all available types and directives on the server, as well as ' + 'the entry points for query, mutation, and subscription operations.',
  1623. fields: function fields() {
  1624. return {
  1625. types: {
  1626. description: 'A list of all types supported by this server.',
  1627. type: new _definition.GraphQLNonNull(new _definition.GraphQLList(new _definition.GraphQLNonNull(__Type))),
  1628. resolve: function resolve(schema) {
  1629. var typeMap = schema.getTypeMap();
  1630. return Object.keys(typeMap).map(function (key) {
  1631. return typeMap[key];
  1632. });
  1633. }
  1634. },
  1635. queryType: {
  1636. description: 'The type that query operations will be rooted at.',
  1637. type: new _definition.GraphQLNonNull(__Type),
  1638. resolve: function resolve(schema) {
  1639. return schema.getQueryType();
  1640. }
  1641. },
  1642. mutationType: {
  1643. description: 'If this server supports mutation, the type that ' + 'mutation operations will be rooted at.',
  1644. type: __Type,
  1645. resolve: function resolve(schema) {
  1646. return schema.getMutationType();
  1647. }
  1648. },
  1649. subscriptionType: {
  1650. description: 'If this server support subscription, the type that ' + 'subscription operations will be rooted at.',
  1651. type: __Type,
  1652. resolve: function resolve(schema) {
  1653. return schema.getSubscriptionType();
  1654. }
  1655. },
  1656. directives: {
  1657. description: 'A list of all directives supported by this server.',
  1658. type: new _definition.GraphQLNonNull(new _definition.GraphQLList(new _definition.GraphQLNonNull(__Directive))),
  1659. resolve: function resolve(schema) {
  1660. return schema.getDirectives();
  1661. }
  1662. }
  1663. };
  1664. }
  1665. });
  1666. var __Directive = exports.__Directive = new _definition.GraphQLObjectType({
  1667. name: '__Directive',
  1668. isIntrospection: true,
  1669. description: 'A Directive provides a way to describe alternate runtime execution and ' + 'type validation behavior in a GraphQL document.' + '\n\nIn some cases, you need to provide options to alter GraphQL\'s ' + 'execution behavior in ways field arguments will not suffice, such as ' + 'conditionally including or skipping a field. Directives provide this by ' + 'describing additional information to the executor.',
  1670. fields: function fields() {
  1671. return {
  1672. name: { type: new _definition.GraphQLNonNull(_scalars.GraphQLString) },
  1673. description: { type: _scalars.GraphQLString },
  1674. locations: {
  1675. type: new _definition.GraphQLNonNull(new _definition.GraphQLList(new _definition.GraphQLNonNull(__DirectiveLocation)))
  1676. },
  1677. args: {
  1678. type: new _definition.GraphQLNonNull(new _definition.GraphQLList(new _definition.GraphQLNonNull(__InputValue))),
  1679. resolve: function resolve(directive) {
  1680. return directive.args || [];
  1681. }
  1682. },
  1683. // NOTE: the following three fields are deprecated and are no longer part
  1684. // of the GraphQL specification.
  1685. onOperation: {
  1686. deprecationReason: 'Use `locations`.',
  1687. type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean),
  1688. resolve: function resolve(d) {
  1689. return d.locations.indexOf(_directives.DirectiveLocation.QUERY) !== -1 || d.locations.indexOf(_directives.DirectiveLocation.MUTATION) !== -1 || d.locations.indexOf(_directives.DirectiveLocation.SUBSCRIPTION) !== -1;
  1690. }
  1691. },
  1692. onFragment: {
  1693. deprecationReason: 'Use `locations`.',
  1694. type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean),
  1695. resolve: function resolve(d) {
  1696. return d.locations.indexOf(_directives.DirectiveLocation.FRAGMENT_SPREAD) !== -1 || d.locations.indexOf(_directives.DirectiveLocation.INLINE_FRAGMENT) !== -1 || d.locations.indexOf(_directives.DirectiveLocation.FRAGMENT_DEFINITION) !== -1;
  1697. }
  1698. },
  1699. onField: {
  1700. deprecationReason: 'Use `locations`.',
  1701. type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean),
  1702. resolve: function resolve(d) {
  1703. return d.locations.indexOf(_directives.DirectiveLocation.FIELD) !== -1;
  1704. }
  1705. }
  1706. };
  1707. }
  1708. });
  1709. var __DirectiveLocation = exports.__DirectiveLocation = new _definition.GraphQLEnumType({
  1710. name: '__DirectiveLocation',
  1711. isIntrospection: true,
  1712. description: 'A Directive can be adjacent to many parts of the GraphQL language, a ' + '__DirectiveLocation describes one such possible adjacencies.',
  1713. values: {
  1714. QUERY: {
  1715. value: _directives.DirectiveLocation.QUERY,
  1716. description: 'Location adjacent to a query operation.'
  1717. },
  1718. MUTATION: {
  1719. value: _directives.DirectiveLocation.MUTATION,
  1720. description: 'Location adjacent to a mutation operation.'
  1721. },
  1722. SUBSCRIPTION: {
  1723. value: _directives.DirectiveLocation.SUBSCRIPTION,
  1724. description: 'Location adjacent to a subscription operation.'
  1725. },
  1726. FIELD: {
  1727. value: _directives.DirectiveLocation.FIELD,
  1728. description: 'Location adjacent to a field.'
  1729. },
  1730. FRAGMENT_DEFINITION: {
  1731. value: _directives.DirectiveLocation.FRAGMENT_DEFINITION,
  1732. description: 'Location adjacent to a fragment definition.'
  1733. },
  1734. FRAGMENT_SPREAD: {
  1735. value: _directives.DirectiveLocation.FRAGMENT_SPREAD,
  1736. description: 'Location adjacent to a fragment spread.'
  1737. },
  1738. INLINE_FRAGMENT: {
  1739. value: _directives.DirectiveLocation.INLINE_FRAGMENT,
  1740. description: 'Location adjacent to an inline fragment.'
  1741. },
  1742. SCHEMA: {
  1743. value: _directives.DirectiveLocation.SCHEMA,
  1744. description: 'Location adjacent to a schema definition.'
  1745. },
  1746. SCALAR: {
  1747. value: _directives.DirectiveLocation.SCALAR,
  1748. description: 'Location adjacent to a scalar definition.'
  1749. },
  1750. OBJECT: {
  1751. value: _directives.DirectiveLocation.OBJECT,
  1752. description: 'Location adjacent to an object type definition.'
  1753. },
  1754. FIELD_DEFINITION: {
  1755. value: _directives.DirectiveLocation.FIELD_DEFINITION,
  1756. description: 'Location adjacent to a field definition.'
  1757. },
  1758. ARGUMENT_DEFINITION: {
  1759. value: _directives.DirectiveLocation.ARGUMENT_DEFINITION,
  1760. description: 'Location adjacent to an argument definition.'
  1761. },
  1762. INTERFACE: {
  1763. value: _directives.DirectiveLocation.INTERFACE,
  1764. description: 'Location adjacent to an interface definition.'
  1765. },
  1766. UNION: {
  1767. value: _directives.DirectiveLocation.UNION,
  1768. description: 'Location adjacent to a union definition.'
  1769. },
  1770. ENUM: {
  1771. value: _directives.DirectiveLocation.ENUM,
  1772. description: 'Location adjacent to an enum definition.'
  1773. },
  1774. ENUM_VALUE: {
  1775. value: _directives.DirectiveLocation.ENUM_VALUE,
  1776. description: 'Location adjacent to an enum value definition.'
  1777. },
  1778. INPUT_OBJECT: {
  1779. value: _directives.DirectiveLocation.INPUT_OBJECT,
  1780. description: 'Location adjacent to an input object type definition.'
  1781. },
  1782. INPUT_FIELD_DEFINITION: {
  1783. value: _directives.DirectiveLocation.INPUT_FIELD_DEFINITION,
  1784. description: 'Location adjacent to an input object field definition.'
  1785. }
  1786. }
  1787. });
  1788. var __Type = exports.__Type = new _definition.GraphQLObjectType({
  1789. name: '__Type',
  1790. isIntrospection: true,
  1791. description: 'The fundamental unit of any GraphQL Schema is the type. There are ' + 'many kinds of types in GraphQL as represented by the `__TypeKind` enum.' + '\n\nDepending on the kind of a type, certain fields describe ' + 'information about that type. Scalar types provide no information ' + 'beyond a name and description, while Enum types provide their values. ' + 'Object and Interface types provide the fields they describe. Abstract ' + 'types, Union and Interface, provide the Object types possible ' + 'at runtime. List and NonNull types compose other types.',
  1792. fields: function fields() {
  1793. return {
  1794. kind: {
  1795. type: new _definition.GraphQLNonNull(__TypeKind),
  1796. resolve: function resolve(type) {
  1797. if (type instanceof _definition.GraphQLScalarType) {
  1798. return TypeKind.SCALAR;
  1799. } else if (type instanceof _definition.GraphQLObjectType) {
  1800. return TypeKind.OBJECT;
  1801. } else if (type instanceof _definition.GraphQLInterfaceType) {
  1802. return TypeKind.INTERFACE;
  1803. } else if (type instanceof _definition.GraphQLUnionType) {
  1804. return TypeKind.UNION;
  1805. } else if (type instanceof _definition.GraphQLEnumType) {
  1806. return TypeKind.ENUM;
  1807. } else if (type instanceof _definition.GraphQLInputObjectType) {
  1808. return TypeKind.INPUT_OBJECT;
  1809. } else if (type instanceof _definition.GraphQLList) {
  1810. return TypeKind.LIST;
  1811. } else if (type instanceof _definition.GraphQLNonNull) {
  1812. return TypeKind.NON_NULL;
  1813. }
  1814. throw new Error('Unknown kind of type: ' + type);
  1815. }
  1816. },
  1817. name: { type: _scalars.GraphQLString },
  1818. description: { type: _scalars.GraphQLString },
  1819. fields: {
  1820. type: new _definition.GraphQLList(new _definition.GraphQLNonNull(__Field)),
  1821. args: {
  1822. includeDeprecated: { type: _scalars.GraphQLBoolean, defaultValue: false }
  1823. },
  1824. resolve: function resolve(type, _ref) {
  1825. var includeDeprecated = _ref.includeDeprecated;
  1826. if (type instanceof _definition.GraphQLObjectType || type instanceof _definition.GraphQLInterfaceType) {
  1827. var _ret = function () {
  1828. var fieldMap = type.getFields();
  1829. var fields = Object.keys(fieldMap).map(function (fieldName) {
  1830. return fieldMap[fieldName];
  1831. });
  1832. if (!includeDeprecated) {
  1833. fields = fields.filter(function (field) {
  1834. return !field.deprecationReason;
  1835. });
  1836. }
  1837. return {
  1838. v: fields
  1839. };
  1840. }();
  1841. if (typeof _ret === "object") return _ret.v;
  1842. }
  1843. return null;
  1844. }
  1845. },
  1846. interfaces: {
  1847. type: new _definition.GraphQLList(new _definition.GraphQLNonNull(__Type)),
  1848. resolve: function resolve(type) {
  1849. if (type instanceof _definition.GraphQLObjectType) {
  1850. return type.getInterfaces();
  1851. }
  1852. }
  1853. },
  1854. possibleTypes: {
  1855. type: new _definition.GraphQLList(new _definition.GraphQLNonNull(__Type)),
  1856. resolve: function resolve(type, args, context, _ref2) {
  1857. var schema = _ref2.schema;
  1858. if (type instanceof _definition.GraphQLInterfaceType || type instanceof _definition.GraphQLUnionType) {
  1859. return schema.getPossibleTypes(type);
  1860. }
  1861. }
  1862. },
  1863. enumValues: {
  1864. type: new _definition.GraphQLList(new _definition.GraphQLNonNull(__EnumValue)),
  1865. args: {
  1866. includeDeprecated: { type: _scalars.GraphQLBoolean, defaultValue: false }
  1867. },
  1868. resolve: function resolve(type, _ref3) {
  1869. var includeDeprecated = _ref3.includeDeprecated;
  1870. if (type instanceof _definition.GraphQLEnumType) {
  1871. var values = type.getValues();
  1872. if (!includeDeprecated) {
  1873. values = values.filter(function (value) {
  1874. return !value.deprecationReason;
  1875. });
  1876. }
  1877. return values;
  1878. }
  1879. }
  1880. },
  1881. inputFields: {
  1882. type: new _definition.GraphQLList(new _definition.GraphQLNonNull(__InputValue)),
  1883. resolve: function resolve(type) {
  1884. if (type instanceof _definition.GraphQLInputObjectType) {
  1885. var _ret2 = function () {
  1886. var fieldMap = type.getFields();
  1887. return {
  1888. v: Object.keys(fieldMap).map(function (fieldName) {
  1889. return fieldMap[fieldName];
  1890. })
  1891. };
  1892. }();
  1893. if (typeof _ret2 === "object") return _ret2.v;
  1894. }
  1895. }
  1896. },
  1897. ofType: { type: __Type }
  1898. };
  1899. }
  1900. });
  1901. var __Field = exports.__Field = new _definition.GraphQLObjectType({
  1902. name: '__Field',
  1903. isIntrospection: true,
  1904. description: 'Object and Interface types are described by a list of Fields, each of ' + 'which has a name, potentially a list of arguments, and a return type.',
  1905. fields: function fields() {
  1906. return {
  1907. name: { type: new _definition.GraphQLNonNull(_scalars.GraphQLString) },
  1908. description: { type: _scalars.GraphQLString },
  1909. args: {
  1910. type: new _definition.GraphQLNonNull(new _definition.GraphQLList(new _definition.GraphQLNonNull(__InputValue))),
  1911. resolve: function resolve(field) {
  1912. return field.args || [];
  1913. }
  1914. },
  1915. type: { type: new _definition.GraphQLNonNull(__Type) },
  1916. isDeprecated: { type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean) },
  1917. deprecationReason: {
  1918. type: _scalars.GraphQLString
  1919. }
  1920. };
  1921. }
  1922. });
  1923. var __InputValue = exports.__InputValue = new _definition.GraphQLObjectType({
  1924. name: '__InputValue',
  1925. isIntrospection: true,
  1926. description: 'Arguments provided to Fields or Directives and the input fields of an ' + 'InputObject are represented as Input Values which describe their type ' + 'and optionally a default value.',
  1927. fields: function fields() {
  1928. return {
  1929. name: { type: new _definition.GraphQLNonNull(_scalars.GraphQLString) },
  1930. description: { type: _scalars.GraphQLString },
  1931. type: { type: new _definition.GraphQLNonNull(__Type) },
  1932. defaultValue: {
  1933. type: _scalars.GraphQLString,
  1934. description: 'A GraphQL-formatted string representing the default value for this ' + 'input value.',
  1935. resolve: function resolve(inputVal) {
  1936. return (0, _isInvalid2.default)(inputVal.defaultValue) ? null : (0, _printer.print)((0, _astFromValue.astFromValue)(inputVal.defaultValue, inputVal.type));
  1937. }
  1938. }
  1939. };
  1940. }
  1941. });
  1942. var __EnumValue = exports.__EnumValue = new _definition.GraphQLObjectType({
  1943. name: '__EnumValue',
  1944. isIntrospection: true,
  1945. description: 'One possible value for a given Enum. Enum values are unique values, not ' + 'a placeholder for a string or numeric value. However an Enum value is ' + 'returned in a JSON response as a string.',
  1946. fields: function fields() {
  1947. return {
  1948. name: { type: new _definition.GraphQLNonNull(_scalars.GraphQLString) },
  1949. description: { type: _scalars.GraphQLString },
  1950. isDeprecated: { type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean) },
  1951. deprecationReason: {
  1952. type: _scalars.GraphQLString
  1953. }
  1954. };
  1955. }
  1956. });
  1957. var TypeKind = exports.TypeKind = {
  1958. SCALAR: 'SCALAR',
  1959. OBJECT: 'OBJECT',
  1960. INTERFACE: 'INTERFACE',
  1961. UNION: 'UNION',
  1962. ENUM: 'ENUM',
  1963. INPUT_OBJECT: 'INPUT_OBJECT',
  1964. LIST: 'LIST',
  1965. NON_NULL: 'NON_NULL'
  1966. };
  1967. var __TypeKind = exports.__TypeKind = new _definition.GraphQLEnumType({
  1968. name: '__TypeKind',
  1969. isIntrospection: true,
  1970. description: 'An enum describing what kind of type a given `__Type` is.',
  1971. values: {
  1972. SCALAR: {
  1973. value: TypeKind.SCALAR,
  1974. description: 'Indicates this type is a scalar.'
  1975. },
  1976. OBJECT: {
  1977. value: TypeKind.OBJECT,
  1978. description: 'Indicates this type is an object. ' + '`fields` and `interfaces` are valid fields.'
  1979. },
  1980. INTERFACE: {
  1981. value: TypeKind.INTERFACE,
  1982. description: 'Indicates this type is an interface. ' + '`fields` and `possibleTypes` are valid fields.'
  1983. },
  1984. UNION: {
  1985. value: TypeKind.UNION,
  1986. description: 'Indicates this type is a union. ' + '`possibleTypes` is a valid field.'
  1987. },
  1988. ENUM: {
  1989. value: TypeKind.ENUM,
  1990. description: 'Indicates this type is an enum. ' + '`enumValues` is a valid field.'
  1991. },
  1992. INPUT_OBJECT: {
  1993. value: TypeKind.INPUT_OBJECT,
  1994. description: 'Indicates this type is an input object. ' + '`inputFields` is a valid field.'
  1995. },
  1996. LIST: {
  1997. value: TypeKind.LIST,
  1998. description: 'Indicates this type is a list. ' + '`ofType` is a valid field.'
  1999. },
  2000. NON_NULL: {
  2001. value: TypeKind.NON_NULL,
  2002. description: 'Indicates this type is a non-null. ' + '`ofType` is a valid field.'
  2003. }
  2004. }
  2005. });
  2006. /**
  2007. * Note that these are GraphQLField and not GraphQLFieldConfig,
  2008. * so the format for args is different.
  2009. */
  2010. var SchemaMetaFieldDef = exports.SchemaMetaFieldDef = {
  2011. name: '__schema',
  2012. type: new _definition.GraphQLNonNull(__Schema),
  2013. description: 'Access the current type schema of this server.',
  2014. args: [],
  2015. resolve: function resolve(source, args, context, _ref4) {
  2016. var schema = _ref4.schema;
  2017. return schema;
  2018. }
  2019. };
  2020. var TypeMetaFieldDef = exports.TypeMetaFieldDef = {
  2021. name: '__type',
  2022. type: __Type,
  2023. description: 'Request the type information of a single type.',
  2024. args: [{ name: 'name', type: new _definition.GraphQLNonNull(_scalars.GraphQLString) }],
  2025. resolve: function resolve(source, _ref5, context, _ref6) {
  2026. var name = _ref5.name;
  2027. var schema = _ref6.schema;
  2028. return schema.getType(name);
  2029. }
  2030. };
  2031. var TypeNameMetaFieldDef = exports.TypeNameMetaFieldDef = {
  2032. name: '__typename',
  2033. type: new _definition.GraphQLNonNull(_scalars.GraphQLString),
  2034. description: 'The name of the current Object type at runtime.',
  2035. args: [],
  2036. resolve: function resolve(source, args, context, _ref7) {
  2037. var parentType = _ref7.parentType;
  2038. return parentType.name;
  2039. }
  2040. };
  2041. /***/ }),
  2042. /* 12 */
  2043. /***/ (function(module, exports, __webpack_require__) {
  2044. "use strict";
  2045. Object.defineProperty(exports, "__esModule", {
  2046. value: true
  2047. });
  2048. exports.default = keyMap;
  2049. /**
  2050. * Copyright (c) 2015, Facebook, Inc.
  2051. * All rights reserved.
  2052. *
  2053. * This source code is licensed under the BSD-style license found in the
  2054. * LICENSE file in the root directory of this source tree. An additional grant
  2055. * of patent rights can be found in the PATENTS file in the same directory.
  2056. */
  2057. /**
  2058. * Creates a keyed JS object from an array, given a function to produce the keys
  2059. * for each value in the array.
  2060. *
  2061. * This provides a convenient lookup for the array items if the key function
  2062. * produces unique results.
  2063. *
  2064. * const phoneBook = [
  2065. * { name: 'Jon', num: '555-1234' },
  2066. * { name: 'Jenny', num: '867-5309' }
  2067. * ]
  2068. *
  2069. * // { Jon: { name: 'Jon', num: '555-1234' },
  2070. * // Jenny: { name: 'Jenny', num: '867-5309' } }
  2071. * const entriesByName = keyMap(
  2072. * phoneBook,
  2073. * entry => entry.name
  2074. * )
  2075. *
  2076. * // { name: 'Jenny', num: '857-6309' }
  2077. * const jennyEntry = entriesByName['Jenny']
  2078. *
  2079. */
  2080. function keyMap(list, keyFn) {
  2081. return list.reduce(function (map, item) {
  2082. return map[keyFn(item)] = item, map;
  2083. }, {});
  2084. }
  2085. /***/ }),
  2086. /* 13 */
  2087. /***/ (function(module, exports, __webpack_require__) {
  2088. "use strict";
  2089. Object.defineProperty(exports, "__esModule", {
  2090. value: true
  2091. });
  2092. exports.GraphQLError = GraphQLError;
  2093. var _location = __webpack_require__(25);
  2094. /**
  2095. * A GraphQLError describes an Error found during the parse, validate, or
  2096. * execute phases of performing a GraphQL operation. In addition to a message
  2097. * and stack trace, it also includes information about the locations in a
  2098. * GraphQL document and/or execution result that correspond to the Error.
  2099. */
  2100. function GraphQLError( // eslint-disable-line no-redeclare
  2101. message, nodes, source, positions, path, originalError) {
  2102. // Include (non-enumerable) stack trace.
  2103. if (originalError && originalError.stack) {
  2104. Object.defineProperty(this, 'stack', {
  2105. value: originalError.stack,
  2106. writable: true,
  2107. configurable: true
  2108. });
  2109. } else if (Error.captureStackTrace) {
  2110. Error.captureStackTrace(this, GraphQLError);
  2111. } else {
  2112. Object.defineProperty(this, 'stack', {
  2113. value: Error().stack,
  2114. writable: true,
  2115. configurable: true
  2116. });
  2117. }
  2118. // Compute locations in the source for the given nodes/positions.
  2119. var _source = source;
  2120. if (!_source && nodes && nodes.length > 0) {
  2121. var node = nodes[0];
  2122. _source = node && node.loc && node.loc.source;
  2123. }
  2124. var _positions = positions;
  2125. if (!_positions && nodes) {
  2126. _positions = nodes.filter(function (node) {
  2127. return Boolean(node.loc);
  2128. }).map(function (node) {
  2129. return node.loc.start;
  2130. });
  2131. }
  2132. if (_positions && _positions.length === 0) {
  2133. _positions = undefined;
  2134. }
  2135. var _locations = void 0;
  2136. var _source2 = _source; // seems here Flow need a const to resolve type.
  2137. if (_source2 && _positions) {
  2138. _locations = _positions.map(function (pos) {
  2139. return (0, _location.getLocation)(_source2, pos);
  2140. });
  2141. }
  2142. Object.defineProperties(this, {
  2143. message: {
  2144. value: message,
  2145. // By being enumerable, JSON.stringify will include `message` in the
  2146. // resulting output. This ensures that the simplist possible GraphQL
  2147. // service adheres to the spec.
  2148. enumerable: true,
  2149. writable: true
  2150. },
  2151. locations: {
  2152. // Coercing falsey values to undefined ensures they will not be included
  2153. // in JSON.stringify() when not provided.
  2154. value: _locations || undefined,
  2155. // By being enumerable, JSON.stringify will include `locations` in the
  2156. // resulting output. This ensures that the simplist possible GraphQL
  2157. // service adheres to the spec.
  2158. enumerable: true
  2159. },
  2160. path: {
  2161. // Coercing falsey values to undefined ensures they will not be included
  2162. // in JSON.stringify() when not provided.
  2163. value: path || undefined,
  2164. // By being enumerable, JSON.stringify will include `path` in the
  2165. // resulting output. This ensures that the simplist possible GraphQL
  2166. // service adheres to the spec.
  2167. enumerable: true
  2168. },
  2169. nodes: {
  2170. value: nodes || undefined
  2171. },
  2172. source: {
  2173. value: _source || undefined
  2174. },
  2175. positions: {
  2176. value: _positions || undefined
  2177. },
  2178. originalError: {
  2179. value: originalError
  2180. }
  2181. });
  2182. }
  2183. /**
  2184. * Copyright (c) 2015, Facebook, Inc.
  2185. * All rights reserved.
  2186. *
  2187. * This source code is licensed under the BSD-style license found in the
  2188. * LICENSE file in the root directory of this source tree. An additional grant
  2189. * of patent rights can be found in the PATENTS file in the same directory.
  2190. */
  2191. GraphQLError.prototype = Object.create(Error.prototype, {
  2192. constructor: { value: GraphQLError },
  2193. name: { value: 'GraphQLError' }
  2194. });
  2195. /***/ }),
  2196. /* 14 */
  2197. /***/ (function(module, exports, __webpack_require__) {
  2198. "use strict";
  2199. Object.defineProperty(exports, "__esModule", {
  2200. value: true
  2201. });
  2202. exports.default = isInvalid;
  2203. /**
  2204. * Copyright (c) 2015, Facebook, Inc.
  2205. * All rights reserved.
  2206. *
  2207. * This source code is licensed under the BSD-style license found in the
  2208. * LICENSE file in the root directory of this source tree. An additional grant
  2209. * of patent rights can be found in the PATENTS file in the same directory.
  2210. */
  2211. /**
  2212. * Returns true if a value is undefined, or NaN.
  2213. */
  2214. function isInvalid(value) {
  2215. return value === undefined || value !== value;
  2216. }
  2217. /***/ }),
  2218. /* 15 */
  2219. /***/ (function(module, exports, __webpack_require__) {
  2220. "use strict";
  2221. Object.defineProperty(exports, "__esModule", {
  2222. value: true
  2223. });
  2224. exports.visit = visit;
  2225. exports.visitInParallel = visitInParallel;
  2226. exports.visitWithTypeInfo = visitWithTypeInfo;
  2227. /**
  2228. * Copyright (c) 2015, Facebook, Inc.
  2229. * All rights reserved.
  2230. *
  2231. * This source code is licensed under the BSD-style license found in the
  2232. * LICENSE file in the root directory of this source tree. An additional grant
  2233. * of patent rights can be found in the PATENTS file in the same directory.
  2234. */
  2235. var QueryDocumentKeys = exports.QueryDocumentKeys = {
  2236. Name: [],
  2237. Document: ['definitions'],
  2238. OperationDefinition: ['name', 'variableDefinitions', 'directives', 'selectionSet'],
  2239. VariableDefinition: ['variable', 'type', 'defaultValue'],
  2240. Variable: ['name'],
  2241. SelectionSet: ['selections'],
  2242. Field: ['alias', 'name', 'arguments', 'directives', 'selectionSet'],
  2243. Argument: ['name', 'value'],
  2244. FragmentSpread: ['name', 'directives'],
  2245. InlineFragment: ['typeCondition', 'directives', 'selectionSet'],
  2246. FragmentDefinition: ['name', 'typeCondition', 'directives', 'selectionSet'],
  2247. IntValue: [],
  2248. FloatValue: [],
  2249. StringValue: [],
  2250. BooleanValue: [],
  2251. NullValue: [],
  2252. EnumValue: [],
  2253. ListValue: ['values'],
  2254. ObjectValue: ['fields'],
  2255. ObjectField: ['name', 'value'],
  2256. Directive: ['name', 'arguments'],
  2257. NamedType: ['name'],
  2258. ListType: ['type'],
  2259. NonNullType: ['type'],
  2260. SchemaDefinition: ['directives', 'operationTypes'],
  2261. OperationTypeDefinition: ['type'],
  2262. ScalarTypeDefinition: ['name', 'directives'],
  2263. ObjectTypeDefinition: ['name', 'interfaces', 'directives', 'fields'],
  2264. FieldDefinition: ['name', 'arguments', 'type', 'directives'],
  2265. InputValueDefinition: ['name', 'type', 'defaultValue', 'directives'],
  2266. InterfaceTypeDefinition: ['name', 'directives', 'fields'],
  2267. UnionTypeDefinition: ['name', 'directives', 'types'],
  2268. EnumTypeDefinition: ['name', 'directives', 'values'],
  2269. EnumValueDefinition: ['name', 'directives'],
  2270. InputObjectTypeDefinition: ['name', 'directives', 'fields'],
  2271. TypeExtensionDefinition: ['definition'],
  2272. DirectiveDefinition: ['name', 'arguments', 'locations']
  2273. };
  2274. var BREAK = exports.BREAK = {};
  2275. /**
  2276. * visit() will walk through an AST using a depth first traversal, calling
  2277. * the visitor's enter function at each node in the traversal, and calling the
  2278. * leave function after visiting that node and all of its child nodes.
  2279. *
  2280. * By returning different values from the enter and leave functions, the
  2281. * behavior of the visitor can be altered, including skipping over a sub-tree of
  2282. * the AST (by returning false), editing the AST by returning a value or null
  2283. * to remove the value, or to stop the whole traversal by returning BREAK.
  2284. *
  2285. * When using visit() to edit an AST, the original AST will not be modified, and
  2286. * a new version of the AST with the changes applied will be returned from the
  2287. * visit function.
  2288. *
  2289. * const editedAST = visit(ast, {
  2290. * enter(node, key, parent, path, ancestors) {
  2291. * // @return
  2292. * // undefined: no action
  2293. * // false: skip visiting this node
  2294. * // visitor.BREAK: stop visiting altogether
  2295. * // null: delete this node
  2296. * // any value: replace this node with the returned value
  2297. * },
  2298. * leave(node, key, parent, path, ancestors) {
  2299. * // @return
  2300. * // undefined: no action
  2301. * // false: no action
  2302. * // visitor.BREAK: stop visiting altogether
  2303. * // null: delete this node
  2304. * // any value: replace this node with the returned value
  2305. * }
  2306. * });
  2307. *
  2308. * Alternatively to providing enter() and leave() functions, a visitor can
  2309. * instead provide functions named the same as the kinds of AST nodes, or
  2310. * enter/leave visitors at a named key, leading to four permutations of
  2311. * visitor API:
  2312. *
  2313. * 1) Named visitors triggered when entering a node a specific kind.
  2314. *
  2315. * visit(ast, {
  2316. * Kind(node) {
  2317. * // enter the "Kind" node
  2318. * }
  2319. * })
  2320. *
  2321. * 2) Named visitors that trigger upon entering and leaving a node of
  2322. * a specific kind.
  2323. *
  2324. * visit(ast, {
  2325. * Kind: {
  2326. * enter(node) {
  2327. * // enter the "Kind" node
  2328. * }
  2329. * leave(node) {
  2330. * // leave the "Kind" node
  2331. * }
  2332. * }
  2333. * })
  2334. *
  2335. * 3) Generic visitors that trigger upon entering and leaving any node.
  2336. *
  2337. * visit(ast, {
  2338. * enter(node) {
  2339. * // enter any node
  2340. * },
  2341. * leave(node) {
  2342. * // leave any node
  2343. * }
  2344. * })
  2345. *
  2346. * 4) Parallel visitors for entering and leaving nodes of a specific kind.
  2347. *
  2348. * visit(ast, {
  2349. * enter: {
  2350. * Kind(node) {
  2351. * // enter the "Kind" node
  2352. * }
  2353. * },
  2354. * leave: {
  2355. * Kind(node) {
  2356. * // leave the "Kind" node
  2357. * }
  2358. * }
  2359. * })
  2360. */
  2361. function visit(root, visitor, keyMap) {
  2362. var visitorKeys = keyMap || QueryDocumentKeys;
  2363. var stack = void 0;
  2364. var inArray = Array.isArray(root);
  2365. var keys = [root];
  2366. var index = -1;
  2367. var edits = [];
  2368. var parent = void 0;
  2369. var path = [];
  2370. var ancestors = [];
  2371. var newRoot = root;
  2372. do {
  2373. index++;
  2374. var isLeaving = index === keys.length;
  2375. var key = void 0;
  2376. var node = void 0;
  2377. var isEdited = isLeaving && edits.length !== 0;
  2378. if (isLeaving) {
  2379. key = ancestors.length === 0 ? undefined : path.pop();
  2380. node = parent;
  2381. parent = ancestors.pop();
  2382. if (isEdited) {
  2383. if (inArray) {
  2384. node = node.slice();
  2385. } else {
  2386. var clone = {};
  2387. for (var k in node) {
  2388. if (node.hasOwnProperty(k)) {
  2389. clone[k] = node[k];
  2390. }
  2391. }
  2392. node = clone;
  2393. }
  2394. var editOffset = 0;
  2395. for (var ii = 0; ii < edits.length; ii++) {
  2396. var editKey = edits[ii][0];
  2397. var editValue = edits[ii][1];
  2398. if (inArray) {
  2399. editKey -= editOffset;
  2400. }
  2401. if (inArray && editValue === null) {
  2402. node.splice(editKey, 1);
  2403. editOffset++;
  2404. } else {
  2405. node[editKey] = editValue;
  2406. }
  2407. }
  2408. }
  2409. index = stack.index;
  2410. keys = stack.keys;
  2411. edits = stack.edits;
  2412. inArray = stack.inArray;
  2413. stack = stack.prev;
  2414. } else {
  2415. key = parent ? inArray ? index : keys[index] : undefined;
  2416. node = parent ? parent[key] : newRoot;
  2417. if (node === null || node === undefined) {
  2418. continue;
  2419. }
  2420. if (parent) {
  2421. path.push(key);
  2422. }
  2423. }
  2424. var result = void 0;
  2425. if (!Array.isArray(node)) {
  2426. if (!isNode(node)) {
  2427. throw new Error('Invalid AST Node: ' + JSON.stringify(node));
  2428. }
  2429. var visitFn = getVisitFn(visitor, node.kind, isLeaving);
  2430. if (visitFn) {
  2431. result = visitFn.call(visitor, node, key, parent, path, ancestors);
  2432. if (result === BREAK) {
  2433. break;
  2434. }
  2435. if (result === false) {
  2436. if (!isLeaving) {
  2437. path.pop();
  2438. continue;
  2439. }
  2440. } else if (result !== undefined) {
  2441. edits.push([key, result]);
  2442. if (!isLeaving) {
  2443. if (isNode(result)) {
  2444. node = result;
  2445. } else {
  2446. path.pop();
  2447. continue;
  2448. }
  2449. }
  2450. }
  2451. }
  2452. }
  2453. if (result === undefined && isEdited) {
  2454. edits.push([key, node]);
  2455. }
  2456. if (!isLeaving) {
  2457. stack = { inArray: inArray, index: index, keys: keys, edits: edits, prev: stack };
  2458. inArray = Array.isArray(node);
  2459. keys = inArray ? node : visitorKeys[node.kind] || [];
  2460. index = -1;
  2461. edits = [];
  2462. if (parent) {
  2463. ancestors.push(parent);
  2464. }
  2465. parent = node;
  2466. }
  2467. } while (stack !== undefined);
  2468. if (edits.length !== 0) {
  2469. newRoot = edits[edits.length - 1][1];
  2470. }
  2471. return newRoot;
  2472. }
  2473. function isNode(maybeNode) {
  2474. return maybeNode && typeof maybeNode.kind === 'string';
  2475. }
  2476. /**
  2477. * Creates a new visitor instance which delegates to many visitors to run in
  2478. * parallel. Each visitor will be visited for each node before moving on.
  2479. *
  2480. * If a prior visitor edits a node, no following visitors will see that node.
  2481. */
  2482. function visitInParallel(visitors) {
  2483. var skipping = new Array(visitors.length);
  2484. return {
  2485. enter: function enter(node) {
  2486. for (var i = 0; i < visitors.length; i++) {
  2487. if (!skipping[i]) {
  2488. var fn = getVisitFn(visitors[i], node.kind, /* isLeaving */false);
  2489. if (fn) {
  2490. var result = fn.apply(visitors[i], arguments);
  2491. if (result === false) {
  2492. skipping[i] = node;
  2493. } else if (result === BREAK) {
  2494. skipping[i] = BREAK;
  2495. } else if (result !== undefined) {
  2496. return result;
  2497. }
  2498. }
  2499. }
  2500. }
  2501. },
  2502. leave: function leave(node) {
  2503. for (var i = 0; i < visitors.length; i++) {
  2504. if (!skipping[i]) {
  2505. var fn = getVisitFn(visitors[i], node.kind, /* isLeaving */true);
  2506. if (fn) {
  2507. var result = fn.apply(visitors[i], arguments);
  2508. if (result === BREAK) {
  2509. skipping[i] = BREAK;
  2510. } else if (result !== undefined && result !== false) {
  2511. return result;
  2512. }
  2513. }
  2514. } else if (skipping[i] === node) {
  2515. skipping[i] = null;
  2516. }
  2517. }
  2518. }
  2519. };
  2520. }
  2521. /**
  2522. * Creates a new visitor instance which maintains a provided TypeInfo instance
  2523. * along with visiting visitor.
  2524. */
  2525. function visitWithTypeInfo(typeInfo, visitor) {
  2526. return {
  2527. enter: function enter(node) {
  2528. typeInfo.enter(node);
  2529. var fn = getVisitFn(visitor, node.kind, /* isLeaving */false);
  2530. if (fn) {
  2531. var result = fn.apply(visitor, arguments);
  2532. if (result !== undefined) {
  2533. typeInfo.leave(node);
  2534. if (isNode(result)) {
  2535. typeInfo.enter(result);
  2536. }
  2537. }
  2538. return result;
  2539. }
  2540. },
  2541. leave: function leave(node) {
  2542. var fn = getVisitFn(visitor, node.kind, /* isLeaving */true);
  2543. var result = void 0;
  2544. if (fn) {
  2545. result = fn.apply(visitor, arguments);
  2546. }
  2547. typeInfo.leave(node);
  2548. return result;
  2549. }
  2550. };
  2551. }
  2552. /**
  2553. * Given a visitor instance, if it is leaving or not, and a node kind, return
  2554. * the function the visitor runtime should call.
  2555. */
  2556. function getVisitFn(visitor, kind, isLeaving) {
  2557. var kindVisitor = visitor[kind];
  2558. if (kindVisitor) {
  2559. if (!isLeaving && typeof kindVisitor === 'function') {
  2560. // { Kind() {} }
  2561. return kindVisitor;
  2562. }
  2563. var kindSpecificVisitor = isLeaving ? kindVisitor.leave : kindVisitor.enter;
  2564. if (typeof kindSpecificVisitor === 'function') {
  2565. // { Kind: { enter() {}, leave() {} } }
  2566. return kindSpecificVisitor;
  2567. }
  2568. } else {
  2569. var specificVisitor = isLeaving ? visitor.leave : visitor.enter;
  2570. if (specificVisitor) {
  2571. if (typeof specificVisitor === 'function') {
  2572. // { enter() {}, leave() {} }
  2573. return specificVisitor;
  2574. }
  2575. var specificKindVisitor = specificVisitor[kind];
  2576. if (typeof specificKindVisitor === 'function') {
  2577. // { enter: { Kind() {} }, leave: { Kind() {} } }
  2578. return specificKindVisitor;
  2579. }
  2580. }
  2581. }
  2582. }
  2583. /***/ }),
  2584. /* 16 */
  2585. /***/ (function(module, exports, __webpack_require__) {
  2586. "use strict";
  2587. Object.defineProperty(exports, "__esModule", {
  2588. value: true
  2589. });
  2590. exports.valueFromAST = valueFromAST;
  2591. var _keyMap = __webpack_require__(12);
  2592. var _keyMap2 = _interopRequireDefault(_keyMap);
  2593. var _invariant = __webpack_require__(3);
  2594. var _invariant2 = _interopRequireDefault(_invariant);
  2595. var _isNullish = __webpack_require__(6);
  2596. var _isNullish2 = _interopRequireDefault(_isNullish);
  2597. var _isInvalid = __webpack_require__(14);
  2598. var _isInvalid2 = _interopRequireDefault(_isInvalid);
  2599. var _kinds = __webpack_require__(2);
  2600. var Kind = _interopRequireWildcard(_kinds);
  2601. var _definition = __webpack_require__(1);
  2602. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  2603. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  2604. /**
  2605. * Produces a JavaScript value given a GraphQL Value AST.
  2606. *
  2607. * A GraphQL type must be provided, which will be used to interpret different
  2608. * GraphQL Value literals.
  2609. *
  2610. * Returns `undefined` when the value could not be validly coerced according to
  2611. * the provided type.
  2612. *
  2613. * | GraphQL Value | JSON Value |
  2614. * | -------------------- | ------------- |
  2615. * | Input Object | Object |
  2616. * | List | Array |
  2617. * | Boolean | Boolean |
  2618. * | String | String |
  2619. * | Int / Float | Number |
  2620. * | Enum Value | Mixed |
  2621. * | NullValue | null |
  2622. *
  2623. */
  2624. /**
  2625. * Copyright (c) 2015, Facebook, Inc.
  2626. * All rights reserved.
  2627. *
  2628. * This source code is licensed under the BSD-style license found in the
  2629. * LICENSE file in the root directory of this source tree. An additional grant
  2630. * of patent rights can be found in the PATENTS file in the same directory.
  2631. */
  2632. function valueFromAST(valueNode, type, variables) {
  2633. if (!valueNode) {
  2634. // When there is no node, then there is also no value.
  2635. // Importantly, this is different from returning the value null.
  2636. return;
  2637. }
  2638. if (type instanceof _definition.GraphQLNonNull) {
  2639. if (valueNode.kind === Kind.NULL) {
  2640. return; // Invalid: intentionally return no value.
  2641. }
  2642. return valueFromAST(valueNode, type.ofType, variables);
  2643. }
  2644. if (valueNode.kind === Kind.NULL) {
  2645. // This is explicitly returning the value null.
  2646. return null;
  2647. }
  2648. if (valueNode.kind === Kind.VARIABLE) {
  2649. var variableName = valueNode.name.value;
  2650. if (!variables || (0, _isInvalid2.default)(variables[variableName])) {
  2651. // No valid return value.
  2652. return;
  2653. }
  2654. // Note: we're not doing any checking that this variable is correct. We're
  2655. // assuming that this query has been validated and the variable usage here
  2656. // is of the correct type.
  2657. return variables[variableName];
  2658. }
  2659. if (type instanceof _definition.GraphQLList) {
  2660. var itemType = type.ofType;
  2661. if (valueNode.kind === Kind.LIST) {
  2662. var coercedValues = [];
  2663. var itemNodes = valueNode.values;
  2664. for (var i = 0; i < itemNodes.length; i++) {
  2665. if (isMissingVariable(itemNodes[i], variables)) {
  2666. // If an array contains a missing variable, it is either coerced to
  2667. // null or if the item type is non-null, it considered invalid.
  2668. if (itemType instanceof _definition.GraphQLNonNull) {
  2669. return; // Invalid: intentionally return no value.
  2670. }
  2671. coercedValues.push(null);
  2672. } else {
  2673. var itemValue = valueFromAST(itemNodes[i], itemType, variables);
  2674. if ((0, _isInvalid2.default)(itemValue)) {
  2675. return; // Invalid: intentionally return no value.
  2676. }
  2677. coercedValues.push(itemValue);
  2678. }
  2679. }
  2680. return coercedValues;
  2681. }
  2682. var coercedValue = valueFromAST(valueNode, itemType, variables);
  2683. if ((0, _isInvalid2.default)(coercedValue)) {
  2684. return; // Invalid: intentionally return no value.
  2685. }
  2686. return [coercedValue];
  2687. }
  2688. if (type instanceof _definition.GraphQLInputObjectType) {
  2689. if (valueNode.kind !== Kind.OBJECT) {
  2690. return; // Invalid: intentionally return no value.
  2691. }
  2692. var coercedObj = Object.create(null);
  2693. var fields = type.getFields();
  2694. var fieldNodes = (0, _keyMap2.default)(valueNode.fields, function (field) {
  2695. return field.name.value;
  2696. });
  2697. var fieldNames = Object.keys(fields);
  2698. for (var _i = 0; _i < fieldNames.length; _i++) {
  2699. var fieldName = fieldNames[_i];
  2700. var field = fields[fieldName];
  2701. var fieldNode = fieldNodes[fieldName];
  2702. if (!fieldNode || isMissingVariable(fieldNode.value, variables)) {
  2703. if (!(0, _isInvalid2.default)(field.defaultValue)) {
  2704. coercedObj[fieldName] = field.defaultValue;
  2705. } else if (field.type instanceof _definition.GraphQLNonNull) {
  2706. return; // Invalid: intentionally return no value.
  2707. }
  2708. continue;
  2709. }
  2710. var fieldValue = valueFromAST(fieldNode.value, field.type, variables);
  2711. if ((0, _isInvalid2.default)(fieldValue)) {
  2712. return; // Invalid: intentionally return no value.
  2713. }
  2714. coercedObj[fieldName] = fieldValue;
  2715. }
  2716. return coercedObj;
  2717. }
  2718. (0, _invariant2.default)(type instanceof _definition.GraphQLScalarType || type instanceof _definition.GraphQLEnumType, 'Must be input type');
  2719. var parsed = type.parseLiteral(valueNode);
  2720. if ((0, _isNullish2.default)(parsed)) {
  2721. // null or invalid values represent a failure to parse correctly,
  2722. // in which case no value is returned.
  2723. return;
  2724. }
  2725. return parsed;
  2726. }
  2727. // Returns true if the provided valueNode is a variable which is not defined
  2728. // in the set of variables.
  2729. function isMissingVariable(valueNode, variables) {
  2730. return valueNode.kind === Kind.VARIABLE && (!variables || (0, _isInvalid2.default)(variables[valueNode.name.value]));
  2731. }
  2732. /***/ }),
  2733. /* 17 */
  2734. /***/ (function(module, exports, __webpack_require__) {
  2735. "use strict";
  2736. Object.defineProperty(exports, "__esModule", {
  2737. value: true
  2738. });
  2739. exports.parse = parse;
  2740. exports.parseValue = parseValue;
  2741. exports.parseType = parseType;
  2742. exports.parseConstValue = parseConstValue;
  2743. exports.parseTypeReference = parseTypeReference;
  2744. exports.parseNamedType = parseNamedType;
  2745. var _source = __webpack_require__(26);
  2746. var _error = __webpack_require__(0);
  2747. var _lexer = __webpack_require__(24);
  2748. var _kinds = __webpack_require__(2);
  2749. /**
  2750. * Given a GraphQL source, parses it into a Document.
  2751. * Throws GraphQLError if a syntax error is encountered.
  2752. */
  2753. /**
  2754. * Configuration options to control parser behavior
  2755. */
  2756. /**
  2757. * Copyright (c) 2015, Facebook, Inc.
  2758. * All rights reserved.
  2759. *
  2760. * This source code is licensed under the BSD-style license found in the
  2761. * LICENSE file in the root directory of this source tree. An additional grant
  2762. * of patent rights can be found in the PATENTS file in the same directory.
  2763. */
  2764. function parse(source, options) {
  2765. var sourceObj = typeof source === 'string' ? new _source.Source(source) : source;
  2766. var lexer = (0, _lexer.createLexer)(sourceObj, options || {});
  2767. return parseDocument(lexer);
  2768. }
  2769. /**
  2770. * Given a string containing a GraphQL value (ex. `[42]`), parse the AST for
  2771. * that value.
  2772. * Throws GraphQLError if a syntax error is encountered.
  2773. *
  2774. * This is useful within tools that operate upon GraphQL Values directly and
  2775. * in isolation of complete GraphQL documents.
  2776. *
  2777. * Consider providing the results to the utility function: valueFromAST().
  2778. */
  2779. function parseValue(source, options) {
  2780. var sourceObj = typeof source === 'string' ? new _source.Source(source) : source;
  2781. var lexer = (0, _lexer.createLexer)(sourceObj, options || {});
  2782. expect(lexer, _lexer.TokenKind.SOF);
  2783. var value = parseValueLiteral(lexer, false);
  2784. expect(lexer, _lexer.TokenKind.EOF);
  2785. return value;
  2786. }
  2787. /**
  2788. * Given a string containing a GraphQL Type (ex. `[Int!]`), parse the AST for
  2789. * that type.
  2790. * Throws GraphQLError if a syntax error is encountered.
  2791. *
  2792. * This is useful within tools that operate upon GraphQL Types directly and
  2793. * in isolation of complete GraphQL documents.
  2794. *
  2795. * Consider providing the results to the utility function: typeFromAST().
  2796. */
  2797. function parseType(source, options) {
  2798. var sourceObj = typeof source === 'string' ? new _source.Source(source) : source;
  2799. var lexer = (0, _lexer.createLexer)(sourceObj, options || {});
  2800. expect(lexer, _lexer.TokenKind.SOF);
  2801. var type = parseTypeReference(lexer);
  2802. expect(lexer, _lexer.TokenKind.EOF);
  2803. return type;
  2804. }
  2805. /**
  2806. * Converts a name lex token into a name parse node.
  2807. */
  2808. function parseName(lexer) {
  2809. var token = expect(lexer, _lexer.TokenKind.NAME);
  2810. return {
  2811. kind: _kinds.NAME,
  2812. value: token.value,
  2813. loc: loc(lexer, token)
  2814. };
  2815. }
  2816. // Implements the parsing rules in the Document section.
  2817. /**
  2818. * Document : Definition+
  2819. */
  2820. function parseDocument(lexer) {
  2821. var start = lexer.token;
  2822. expect(lexer, _lexer.TokenKind.SOF);
  2823. var definitions = [];
  2824. do {
  2825. definitions.push(parseDefinition(lexer));
  2826. } while (!skip(lexer, _lexer.TokenKind.EOF));
  2827. return {
  2828. kind: _kinds.DOCUMENT,
  2829. definitions: definitions,
  2830. loc: loc(lexer, start)
  2831. };
  2832. }
  2833. /**
  2834. * Definition :
  2835. * - OperationDefinition
  2836. * - FragmentDefinition
  2837. * - TypeSystemDefinition
  2838. */
  2839. function parseDefinition(lexer) {
  2840. if (peek(lexer, _lexer.TokenKind.BRACE_L)) {
  2841. return parseOperationDefinition(lexer);
  2842. }
  2843. if (peek(lexer, _lexer.TokenKind.NAME)) {
  2844. switch (lexer.token.value) {
  2845. // Note: subscription is an experimental non-spec addition.
  2846. case 'query':
  2847. case 'mutation':
  2848. case 'subscription':
  2849. return parseOperationDefinition(lexer);
  2850. case 'fragment':
  2851. return parseFragmentDefinition(lexer);
  2852. // Note: the Type System IDL is an experimental non-spec addition.
  2853. case 'schema':
  2854. case 'scalar':
  2855. case 'type':
  2856. case 'interface':
  2857. case 'union':
  2858. case 'enum':
  2859. case 'input':
  2860. case 'extend':
  2861. case 'directive':
  2862. return parseTypeSystemDefinition(lexer);
  2863. }
  2864. }
  2865. throw unexpected(lexer);
  2866. }
  2867. // Implements the parsing rules in the Operations section.
  2868. /**
  2869. * OperationDefinition :
  2870. * - SelectionSet
  2871. * - OperationType Name? VariableDefinitions? Directives? SelectionSet
  2872. */
  2873. function parseOperationDefinition(lexer) {
  2874. var start = lexer.token;
  2875. if (peek(lexer, _lexer.TokenKind.BRACE_L)) {
  2876. return {
  2877. kind: _kinds.OPERATION_DEFINITION,
  2878. operation: 'query',
  2879. name: null,
  2880. variableDefinitions: null,
  2881. directives: [],
  2882. selectionSet: parseSelectionSet(lexer),
  2883. loc: loc(lexer, start)
  2884. };
  2885. }
  2886. var operation = parseOperationType(lexer);
  2887. var name = void 0;
  2888. if (peek(lexer, _lexer.TokenKind.NAME)) {
  2889. name = parseName(lexer);
  2890. }
  2891. return {
  2892. kind: _kinds.OPERATION_DEFINITION,
  2893. operation: operation,
  2894. name: name,
  2895. variableDefinitions: parseVariableDefinitions(lexer),
  2896. directives: parseDirectives(lexer),
  2897. selectionSet: parseSelectionSet(lexer),
  2898. loc: loc(lexer, start)
  2899. };
  2900. }
  2901. /**
  2902. * OperationType : one of query mutation subscription
  2903. */
  2904. function parseOperationType(lexer) {
  2905. var operationToken = expect(lexer, _lexer.TokenKind.NAME);
  2906. switch (operationToken.value) {
  2907. case 'query':
  2908. return 'query';
  2909. case 'mutation':
  2910. return 'mutation';
  2911. // Note: subscription is an experimental non-spec addition.
  2912. case 'subscription':
  2913. return 'subscription';
  2914. }
  2915. throw unexpected(lexer, operationToken);
  2916. }
  2917. /**
  2918. * VariableDefinitions : ( VariableDefinition+ )
  2919. */
  2920. function parseVariableDefinitions(lexer) {
  2921. return peek(lexer, _lexer.TokenKind.PAREN_L) ? many(lexer, _lexer.TokenKind.PAREN_L, parseVariableDefinition, _lexer.TokenKind.PAREN_R) : [];
  2922. }
  2923. /**
  2924. * VariableDefinition : Variable : Type DefaultValue?
  2925. */
  2926. function parseVariableDefinition(lexer) {
  2927. var start = lexer.token;
  2928. return {
  2929. kind: _kinds.VARIABLE_DEFINITION,
  2930. variable: parseVariable(lexer),
  2931. type: (expect(lexer, _lexer.TokenKind.COLON), parseTypeReference(lexer)),
  2932. defaultValue: skip(lexer, _lexer.TokenKind.EQUALS) ? parseValueLiteral(lexer, true) : null,
  2933. loc: loc(lexer, start)
  2934. };
  2935. }
  2936. /**
  2937. * Variable : $ Name
  2938. */
  2939. function parseVariable(lexer) {
  2940. var start = lexer.token;
  2941. expect(lexer, _lexer.TokenKind.DOLLAR);
  2942. return {
  2943. kind: _kinds.VARIABLE,
  2944. name: parseName(lexer),
  2945. loc: loc(lexer, start)
  2946. };
  2947. }
  2948. /**
  2949. * SelectionSet : { Selection+ }
  2950. */
  2951. function parseSelectionSet(lexer) {
  2952. var start = lexer.token;
  2953. return {
  2954. kind: _kinds.SELECTION_SET,
  2955. selections: many(lexer, _lexer.TokenKind.BRACE_L, parseSelection, _lexer.TokenKind.BRACE_R),
  2956. loc: loc(lexer, start)
  2957. };
  2958. }
  2959. /**
  2960. * Selection :
  2961. * - Field
  2962. * - FragmentSpread
  2963. * - InlineFragment
  2964. */
  2965. function parseSelection(lexer) {
  2966. return peek(lexer, _lexer.TokenKind.SPREAD) ? parseFragment(lexer) : parseField(lexer);
  2967. }
  2968. /**
  2969. * Field : Alias? Name Arguments? Directives? SelectionSet?
  2970. *
  2971. * Alias : Name :
  2972. */
  2973. function parseField(lexer) {
  2974. var start = lexer.token;
  2975. var nameOrAlias = parseName(lexer);
  2976. var alias = void 0;
  2977. var name = void 0;
  2978. if (skip(lexer, _lexer.TokenKind.COLON)) {
  2979. alias = nameOrAlias;
  2980. name = parseName(lexer);
  2981. } else {
  2982. alias = null;
  2983. name = nameOrAlias;
  2984. }
  2985. return {
  2986. kind: _kinds.FIELD,
  2987. alias: alias,
  2988. name: name,
  2989. arguments: parseArguments(lexer),
  2990. directives: parseDirectives(lexer),
  2991. selectionSet: peek(lexer, _lexer.TokenKind.BRACE_L) ? parseSelectionSet(lexer) : null,
  2992. loc: loc(lexer, start)
  2993. };
  2994. }
  2995. /**
  2996. * Arguments : ( Argument+ )
  2997. */
  2998. function parseArguments(lexer) {
  2999. return peek(lexer, _lexer.TokenKind.PAREN_L) ? many(lexer, _lexer.TokenKind.PAREN_L, parseArgument, _lexer.TokenKind.PAREN_R) : [];
  3000. }
  3001. /**
  3002. * Argument : Name : Value
  3003. */
  3004. function parseArgument(lexer) {
  3005. var start = lexer.token;
  3006. return {
  3007. kind: _kinds.ARGUMENT,
  3008. name: parseName(lexer),
  3009. value: (expect(lexer, _lexer.TokenKind.COLON), parseValueLiteral(lexer, false)),
  3010. loc: loc(lexer, start)
  3011. };
  3012. }
  3013. // Implements the parsing rules in the Fragments section.
  3014. /**
  3015. * Corresponds to both FragmentSpread and InlineFragment in the spec.
  3016. *
  3017. * FragmentSpread : ... FragmentName Directives?
  3018. *
  3019. * InlineFragment : ... TypeCondition? Directives? SelectionSet
  3020. */
  3021. function parseFragment(lexer) {
  3022. var start = lexer.token;
  3023. expect(lexer, _lexer.TokenKind.SPREAD);
  3024. if (peek(lexer, _lexer.TokenKind.NAME) && lexer.token.value !== 'on') {
  3025. return {
  3026. kind: _kinds.FRAGMENT_SPREAD,
  3027. name: parseFragmentName(lexer),
  3028. directives: parseDirectives(lexer),
  3029. loc: loc(lexer, start)
  3030. };
  3031. }
  3032. var typeCondition = null;
  3033. if (lexer.token.value === 'on') {
  3034. lexer.advance();
  3035. typeCondition = parseNamedType(lexer);
  3036. }
  3037. return {
  3038. kind: _kinds.INLINE_FRAGMENT,
  3039. typeCondition: typeCondition,
  3040. directives: parseDirectives(lexer),
  3041. selectionSet: parseSelectionSet(lexer),
  3042. loc: loc(lexer, start)
  3043. };
  3044. }
  3045. /**
  3046. * FragmentDefinition :
  3047. * - fragment FragmentName on TypeCondition Directives? SelectionSet
  3048. *
  3049. * TypeCondition : NamedType
  3050. */
  3051. function parseFragmentDefinition(lexer) {
  3052. var start = lexer.token;
  3053. expectKeyword(lexer, 'fragment');
  3054. return {
  3055. kind: _kinds.FRAGMENT_DEFINITION,
  3056. name: parseFragmentName(lexer),
  3057. typeCondition: (expectKeyword(lexer, 'on'), parseNamedType(lexer)),
  3058. directives: parseDirectives(lexer),
  3059. selectionSet: parseSelectionSet(lexer),
  3060. loc: loc(lexer, start)
  3061. };
  3062. }
  3063. /**
  3064. * FragmentName : Name but not `on`
  3065. */
  3066. function parseFragmentName(lexer) {
  3067. if (lexer.token.value === 'on') {
  3068. throw unexpected(lexer);
  3069. }
  3070. return parseName(lexer);
  3071. }
  3072. // Implements the parsing rules in the Values section.
  3073. /**
  3074. * Value[Const] :
  3075. * - [~Const] Variable
  3076. * - IntValue
  3077. * - FloatValue
  3078. * - StringValue
  3079. * - BooleanValue
  3080. * - NullValue
  3081. * - EnumValue
  3082. * - ListValue[?Const]
  3083. * - ObjectValue[?Const]
  3084. *
  3085. * BooleanValue : one of `true` `false`
  3086. *
  3087. * NullValue : `null`
  3088. *
  3089. * EnumValue : Name but not `true`, `false` or `null`
  3090. */
  3091. function parseValueLiteral(lexer, isConst) {
  3092. var token = lexer.token;
  3093. switch (token.kind) {
  3094. case _lexer.TokenKind.BRACKET_L:
  3095. return parseList(lexer, isConst);
  3096. case _lexer.TokenKind.BRACE_L:
  3097. return parseObject(lexer, isConst);
  3098. case _lexer.TokenKind.INT:
  3099. lexer.advance();
  3100. return {
  3101. kind: _kinds.INT,
  3102. value: token.value,
  3103. loc: loc(lexer, token)
  3104. };
  3105. case _lexer.TokenKind.FLOAT:
  3106. lexer.advance();
  3107. return {
  3108. kind: _kinds.FLOAT,
  3109. value: token.value,
  3110. loc: loc(lexer, token)
  3111. };
  3112. case _lexer.TokenKind.STRING:
  3113. lexer.advance();
  3114. return {
  3115. kind: _kinds.STRING,
  3116. value: token.value,
  3117. loc: loc(lexer, token)
  3118. };
  3119. case _lexer.TokenKind.NAME:
  3120. if (token.value === 'true' || token.value === 'false') {
  3121. lexer.advance();
  3122. return {
  3123. kind: _kinds.BOOLEAN,
  3124. value: token.value === 'true',
  3125. loc: loc(lexer, token)
  3126. };
  3127. } else if (token.value === 'null') {
  3128. lexer.advance();
  3129. return {
  3130. kind: _kinds.NULL,
  3131. loc: loc(lexer, token)
  3132. };
  3133. }
  3134. lexer.advance();
  3135. return {
  3136. kind: _kinds.ENUM,
  3137. value: token.value,
  3138. loc: loc(lexer, token)
  3139. };
  3140. case _lexer.TokenKind.DOLLAR:
  3141. if (!isConst) {
  3142. return parseVariable(lexer);
  3143. }
  3144. break;
  3145. }
  3146. throw unexpected(lexer);
  3147. }
  3148. function parseConstValue(lexer) {
  3149. return parseValueLiteral(lexer, true);
  3150. }
  3151. function parseValueValue(lexer) {
  3152. return parseValueLiteral(lexer, false);
  3153. }
  3154. /**
  3155. * ListValue[Const] :
  3156. * - [ ]
  3157. * - [ Value[?Const]+ ]
  3158. */
  3159. function parseList(lexer, isConst) {
  3160. var start = lexer.token;
  3161. var item = isConst ? parseConstValue : parseValueValue;
  3162. return {
  3163. kind: _kinds.LIST,
  3164. values: any(lexer, _lexer.TokenKind.BRACKET_L, item, _lexer.TokenKind.BRACKET_R),
  3165. loc: loc(lexer, start)
  3166. };
  3167. }
  3168. /**
  3169. * ObjectValue[Const] :
  3170. * - { }
  3171. * - { ObjectField[?Const]+ }
  3172. */
  3173. function parseObject(lexer, isConst) {
  3174. var start = lexer.token;
  3175. expect(lexer, _lexer.TokenKind.BRACE_L);
  3176. var fields = [];
  3177. while (!skip(lexer, _lexer.TokenKind.BRACE_R)) {
  3178. fields.push(parseObjectField(lexer, isConst));
  3179. }
  3180. return {
  3181. kind: _kinds.OBJECT,
  3182. fields: fields,
  3183. loc: loc(lexer, start)
  3184. };
  3185. }
  3186. /**
  3187. * ObjectField[Const] : Name : Value[?Const]
  3188. */
  3189. function parseObjectField(lexer, isConst) {
  3190. var start = lexer.token;
  3191. return {
  3192. kind: _kinds.OBJECT_FIELD,
  3193. name: parseName(lexer),
  3194. value: (expect(lexer, _lexer.TokenKind.COLON), parseValueLiteral(lexer, isConst)),
  3195. loc: loc(lexer, start)
  3196. };
  3197. }
  3198. // Implements the parsing rules in the Directives section.
  3199. /**
  3200. * Directives : Directive+
  3201. */
  3202. function parseDirectives(lexer) {
  3203. var directives = [];
  3204. while (peek(lexer, _lexer.TokenKind.AT)) {
  3205. directives.push(parseDirective(lexer));
  3206. }
  3207. return directives;
  3208. }
  3209. /**
  3210. * Directive : @ Name Arguments?
  3211. */
  3212. function parseDirective(lexer) {
  3213. var start = lexer.token;
  3214. expect(lexer, _lexer.TokenKind.AT);
  3215. return {
  3216. kind: _kinds.DIRECTIVE,
  3217. name: parseName(lexer),
  3218. arguments: parseArguments(lexer),
  3219. loc: loc(lexer, start)
  3220. };
  3221. }
  3222. // Implements the parsing rules in the Types section.
  3223. /**
  3224. * Type :
  3225. * - NamedType
  3226. * - ListType
  3227. * - NonNullType
  3228. */
  3229. function parseTypeReference(lexer) {
  3230. var start = lexer.token;
  3231. var type = void 0;
  3232. if (skip(lexer, _lexer.TokenKind.BRACKET_L)) {
  3233. type = parseTypeReference(lexer);
  3234. expect(lexer, _lexer.TokenKind.BRACKET_R);
  3235. type = {
  3236. kind: _kinds.LIST_TYPE,
  3237. type: type,
  3238. loc: loc(lexer, start)
  3239. };
  3240. } else {
  3241. type = parseNamedType(lexer);
  3242. }
  3243. if (skip(lexer, _lexer.TokenKind.BANG)) {
  3244. return {
  3245. kind: _kinds.NON_NULL_TYPE,
  3246. type: type,
  3247. loc: loc(lexer, start)
  3248. };
  3249. }
  3250. return type;
  3251. }
  3252. /**
  3253. * NamedType : Name
  3254. */
  3255. function parseNamedType(lexer) {
  3256. var start = lexer.token;
  3257. return {
  3258. kind: _kinds.NAMED_TYPE,
  3259. name: parseName(lexer),
  3260. loc: loc(lexer, start)
  3261. };
  3262. }
  3263. // Implements the parsing rules in the Type Definition section.
  3264. /**
  3265. * TypeSystemDefinition :
  3266. * - SchemaDefinition
  3267. * - TypeDefinition
  3268. * - TypeExtensionDefinition
  3269. * - DirectiveDefinition
  3270. *
  3271. * TypeDefinition :
  3272. * - ScalarTypeDefinition
  3273. * - ObjectTypeDefinition
  3274. * - InterfaceTypeDefinition
  3275. * - UnionTypeDefinition
  3276. * - EnumTypeDefinition
  3277. * - InputObjectTypeDefinition
  3278. */
  3279. function parseTypeSystemDefinition(lexer) {
  3280. if (peek(lexer, _lexer.TokenKind.NAME)) {
  3281. switch (lexer.token.value) {
  3282. case 'schema':
  3283. return parseSchemaDefinition(lexer);
  3284. case 'scalar':
  3285. return parseScalarTypeDefinition(lexer);
  3286. case 'type':
  3287. return parseObjectTypeDefinition(lexer);
  3288. case 'interface':
  3289. return parseInterfaceTypeDefinition(lexer);
  3290. case 'union':
  3291. return parseUnionTypeDefinition(lexer);
  3292. case 'enum':
  3293. return parseEnumTypeDefinition(lexer);
  3294. case 'input':
  3295. return parseInputObjectTypeDefinition(lexer);
  3296. case 'extend':
  3297. return parseTypeExtensionDefinition(lexer);
  3298. case 'directive':
  3299. return parseDirectiveDefinition(lexer);
  3300. }
  3301. }
  3302. throw unexpected(lexer);
  3303. }
  3304. /**
  3305. * SchemaDefinition : schema Directives? { OperationTypeDefinition+ }
  3306. *
  3307. * OperationTypeDefinition : OperationType : NamedType
  3308. */
  3309. function parseSchemaDefinition(lexer) {
  3310. var start = lexer.token;
  3311. expectKeyword(lexer, 'schema');
  3312. var directives = parseDirectives(lexer);
  3313. var operationTypes = many(lexer, _lexer.TokenKind.BRACE_L, parseOperationTypeDefinition, _lexer.TokenKind.BRACE_R);
  3314. return {
  3315. kind: _kinds.SCHEMA_DEFINITION,
  3316. directives: directives,
  3317. operationTypes: operationTypes,
  3318. loc: loc(lexer, start)
  3319. };
  3320. }
  3321. function parseOperationTypeDefinition(lexer) {
  3322. var start = lexer.token;
  3323. var operation = parseOperationType(lexer);
  3324. expect(lexer, _lexer.TokenKind.COLON);
  3325. var type = parseNamedType(lexer);
  3326. return {
  3327. kind: _kinds.OPERATION_TYPE_DEFINITION,
  3328. operation: operation,
  3329. type: type,
  3330. loc: loc(lexer, start)
  3331. };
  3332. }
  3333. /**
  3334. * ScalarTypeDefinition : scalar Name Directives?
  3335. */
  3336. function parseScalarTypeDefinition(lexer) {
  3337. var start = lexer.token;
  3338. expectKeyword(lexer, 'scalar');
  3339. var name = parseName(lexer);
  3340. var directives = parseDirectives(lexer);
  3341. return {
  3342. kind: _kinds.SCALAR_TYPE_DEFINITION,
  3343. name: name,
  3344. directives: directives,
  3345. loc: loc(lexer, start)
  3346. };
  3347. }
  3348. /**
  3349. * ObjectTypeDefinition :
  3350. * - type Name ImplementsInterfaces? Directives? { FieldDefinition+ }
  3351. */
  3352. function parseObjectTypeDefinition(lexer) {
  3353. var start = lexer.token;
  3354. expectKeyword(lexer, 'type');
  3355. var name = parseName(lexer);
  3356. var interfaces = parseImplementsInterfaces(lexer);
  3357. var directives = parseDirectives(lexer);
  3358. var fields = any(lexer, _lexer.TokenKind.BRACE_L, parseFieldDefinition, _lexer.TokenKind.BRACE_R);
  3359. return {
  3360. kind: _kinds.OBJECT_TYPE_DEFINITION,
  3361. name: name,
  3362. interfaces: interfaces,
  3363. directives: directives,
  3364. fields: fields,
  3365. loc: loc(lexer, start)
  3366. };
  3367. }
  3368. /**
  3369. * ImplementsInterfaces : implements NamedType+
  3370. */
  3371. function parseImplementsInterfaces(lexer) {
  3372. var types = [];
  3373. if (lexer.token.value === 'implements') {
  3374. lexer.advance();
  3375. do {
  3376. types.push(parseNamedType(lexer));
  3377. } while (peek(lexer, _lexer.TokenKind.NAME));
  3378. }
  3379. return types;
  3380. }
  3381. /**
  3382. * FieldDefinition : Name ArgumentsDefinition? : Type Directives?
  3383. */
  3384. function parseFieldDefinition(lexer) {
  3385. var start = lexer.token;
  3386. var name = parseName(lexer);
  3387. var args = parseArgumentDefs(lexer);
  3388. expect(lexer, _lexer.TokenKind.COLON);
  3389. var type = parseTypeReference(lexer);
  3390. var directives = parseDirectives(lexer);
  3391. return {
  3392. kind: _kinds.FIELD_DEFINITION,
  3393. name: name,
  3394. arguments: args,
  3395. type: type,
  3396. directives: directives,
  3397. loc: loc(lexer, start)
  3398. };
  3399. }
  3400. /**
  3401. * ArgumentsDefinition : ( InputValueDefinition+ )
  3402. */
  3403. function parseArgumentDefs(lexer) {
  3404. if (!peek(lexer, _lexer.TokenKind.PAREN_L)) {
  3405. return [];
  3406. }
  3407. return many(lexer, _lexer.TokenKind.PAREN_L, parseInputValueDef, _lexer.TokenKind.PAREN_R);
  3408. }
  3409. /**
  3410. * InputValueDefinition : Name : Type DefaultValue? Directives?
  3411. */
  3412. function parseInputValueDef(lexer) {
  3413. var start = lexer.token;
  3414. var name = parseName(lexer);
  3415. expect(lexer, _lexer.TokenKind.COLON);
  3416. var type = parseTypeReference(lexer);
  3417. var defaultValue = null;
  3418. if (skip(lexer, _lexer.TokenKind.EQUALS)) {
  3419. defaultValue = parseConstValue(lexer);
  3420. }
  3421. var directives = parseDirectives(lexer);
  3422. return {
  3423. kind: _kinds.INPUT_VALUE_DEFINITION,
  3424. name: name,
  3425. type: type,
  3426. defaultValue: defaultValue,
  3427. directives: directives,
  3428. loc: loc(lexer, start)
  3429. };
  3430. }
  3431. /**
  3432. * InterfaceTypeDefinition : interface Name Directives? { FieldDefinition+ }
  3433. */
  3434. function parseInterfaceTypeDefinition(lexer) {
  3435. var start = lexer.token;
  3436. expectKeyword(lexer, 'interface');
  3437. var name = parseName(lexer);
  3438. var directives = parseDirectives(lexer);
  3439. var fields = any(lexer, _lexer.TokenKind.BRACE_L, parseFieldDefinition, _lexer.TokenKind.BRACE_R);
  3440. return {
  3441. kind: _kinds.INTERFACE_TYPE_DEFINITION,
  3442. name: name,
  3443. directives: directives,
  3444. fields: fields,
  3445. loc: loc(lexer, start)
  3446. };
  3447. }
  3448. /**
  3449. * UnionTypeDefinition : union Name Directives? = UnionMembers
  3450. */
  3451. function parseUnionTypeDefinition(lexer) {
  3452. var start = lexer.token;
  3453. expectKeyword(lexer, 'union');
  3454. var name = parseName(lexer);
  3455. var directives = parseDirectives(lexer);
  3456. expect(lexer, _lexer.TokenKind.EQUALS);
  3457. var types = parseUnionMembers(lexer);
  3458. return {
  3459. kind: _kinds.UNION_TYPE_DEFINITION,
  3460. name: name,
  3461. directives: directives,
  3462. types: types,
  3463. loc: loc(lexer, start)
  3464. };
  3465. }
  3466. /**
  3467. * UnionMembers :
  3468. * - NamedType
  3469. * - UnionMembers | NamedType
  3470. */
  3471. function parseUnionMembers(lexer) {
  3472. var members = [];
  3473. do {
  3474. members.push(parseNamedType(lexer));
  3475. } while (skip(lexer, _lexer.TokenKind.PIPE));
  3476. return members;
  3477. }
  3478. /**
  3479. * EnumTypeDefinition : enum Name Directives? { EnumValueDefinition+ }
  3480. */
  3481. function parseEnumTypeDefinition(lexer) {
  3482. var start = lexer.token;
  3483. expectKeyword(lexer, 'enum');
  3484. var name = parseName(lexer);
  3485. var directives = parseDirectives(lexer);
  3486. var values = many(lexer, _lexer.TokenKind.BRACE_L, parseEnumValueDefinition, _lexer.TokenKind.BRACE_R);
  3487. return {
  3488. kind: _kinds.ENUM_TYPE_DEFINITION,
  3489. name: name,
  3490. directives: directives,
  3491. values: values,
  3492. loc: loc(lexer, start)
  3493. };
  3494. }
  3495. /**
  3496. * EnumValueDefinition : EnumValue Directives?
  3497. *
  3498. * EnumValue : Name
  3499. */
  3500. function parseEnumValueDefinition(lexer) {
  3501. var start = lexer.token;
  3502. var name = parseName(lexer);
  3503. var directives = parseDirectives(lexer);
  3504. return {
  3505. kind: _kinds.ENUM_VALUE_DEFINITION,
  3506. name: name,
  3507. directives: directives,
  3508. loc: loc(lexer, start)
  3509. };
  3510. }
  3511. /**
  3512. * InputObjectTypeDefinition : input Name Directives? { InputValueDefinition+ }
  3513. */
  3514. function parseInputObjectTypeDefinition(lexer) {
  3515. var start = lexer.token;
  3516. expectKeyword(lexer, 'input');
  3517. var name = parseName(lexer);
  3518. var directives = parseDirectives(lexer);
  3519. var fields = any(lexer, _lexer.TokenKind.BRACE_L, parseInputValueDef, _lexer.TokenKind.BRACE_R);
  3520. return {
  3521. kind: _kinds.INPUT_OBJECT_TYPE_DEFINITION,
  3522. name: name,
  3523. directives: directives,
  3524. fields: fields,
  3525. loc: loc(lexer, start)
  3526. };
  3527. }
  3528. /**
  3529. * TypeExtensionDefinition : extend ObjectTypeDefinition
  3530. */
  3531. function parseTypeExtensionDefinition(lexer) {
  3532. var start = lexer.token;
  3533. expectKeyword(lexer, 'extend');
  3534. var definition = parseObjectTypeDefinition(lexer);
  3535. return {
  3536. kind: _kinds.TYPE_EXTENSION_DEFINITION,
  3537. definition: definition,
  3538. loc: loc(lexer, start)
  3539. };
  3540. }
  3541. /**
  3542. * DirectiveDefinition :
  3543. * - directive @ Name ArgumentsDefinition? on DirectiveLocations
  3544. */
  3545. function parseDirectiveDefinition(lexer) {
  3546. var start = lexer.token;
  3547. expectKeyword(lexer, 'directive');
  3548. expect(lexer, _lexer.TokenKind.AT);
  3549. var name = parseName(lexer);
  3550. var args = parseArgumentDefs(lexer);
  3551. expectKeyword(lexer, 'on');
  3552. var locations = parseDirectiveLocations(lexer);
  3553. return {
  3554. kind: _kinds.DIRECTIVE_DEFINITION,
  3555. name: name,
  3556. arguments: args,
  3557. locations: locations,
  3558. loc: loc(lexer, start)
  3559. };
  3560. }
  3561. /**
  3562. * DirectiveLocations :
  3563. * - Name
  3564. * - DirectiveLocations | Name
  3565. */
  3566. function parseDirectiveLocations(lexer) {
  3567. var locations = [];
  3568. do {
  3569. locations.push(parseName(lexer));
  3570. } while (skip(lexer, _lexer.TokenKind.PIPE));
  3571. return locations;
  3572. }
  3573. // Core parsing utility functions
  3574. /**
  3575. * Returns a location object, used to identify the place in
  3576. * the source that created a given parsed object.
  3577. */
  3578. function loc(lexer, startToken) {
  3579. if (!lexer.options.noLocation) {
  3580. return new Loc(startToken, lexer.lastToken, lexer.source);
  3581. }
  3582. }
  3583. function Loc(startToken, endToken, source) {
  3584. this.start = startToken.start;
  3585. this.end = endToken.end;
  3586. this.startToken = startToken;
  3587. this.endToken = endToken;
  3588. this.source = source;
  3589. }
  3590. // Print a simplified form when appearing in JSON/util.inspect.
  3591. Loc.prototype.toJSON = Loc.prototype.inspect = function toJSON() {
  3592. return { start: this.start, end: this.end };
  3593. };
  3594. /**
  3595. * Determines if the next token is of a given kind
  3596. */
  3597. function peek(lexer, kind) {
  3598. return lexer.token.kind === kind;
  3599. }
  3600. /**
  3601. * If the next token is of the given kind, return true after advancing
  3602. * the lexer. Otherwise, do not change the parser state and return false.
  3603. */
  3604. function skip(lexer, kind) {
  3605. var match = lexer.token.kind === kind;
  3606. if (match) {
  3607. lexer.advance();
  3608. }
  3609. return match;
  3610. }
  3611. /**
  3612. * If the next token is of the given kind, return that token after advancing
  3613. * the lexer. Otherwise, do not change the parser state and throw an error.
  3614. */
  3615. function expect(lexer, kind) {
  3616. var token = lexer.token;
  3617. if (token.kind === kind) {
  3618. lexer.advance();
  3619. return token;
  3620. }
  3621. throw (0, _error.syntaxError)(lexer.source, token.start, 'Expected ' + kind + ', found ' + (0, _lexer.getTokenDesc)(token));
  3622. }
  3623. /**
  3624. * If the next token is a keyword with the given value, return that token after
  3625. * advancing the lexer. Otherwise, do not change the parser state and return
  3626. * false.
  3627. */
  3628. function expectKeyword(lexer, value) {
  3629. var token = lexer.token;
  3630. if (token.kind === _lexer.TokenKind.NAME && token.value === value) {
  3631. lexer.advance();
  3632. return token;
  3633. }
  3634. throw (0, _error.syntaxError)(lexer.source, token.start, 'Expected "' + value + '", found ' + (0, _lexer.getTokenDesc)(token));
  3635. }
  3636. /**
  3637. * Helper function for creating an error when an unexpected lexed token
  3638. * is encountered.
  3639. */
  3640. function unexpected(lexer, atToken) {
  3641. var token = atToken || lexer.token;
  3642. return (0, _error.syntaxError)(lexer.source, token.start, 'Unexpected ' + (0, _lexer.getTokenDesc)(token));
  3643. }
  3644. /**
  3645. * Returns a possibly empty list of parse nodes, determined by
  3646. * the parseFn. This list begins with a lex token of openKind
  3647. * and ends with a lex token of closeKind. Advances the parser
  3648. * to the next lex token after the closing token.
  3649. */
  3650. function any(lexer, openKind, parseFn, closeKind) {
  3651. expect(lexer, openKind);
  3652. var nodes = [];
  3653. while (!skip(lexer, closeKind)) {
  3654. nodes.push(parseFn(lexer));
  3655. }
  3656. return nodes;
  3657. }
  3658. /**
  3659. * Returns a non-empty list of parse nodes, determined by
  3660. * the parseFn. This list begins with a lex token of openKind
  3661. * and ends with a lex token of closeKind. Advances the parser
  3662. * to the next lex token after the closing token.
  3663. */
  3664. function many(lexer, openKind, parseFn, closeKind) {
  3665. expect(lexer, openKind);
  3666. var nodes = [parseFn(lexer)];
  3667. while (!skip(lexer, closeKind)) {
  3668. nodes.push(parseFn(lexer));
  3669. }
  3670. return nodes;
  3671. }
  3672. /***/ }),
  3673. /* 18 */
  3674. /***/ (function(module, exports, __webpack_require__) {
  3675. "use strict";
  3676. Object.defineProperty(exports, "__esModule", {
  3677. value: true
  3678. });
  3679. exports.isValidLiteralValue = isValidLiteralValue;
  3680. var _printer = __webpack_require__(4);
  3681. var _kinds = __webpack_require__(2);
  3682. var _definition = __webpack_require__(1);
  3683. var _invariant = __webpack_require__(3);
  3684. var _invariant2 = _interopRequireDefault(_invariant);
  3685. var _keyMap = __webpack_require__(12);
  3686. var _keyMap2 = _interopRequireDefault(_keyMap);
  3687. var _isNullish = __webpack_require__(6);
  3688. var _isNullish2 = _interopRequireDefault(_isNullish);
  3689. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  3690. /**
  3691. * Utility for validators which determines if a value literal node is valid
  3692. * given an input type.
  3693. *
  3694. * Note that this only validates literal values, variables are assumed to
  3695. * provide values of the correct type.
  3696. */
  3697. /**
  3698. * Copyright (c) 2015, Facebook, Inc.
  3699. * All rights reserved.
  3700. *
  3701. * This source code is licensed under the BSD-style license found in the
  3702. * LICENSE file in the root directory of this source tree. An additional grant
  3703. * of patent rights can be found in the PATENTS file in the same directory.
  3704. */
  3705. function isValidLiteralValue(type, valueNode) {
  3706. // A value must be provided if the type is non-null.
  3707. if (type instanceof _definition.GraphQLNonNull) {
  3708. if (!valueNode || valueNode.kind === _kinds.NULL) {
  3709. return ['Expected "' + String(type) + '", found null.'];
  3710. }
  3711. return isValidLiteralValue(type.ofType, valueNode);
  3712. }
  3713. if (!valueNode || valueNode.kind === _kinds.NULL) {
  3714. return [];
  3715. }
  3716. // This function only tests literals, and assumes variables will provide
  3717. // values of the correct type.
  3718. if (valueNode.kind === _kinds.VARIABLE) {
  3719. return [];
  3720. }
  3721. // Lists accept a non-list value as a list of one.
  3722. if (type instanceof _definition.GraphQLList) {
  3723. var _ret = function () {
  3724. var itemType = type.ofType;
  3725. if (valueNode.kind === _kinds.LIST) {
  3726. return {
  3727. v: valueNode.values.reduce(function (acc, item, index) {
  3728. var errors = isValidLiteralValue(itemType, item);
  3729. return acc.concat(errors.map(function (error) {
  3730. return 'In element #' + index + ': ' + error;
  3731. }));
  3732. }, [])
  3733. };
  3734. }
  3735. return {
  3736. v: isValidLiteralValue(itemType, valueNode)
  3737. };
  3738. }();
  3739. if (typeof _ret === "object") return _ret.v;
  3740. }
  3741. // Input objects check each defined field and look for undefined fields.
  3742. if (type instanceof _definition.GraphQLInputObjectType) {
  3743. var _ret2 = function () {
  3744. if (valueNode.kind !== _kinds.OBJECT) {
  3745. return {
  3746. v: ['Expected "' + type.name + '", found not an object.']
  3747. };
  3748. }
  3749. var fields = type.getFields();
  3750. var errors = [];
  3751. // Ensure every provided field is defined.
  3752. var fieldNodes = valueNode.fields;
  3753. fieldNodes.forEach(function (providedFieldNode) {
  3754. if (!fields[providedFieldNode.name.value]) {
  3755. errors.push('In field "' + providedFieldNode.name.value + '": Unknown field.');
  3756. }
  3757. });
  3758. // Ensure every defined field is valid.
  3759. var fieldNodeMap = (0, _keyMap2.default)(fieldNodes, function (fieldNode) {
  3760. return fieldNode.name.value;
  3761. });
  3762. Object.keys(fields).forEach(function (fieldName) {
  3763. var result = isValidLiteralValue(fields[fieldName].type, fieldNodeMap[fieldName] && fieldNodeMap[fieldName].value);
  3764. errors.push.apply(errors, result.map(function (error) {
  3765. return 'In field "' + fieldName + '": ' + error;
  3766. }));
  3767. });
  3768. return {
  3769. v: errors
  3770. };
  3771. }();
  3772. if (typeof _ret2 === "object") return _ret2.v;
  3773. }
  3774. (0, _invariant2.default)(type instanceof _definition.GraphQLScalarType || type instanceof _definition.GraphQLEnumType, 'Must be input type');
  3775. // Scalar/Enum input checks to ensure the type can parse the value to
  3776. // a non-null value.
  3777. var parseResult = type.parseLiteral(valueNode);
  3778. if ((0, _isNullish2.default)(parseResult)) {
  3779. return ['Expected type "' + type.name + '", found ' + (0, _printer.print)(valueNode) + '.'];
  3780. }
  3781. return [];
  3782. }
  3783. /***/ }),
  3784. /* 19 */
  3785. /***/ (function(module, exports, __webpack_require__) {
  3786. "use strict";
  3787. Object.defineProperty(exports, "__esModule", {
  3788. value: true
  3789. });
  3790. exports.isEqualType = isEqualType;
  3791. exports.isTypeSubTypeOf = isTypeSubTypeOf;
  3792. exports.doTypesOverlap = doTypesOverlap;
  3793. var _definition = __webpack_require__(1);
  3794. /**
  3795. * Provided two types, return true if the types are equal (invariant).
  3796. */
  3797. function isEqualType(typeA, typeB) {
  3798. // Equivalent types are equal.
  3799. if (typeA === typeB) {
  3800. return true;
  3801. }
  3802. // If either type is non-null, the other must also be non-null.
  3803. if (typeA instanceof _definition.GraphQLNonNull && typeB instanceof _definition.GraphQLNonNull) {
  3804. return isEqualType(typeA.ofType, typeB.ofType);
  3805. }
  3806. // If either type is a list, the other must also be a list.
  3807. if (typeA instanceof _definition.GraphQLList && typeB instanceof _definition.GraphQLList) {
  3808. return isEqualType(typeA.ofType, typeB.ofType);
  3809. }
  3810. // Otherwise the types are not equal.
  3811. return false;
  3812. }
  3813. /**
  3814. * Provided a type and a super type, return true if the first type is either
  3815. * equal or a subset of the second super type (covariant).
  3816. */
  3817. /**
  3818. * Copyright (c) 2015, Facebook, Inc.
  3819. * All rights reserved.
  3820. *
  3821. * This source code is licensed under the BSD-style license found in the
  3822. * LICENSE file in the root directory of this source tree. An additional grant
  3823. * of patent rights can be found in the PATENTS file in the same directory.
  3824. */
  3825. function isTypeSubTypeOf(schema, maybeSubType, superType) {
  3826. // Equivalent type is a valid subtype
  3827. if (maybeSubType === superType) {
  3828. return true;
  3829. }
  3830. // If superType is non-null, maybeSubType must also be non-null.
  3831. if (superType instanceof _definition.GraphQLNonNull) {
  3832. if (maybeSubType instanceof _definition.GraphQLNonNull) {
  3833. return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType);
  3834. }
  3835. return false;
  3836. } else if (maybeSubType instanceof _definition.GraphQLNonNull) {
  3837. // If superType is nullable, maybeSubType may be non-null or nullable.
  3838. return isTypeSubTypeOf(schema, maybeSubType.ofType, superType);
  3839. }
  3840. // If superType type is a list, maybeSubType type must also be a list.
  3841. if (superType instanceof _definition.GraphQLList) {
  3842. if (maybeSubType instanceof _definition.GraphQLList) {
  3843. return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType);
  3844. }
  3845. return false;
  3846. } else if (maybeSubType instanceof _definition.GraphQLList) {
  3847. // If superType is not a list, maybeSubType must also be not a list.
  3848. return false;
  3849. }
  3850. // If superType type is an abstract type, maybeSubType type may be a currently
  3851. // possible object type.
  3852. if ((0, _definition.isAbstractType)(superType) && maybeSubType instanceof _definition.GraphQLObjectType && schema.isPossibleType(superType, maybeSubType)) {
  3853. return true;
  3854. }
  3855. // Otherwise, the child type is not a valid subtype of the parent type.
  3856. return false;
  3857. }
  3858. /**
  3859. * Provided two composite types, determine if they "overlap". Two composite
  3860. * types overlap when the Sets of possible concrete types for each intersect.
  3861. *
  3862. * This is often used to determine if a fragment of a given type could possibly
  3863. * be visited in a context of another type.
  3864. *
  3865. * This function is commutative.
  3866. */
  3867. function doTypesOverlap(schema, typeA, typeB) {
  3868. // So flow is aware this is constant
  3869. var _typeB = typeB;
  3870. // Equivalent types overlap
  3871. if (typeA === _typeB) {
  3872. return true;
  3873. }
  3874. if (typeA instanceof _definition.GraphQLInterfaceType || typeA instanceof _definition.GraphQLUnionType) {
  3875. if (_typeB instanceof _definition.GraphQLInterfaceType || _typeB instanceof _definition.GraphQLUnionType) {
  3876. // If both types are abstract, then determine if there is any intersection
  3877. // between possible concrete types of each.
  3878. return schema.getPossibleTypes(typeA).some(function (type) {
  3879. return schema.isPossibleType(_typeB, type);
  3880. });
  3881. }
  3882. // Determine if the latter type is a possible concrete type of the former.
  3883. return schema.isPossibleType(typeA, _typeB);
  3884. }
  3885. if (_typeB instanceof _definition.GraphQLInterfaceType || _typeB instanceof _definition.GraphQLUnionType) {
  3886. // Determine if the former type is a possible concrete type of the latter.
  3887. return schema.isPossibleType(_typeB, typeA);
  3888. }
  3889. // Otherwise the types do not overlap.
  3890. return false;
  3891. }
  3892. /***/ }),
  3893. /* 20 */
  3894. /***/ (function(module, exports) {
  3895. /**
  3896. * Copyright (c) 2016, Lee Byron
  3897. * All rights reserved.
  3898. *
  3899. * This source code is licensed under the MIT license found in the
  3900. * LICENSE file in the root directory of this source tree.
  3901. *
  3902. * @ignore
  3903. */
  3904. /**
  3905. * [Iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#iterator)
  3906. * is a *protocol* which describes a standard way to produce a sequence of
  3907. * values, typically the values of the Iterable represented by this Iterator.
  3908. *
  3909. * While described by the [ES2015 version of JavaScript](http://www.ecma-international.org/ecma-262/6.0/#sec-iterator-interface)
  3910. * it can be utilized by any version of JavaScript.
  3911. *
  3912. * @typedef {Object} Iterator
  3913. * @template T The type of each iterated value
  3914. * @property {function (): { value: T, done: boolean }} next
  3915. * A method which produces either the next value in a sequence or a result
  3916. * where the `done` property is `true` indicating the end of the Iterator.
  3917. */
  3918. /**
  3919. * [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#iterable)
  3920. * is a *protocol* which when implemented allows a JavaScript object to define
  3921. * their iteration behavior, such as what values are looped over in a `for..of`
  3922. * loop or `iterall`'s `forEach` function. Many [built-in types](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#Builtin_iterables)
  3923. * implement the Iterable protocol, including `Array` and `Map`.
  3924. *
  3925. * While described by the [ES2015 version of JavaScript](http://www.ecma-international.org/ecma-262/6.0/#sec-iterable-interface)
  3926. * it can be utilized by any version of JavaScript.
  3927. *
  3928. * @typedef {Object} Iterable
  3929. * @template T The type of each iterated value
  3930. * @property {function (): Iterator<T>} Symbol.iterator
  3931. * A method which produces an Iterator for this Iterable.
  3932. */
  3933. // In ES2015 (or a polyfilled) environment, this will be Symbol.iterator
  3934. var SYMBOL_ITERATOR = typeof Symbol === 'function' && Symbol.iterator
  3935. /**
  3936. * A property name to be used as the name of an Iterable's method responsible
  3937. * for producing an Iterator, referred to as `@@iterator`. Typically represents
  3938. * the value `Symbol.iterator` but falls back to the string `"@@iterator"` when
  3939. * `Symbol.iterator` is not defined.
  3940. *
  3941. * Use `$$iterator` for defining new Iterables instead of `Symbol.iterator`,
  3942. * but do not use it for accessing existing Iterables, instead use
  3943. * `getIterator()` or `isIterable()`.
  3944. *
  3945. * @example
  3946. *
  3947. * var $$iterator = require('iterall').$$iterator
  3948. *
  3949. * function Counter (to) {
  3950. * this.to = to
  3951. * }
  3952. *
  3953. * Counter.prototype[$$iterator] = function () {
  3954. * return {
  3955. * to: this.to,
  3956. * num: 0,
  3957. * next () {
  3958. * if (this.num >= this.to) {
  3959. * return { value: undefined, done: true }
  3960. * }
  3961. * return { value: this.num++, done: false }
  3962. * }
  3963. * }
  3964. * }
  3965. *
  3966. * var counter = new Counter(3)
  3967. * for (var number of counter) {
  3968. * console.log(number) // 0 ... 1 ... 2
  3969. * }
  3970. *
  3971. * @type {Symbol|string}
  3972. */
  3973. var $$iterator = SYMBOL_ITERATOR || '@@iterator'
  3974. exports.$$iterator = $$iterator
  3975. /**
  3976. * Returns true if the provided object implements the Iterator protocol via
  3977. * either implementing a `Symbol.iterator` or `"@@iterator"` method.
  3978. *
  3979. * @example
  3980. *
  3981. * var isIterable = require('iterall').isIterable
  3982. * isIterable([ 1, 2, 3 ]) // true
  3983. * isIterable('ABC') // true
  3984. * isIterable({ length: 1, 0: 'Alpha' }) // false
  3985. * isIterable({ key: 'value' }) // false
  3986. * isIterable(new Map()) // true
  3987. *
  3988. * @param obj
  3989. * A value which might implement the Iterable protocol.
  3990. * @return {boolean} true if Iterable.
  3991. */
  3992. function isIterable (obj) {
  3993. return !!getIteratorMethod(obj)
  3994. }
  3995. exports.isIterable = isIterable
  3996. /**
  3997. * Returns true if the provided object implements the Array-like protocol via
  3998. * defining a positive-integer `length` property.
  3999. *
  4000. * @example
  4001. *
  4002. * var isArrayLike = require('iterall').isArrayLike
  4003. * isArrayLike([ 1, 2, 3 ]) // true
  4004. * isArrayLike('ABC') // true
  4005. * isArrayLike({ length: 1, 0: 'Alpha' }) // true
  4006. * isArrayLike({ key: 'value' }) // false
  4007. * isArrayLike(new Map()) // false
  4008. *
  4009. * @param obj
  4010. * A value which might implement the Array-like protocol.
  4011. * @return {boolean} true if Array-like.
  4012. */
  4013. function isArrayLike (obj) {
  4014. var length = obj != null && obj.length
  4015. return typeof length === 'number' && length >= 0 && length % 1 === 0
  4016. }
  4017. exports.isArrayLike = isArrayLike
  4018. /**
  4019. * Returns true if the provided object is an Object (i.e. not a string literal)
  4020. * and is either Iterable or Array-like.
  4021. *
  4022. * This may be used in place of [Array.isArray()][isArray] to determine if an
  4023. * object should be iterated-over. It always excludes string literals and
  4024. * includes Arrays (regardless of if it is Iterable). It also includes other
  4025. * Array-like objects such as NodeList, TypedArray, and Buffer.
  4026. *
  4027. * @example
  4028. *
  4029. * var isCollection = require('iterall').isCollection
  4030. * isCollection([ 1, 2, 3 ]) // true
  4031. * isCollection('ABC') // false
  4032. * isCollection({ length: 1, 0: 'Alpha' }) // true
  4033. * isCollection({ key: 'value' }) // false
  4034. * isCollection(new Map()) // true
  4035. *
  4036. * @example
  4037. *
  4038. * var forEach = require('iterall').forEach
  4039. * if (isCollection(obj)) {
  4040. * forEach(obj, function (value) {
  4041. * console.log(value)
  4042. * })
  4043. * }
  4044. *
  4045. * @param obj
  4046. * An Object value which might implement the Iterable or Array-like protocols.
  4047. * @return {boolean} true if Iterable or Array-like Object.
  4048. */
  4049. function isCollection (obj) {
  4050. return Object(obj) === obj && (isArrayLike(obj) || isIterable(obj))
  4051. }
  4052. exports.isCollection = isCollection
  4053. /**
  4054. * If the provided object implements the Iterator protocol, its Iterator object
  4055. * is returned. Otherwise returns undefined.
  4056. *
  4057. * @example
  4058. *
  4059. * var getIterator = require('iterall').getIterator
  4060. * var iterator = getIterator([ 1, 2, 3 ])
  4061. * iterator.next() // { value: 1, done: false }
  4062. * iterator.next() // { value: 2, done: false }
  4063. * iterator.next() // { value: 3, done: false }
  4064. * iterator.next() // { value: undefined, done: true }
  4065. *
  4066. * @template T the type of each iterated value
  4067. * @param {Iterable<T>} iterable
  4068. * An Iterable object which is the source of an Iterator.
  4069. * @return {Iterator<T>} new Iterator instance.
  4070. */
  4071. function getIterator (iterable) {
  4072. var method = getIteratorMethod(iterable)
  4073. if (method) {
  4074. return method.call(iterable)
  4075. }
  4076. }
  4077. exports.getIterator = getIterator
  4078. /**
  4079. * If the provided object implements the Iterator protocol, the method
  4080. * responsible for producing its Iterator object is returned.
  4081. *
  4082. * This is used in rare cases for performance tuning. This method must be called
  4083. * with obj as the contextual this-argument.
  4084. *
  4085. * @example
  4086. *
  4087. * var getIteratorMethod = require('iterall').getIteratorMethod
  4088. * var myArray = [ 1, 2, 3 ]
  4089. * var method = getIteratorMethod(myArray)
  4090. * if (method) {
  4091. * var iterator = method.call(myArray)
  4092. * }
  4093. *
  4094. * @template T the type of each iterated value
  4095. * @param {Iterable<T>} iterable
  4096. * An Iterable object which defines an `@@iterator` method.
  4097. * @return {function(): Iterator<T>} `@@iterator` method.
  4098. */
  4099. function getIteratorMethod (iterable) {
  4100. if (iterable != null) {
  4101. var method = SYMBOL_ITERATOR && iterable[SYMBOL_ITERATOR] || iterable['@@iterator']
  4102. if (typeof method === 'function') {
  4103. return method
  4104. }
  4105. }
  4106. }
  4107. exports.getIteratorMethod = getIteratorMethod
  4108. /**
  4109. * Given an object which either implements the Iterable protocol or is
  4110. * Array-like, iterate over it, calling the `callback` at each iteration.
  4111. *
  4112. * Use `forEach` where you would expect to use a `for ... of` loop in ES6.
  4113. * However `forEach` adheres to the behavior of [Array#forEach][] described in
  4114. * the ECMAScript specification, skipping over "holes" in Array-likes. It will
  4115. * also delegate to a `forEach` method on `collection` if one is defined,
  4116. * ensuring native performance for `Arrays`.
  4117. *
  4118. * Similar to [Array#forEach][], the `callback` function accepts three
  4119. * arguments, and is provided with `thisArg` as the calling context.
  4120. *
  4121. * Note: providing an infinite Iterator to forEach will produce an error.
  4122. *
  4123. * [Array#forEach]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
  4124. *
  4125. * @example
  4126. *
  4127. * var forEach = require('iterall').forEach
  4128. *
  4129. * forEach(myIterable, function (value, index, iterable) {
  4130. * console.log(value, index, iterable === myIterable)
  4131. * })
  4132. *
  4133. * @example
  4134. *
  4135. * // ES6:
  4136. * for (let value of myIterable) {
  4137. * console.log(value)
  4138. * }
  4139. *
  4140. * // Any JavaScript environment:
  4141. * forEach(myIterable, function (value) {
  4142. * console.log(value)
  4143. * })
  4144. *
  4145. * @template T the type of each iterated value
  4146. * @param {Iterable<T>|{ length: number }} collection
  4147. * The Iterable or array to iterate over.
  4148. * @param {function(T, number, object)} callback
  4149. * Function to execute for each iteration, taking up to three arguments
  4150. * @param [thisArg]
  4151. * Optional. Value to use as `this` when executing `callback`.
  4152. */
  4153. function forEach (collection, callback, thisArg) {
  4154. if (collection != null) {
  4155. if (typeof collection.forEach === 'function') {
  4156. return collection.forEach(callback, thisArg)
  4157. }
  4158. var i = 0
  4159. var iterator = getIterator(collection)
  4160. if (iterator) {
  4161. var step
  4162. while (!(step = iterator.next()).done) {
  4163. callback.call(thisArg, step.value, i++, collection)
  4164. // Infinite Iterators could cause forEach to run forever.
  4165. // After a very large number of iterations, produce an error.
  4166. /* istanbul ignore if */
  4167. if (i > 9999999) {
  4168. throw new TypeError('Near-infinite iteration.')
  4169. }
  4170. }
  4171. } else if (isArrayLike(collection)) {
  4172. for (; i < collection.length; i++) {
  4173. if (collection.hasOwnProperty(i)) {
  4174. callback.call(thisArg, collection[i], i, collection)
  4175. }
  4176. }
  4177. }
  4178. }
  4179. }
  4180. exports.forEach = forEach
  4181. /**
  4182. * Similar to `getIterator()`, this method returns a new Iterator given an
  4183. * Iterable. However it will also create an Iterator for a non-Iterable
  4184. * Array-like collection, such as Array in a non-ES2015 environment.
  4185. *
  4186. * `createIterator` is complimentary to `forEach`, but allows a "pull"-based
  4187. * iteration as opposed to `forEach`'s "push"-based iteration.
  4188. *
  4189. * `createIterator` produces an Iterator for Array-likes with the same behavior
  4190. * as ArrayIteratorPrototype described in the ECMAScript specification, and
  4191. * does *not* skip over "holes".
  4192. *
  4193. * @example
  4194. *
  4195. * var createIterator = require('iterall').createIterator
  4196. *
  4197. * var myArraylike = { length: 3, 0: 'Alpha', 1: 'Bravo', 2: 'Charlie' }
  4198. * var iterator = createIterator(myArraylike)
  4199. * iterator.next() // { value: 'Alpha', done: false }
  4200. * iterator.next() // { value: 'Bravo', done: false }
  4201. * iterator.next() // { value: 'Charlie', done: false }
  4202. * iterator.next() // { value: undefined, done: true }
  4203. *
  4204. * @template T the type of each iterated value
  4205. * @param {Iterable<T>|{ length: number }} collection
  4206. * An Iterable or Array-like object to produce an Iterator.
  4207. * @return {Iterator<T>} new Iterator instance.
  4208. */
  4209. function createIterator (collection) {
  4210. if (collection != null) {
  4211. var iterator = getIterator(collection)
  4212. if (iterator) {
  4213. return iterator
  4214. }
  4215. if (isArrayLike(collection)) {
  4216. return new ArrayLikeIterator(collection)
  4217. }
  4218. }
  4219. }
  4220. exports.createIterator = createIterator
  4221. // When the object provided to `createIterator` is not Iterable but is
  4222. // Array-like, this simple Iterator is created.
  4223. function ArrayLikeIterator (obj) {
  4224. this._o = obj
  4225. this._i = 0
  4226. }
  4227. // Note: all Iterators are themselves Iterable.
  4228. ArrayLikeIterator.prototype[$$iterator] = function () {
  4229. return this
  4230. }
  4231. // A simple state-machine determines the IteratorResult returned, yielding
  4232. // each value in the Array-like object in order of their indicies.
  4233. ArrayLikeIterator.prototype.next = function () {
  4234. if (this._o === void 0 || this._i >= this._o.length) {
  4235. this._o = void 0
  4236. return { value: void 0, done: true }
  4237. }
  4238. return { value: this._o[this._i++], done: false }
  4239. }
  4240. /***/ }),
  4241. /* 21 */
  4242. /***/ (function(module, exports, __webpack_require__) {
  4243. "use strict";
  4244. Object.defineProperty(exports, "__esModule", {
  4245. value: true
  4246. });
  4247. exports.default = keyValMap;
  4248. /**
  4249. * Copyright (c) 2015, Facebook, Inc.
  4250. * All rights reserved.
  4251. *
  4252. * This source code is licensed under the BSD-style license found in the
  4253. * LICENSE file in the root directory of this source tree. An additional grant
  4254. * of patent rights can be found in the PATENTS file in the same directory.
  4255. */
  4256. /**
  4257. * Creates a keyed JS object from an array, given a function to produce the keys
  4258. * and a function to produce the values from each item in the array.
  4259. *
  4260. * const phoneBook = [
  4261. * { name: 'Jon', num: '555-1234' },
  4262. * { name: 'Jenny', num: '867-5309' }
  4263. * ]
  4264. *
  4265. * // { Jon: '555-1234', Jenny: '867-5309' }
  4266. * const phonesByName = keyValMap(
  4267. * phoneBook,
  4268. * entry => entry.name,
  4269. * entry => entry.num
  4270. * )
  4271. *
  4272. */
  4273. function keyValMap(list, keyFn, valFn) {
  4274. return list.reduce(function (map, item) {
  4275. return map[keyFn(item)] = valFn(item), map;
  4276. }, {});
  4277. }
  4278. /***/ }),
  4279. /* 22 */
  4280. /***/ (function(module, exports, __webpack_require__) {
  4281. "use strict";
  4282. Object.defineProperty(exports, "__esModule", {
  4283. value: true
  4284. });
  4285. exports.default = quotedOrList;
  4286. /**
  4287. * Copyright (c) 2015, Facebook, Inc.
  4288. * All rights reserved.
  4289. *
  4290. * This source code is licensed under the BSD-style license found in the
  4291. * LICENSE file in the root directory of this source tree. An additional grant
  4292. * of patent rights can be found in the PATENTS file in the same directory.
  4293. */
  4294. var MAX_LENGTH = 5;
  4295. /**
  4296. * Given [ A, B, C ] return '"A", "B", or "C"'.
  4297. */
  4298. function quotedOrList(items) {
  4299. var selected = items.slice(0, MAX_LENGTH);
  4300. return selected.map(function (item) {
  4301. return '"' + item + '"';
  4302. }).reduce(function (list, quoted, index) {
  4303. return list + (selected.length > 2 ? ', ' : ' ') + (index === selected.length - 1 ? 'or ' : '') + quoted;
  4304. });
  4305. }
  4306. /***/ }),
  4307. /* 23 */
  4308. /***/ (function(module, exports, __webpack_require__) {
  4309. "use strict";
  4310. Object.defineProperty(exports, "__esModule", {
  4311. value: true
  4312. });
  4313. exports.default = suggestionList;
  4314. /**
  4315. * Copyright (c) 2015, Facebook, Inc.
  4316. * All rights reserved.
  4317. *
  4318. * This source code is licensed under the BSD-style license found in the
  4319. * LICENSE file in the root directory of this source tree. An additional grant
  4320. * of patent rights can be found in the PATENTS file in the same directory.
  4321. */
  4322. /**
  4323. * Given an invalid input string and a list of valid options, returns a filtered
  4324. * list of valid options sorted based on their similarity with the input.
  4325. */
  4326. function suggestionList(input, options) {
  4327. var optionsByDistance = Object.create(null);
  4328. var oLength = options.length;
  4329. var inputThreshold = input.length / 2;
  4330. for (var i = 0; i < oLength; i++) {
  4331. var distance = lexicalDistance(input, options[i]);
  4332. var threshold = Math.max(inputThreshold, options[i].length / 2, 1);
  4333. if (distance <= threshold) {
  4334. optionsByDistance[options[i]] = distance;
  4335. }
  4336. }
  4337. return Object.keys(optionsByDistance).sort(function (a, b) {
  4338. return optionsByDistance[a] - optionsByDistance[b];
  4339. });
  4340. }
  4341. /**
  4342. * Computes the lexical distance between strings A and B.
  4343. *
  4344. * The "distance" between two strings is given by counting the minimum number
  4345. * of edits needed to transform string A into string B. An edit can be an
  4346. * insertion, deletion, or substitution of a single character, or a swap of two
  4347. * adjacent characters.
  4348. *
  4349. * This distance can be useful for detecting typos in input or sorting
  4350. *
  4351. * @param {string} a
  4352. * @param {string} b
  4353. * @return {int} distance in number of edits
  4354. */
  4355. function lexicalDistance(a, b) {
  4356. var i = void 0;
  4357. var j = void 0;
  4358. var d = [];
  4359. var aLength = a.length;
  4360. var bLength = b.length;
  4361. for (i = 0; i <= aLength; i++) {
  4362. d[i] = [i];
  4363. }
  4364. for (j = 1; j <= bLength; j++) {
  4365. d[0][j] = j;
  4366. }
  4367. for (i = 1; i <= aLength; i++) {
  4368. for (j = 1; j <= bLength; j++) {
  4369. var cost = a[i - 1] === b[j - 1] ? 0 : 1;
  4370. d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
  4371. if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
  4372. d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + cost);
  4373. }
  4374. }
  4375. }
  4376. return d[aLength][bLength];
  4377. }
  4378. /***/ }),
  4379. /* 24 */
  4380. /***/ (function(module, exports, __webpack_require__) {
  4381. "use strict";
  4382. Object.defineProperty(exports, "__esModule", {
  4383. value: true
  4384. });
  4385. exports.TokenKind = undefined;
  4386. exports.createLexer = createLexer;
  4387. exports.getTokenDesc = getTokenDesc;
  4388. var _error = __webpack_require__(0);
  4389. /**
  4390. * Given a Source object, this returns a Lexer for that source.
  4391. * A Lexer is a stateful stream generator in that every time
  4392. * it is advanced, it returns the next token in the Source. Assuming the
  4393. * source lexes, the final Token emitted by the lexer will be of kind
  4394. * EOF, after which the lexer will repeatedly return the same EOF token
  4395. * whenever called.
  4396. */
  4397. function createLexer(source, options) {
  4398. var startOfFileToken = new Tok(SOF, 0, 0, 0, 0, null);
  4399. var lexer = {
  4400. source: source,
  4401. options: options,
  4402. lastToken: startOfFileToken,
  4403. token: startOfFileToken,
  4404. line: 1,
  4405. lineStart: 0,
  4406. advance: advanceLexer
  4407. };
  4408. return lexer;
  4409. } /* /
  4410. /**
  4411. * Copyright (c) 2015, Facebook, Inc.
  4412. * All rights reserved.
  4413. *
  4414. * This source code is licensed under the BSD-style license found in the
  4415. * LICENSE file in the root directory of this source tree. An additional grant
  4416. * of patent rights can be found in the PATENTS file in the same directory.
  4417. */
  4418. function advanceLexer() {
  4419. var token = this.lastToken = this.token;
  4420. if (token.kind !== EOF) {
  4421. do {
  4422. token = token.next = readToken(this, token);
  4423. } while (token.kind === COMMENT);
  4424. this.token = token;
  4425. }
  4426. return token;
  4427. }
  4428. /**
  4429. * The return type of createLexer.
  4430. */
  4431. // Each kind of token.
  4432. var SOF = '<SOF>';
  4433. var EOF = '<EOF>';
  4434. var BANG = '!';
  4435. var DOLLAR = '$';
  4436. var PAREN_L = '(';
  4437. var PAREN_R = ')';
  4438. var SPREAD = '...';
  4439. var COLON = ':';
  4440. var EQUALS = '=';
  4441. var AT = '@';
  4442. var BRACKET_L = '[';
  4443. var BRACKET_R = ']';
  4444. var BRACE_L = '{';
  4445. var PIPE = '|';
  4446. var BRACE_R = '}';
  4447. var NAME = 'Name';
  4448. var INT = 'Int';
  4449. var FLOAT = 'Float';
  4450. var STRING = 'String';
  4451. var COMMENT = 'Comment';
  4452. /**
  4453. * An exported enum describing the different kinds of tokens that the
  4454. * lexer emits.
  4455. */
  4456. var TokenKind = exports.TokenKind = {
  4457. SOF: SOF,
  4458. EOF: EOF,
  4459. BANG: BANG,
  4460. DOLLAR: DOLLAR,
  4461. PAREN_L: PAREN_L,
  4462. PAREN_R: PAREN_R,
  4463. SPREAD: SPREAD,
  4464. COLON: COLON,
  4465. EQUALS: EQUALS,
  4466. AT: AT,
  4467. BRACKET_L: BRACKET_L,
  4468. BRACKET_R: BRACKET_R,
  4469. BRACE_L: BRACE_L,
  4470. PIPE: PIPE,
  4471. BRACE_R: BRACE_R,
  4472. NAME: NAME,
  4473. INT: INT,
  4474. FLOAT: FLOAT,
  4475. STRING: STRING,
  4476. COMMENT: COMMENT
  4477. };
  4478. /**
  4479. * A helper function to describe a token as a string for debugging
  4480. */
  4481. function getTokenDesc(token) {
  4482. var value = token.value;
  4483. return value ? token.kind + ' "' + value + '"' : token.kind;
  4484. }
  4485. var charCodeAt = String.prototype.charCodeAt;
  4486. var slice = String.prototype.slice;
  4487. /**
  4488. * Helper function for constructing the Token object.
  4489. */
  4490. function Tok(kind, start, end, line, column, prev, value) {
  4491. this.kind = kind;
  4492. this.start = start;
  4493. this.end = end;
  4494. this.line = line;
  4495. this.column = column;
  4496. this.value = value;
  4497. this.prev = prev;
  4498. this.next = null;
  4499. }
  4500. // Print a simplified form when appearing in JSON/util.inspect.
  4501. Tok.prototype.toJSON = Tok.prototype.inspect = function toJSON() {
  4502. return {
  4503. kind: this.kind,
  4504. value: this.value,
  4505. line: this.line,
  4506. column: this.column
  4507. };
  4508. };
  4509. function printCharCode(code) {
  4510. return (
  4511. // NaN/undefined represents access beyond the end of the file.
  4512. isNaN(code) ? EOF :
  4513. // Trust JSON for ASCII.
  4514. code < 0x007F ? JSON.stringify(String.fromCharCode(code)) :
  4515. // Otherwise print the escaped form.
  4516. '"\\u' + ('00' + code.toString(16).toUpperCase()).slice(-4) + '"'
  4517. );
  4518. }
  4519. /**
  4520. * Gets the next token from the source starting at the given position.
  4521. *
  4522. * This skips over whitespace and comments until it finds the next lexable
  4523. * token, then lexes punctuators immediately or calls the appropriate helper
  4524. * function for more complicated tokens.
  4525. */
  4526. function readToken(lexer, prev) {
  4527. var source = lexer.source;
  4528. var body = source.body;
  4529. var bodyLength = body.length;
  4530. var position = positionAfterWhitespace(body, prev.end, lexer);
  4531. var line = lexer.line;
  4532. var col = 1 + position - lexer.lineStart;
  4533. if (position >= bodyLength) {
  4534. return new Tok(EOF, bodyLength, bodyLength, line, col, prev);
  4535. }
  4536. var code = charCodeAt.call(body, position);
  4537. // SourceCharacter
  4538. if (code < 0x0020 && code !== 0x0009 && code !== 0x000A && code !== 0x000D) {
  4539. throw (0, _error.syntaxError)(source, position, 'Cannot contain the invalid character ' + printCharCode(code) + '.');
  4540. }
  4541. switch (code) {
  4542. // !
  4543. case 33:
  4544. return new Tok(BANG, position, position + 1, line, col, prev);
  4545. // #
  4546. case 35:
  4547. return readComment(source, position, line, col, prev);
  4548. // $
  4549. case 36:
  4550. return new Tok(DOLLAR, position, position + 1, line, col, prev);
  4551. // (
  4552. case 40:
  4553. return new Tok(PAREN_L, position, position + 1, line, col, prev);
  4554. // )
  4555. case 41:
  4556. return new Tok(PAREN_R, position, position + 1, line, col, prev);
  4557. // .
  4558. case 46:
  4559. if (charCodeAt.call(body, position + 1) === 46 && charCodeAt.call(body, position + 2) === 46) {
  4560. return new Tok(SPREAD, position, position + 3, line, col, prev);
  4561. }
  4562. break;
  4563. // :
  4564. case 58:
  4565. return new Tok(COLON, position, position + 1, line, col, prev);
  4566. // =
  4567. case 61:
  4568. return new Tok(EQUALS, position, position + 1, line, col, prev);
  4569. // @
  4570. case 64:
  4571. return new Tok(AT, position, position + 1, line, col, prev);
  4572. // [
  4573. case 91:
  4574. return new Tok(BRACKET_L, position, position + 1, line, col, prev);
  4575. // ]
  4576. case 93:
  4577. return new Tok(BRACKET_R, position, position + 1, line, col, prev);
  4578. // {
  4579. case 123:
  4580. return new Tok(BRACE_L, position, position + 1, line, col, prev);
  4581. // |
  4582. case 124:
  4583. return new Tok(PIPE, position, position + 1, line, col, prev);
  4584. // }
  4585. case 125:
  4586. return new Tok(BRACE_R, position, position + 1, line, col, prev);
  4587. // A-Z _ a-z
  4588. case 65:case 66:case 67:case 68:case 69:case 70:case 71:case 72:
  4589. case 73:case 74:case 75:case 76:case 77:case 78:case 79:case 80:
  4590. case 81:case 82:case 83:case 84:case 85:case 86:case 87:case 88:
  4591. case 89:case 90:
  4592. case 95:
  4593. case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104:
  4594. case 105:case 106:case 107:case 108:case 109:case 110:case 111:
  4595. case 112:case 113:case 114:case 115:case 116:case 117:case 118:
  4596. case 119:case 120:case 121:case 122:
  4597. return readName(source, position, line, col, prev);
  4598. // - 0-9
  4599. case 45:
  4600. case 48:case 49:case 50:case 51:case 52:
  4601. case 53:case 54:case 55:case 56:case 57:
  4602. return readNumber(source, position, code, line, col, prev);
  4603. // "
  4604. case 34:
  4605. return readString(source, position, line, col, prev);
  4606. }
  4607. throw (0, _error.syntaxError)(source, position, unexpectedCharacterMessage(code));
  4608. }
  4609. /**
  4610. * Report a message that an unexpected character was encountered.
  4611. */
  4612. function unexpectedCharacterMessage(code) {
  4613. if (code === 39) {
  4614. // '
  4615. return 'Unexpected single quote character (\'), did you mean to use ' + 'a double quote (")?';
  4616. }
  4617. return 'Cannot parse the unexpected character ' + printCharCode(code) + '.';
  4618. }
  4619. /**
  4620. * Reads from body starting at startPosition until it finds a non-whitespace
  4621. * or commented character, then returns the position of that character for
  4622. * lexing.
  4623. */
  4624. function positionAfterWhitespace(body, startPosition, lexer) {
  4625. var bodyLength = body.length;
  4626. var position = startPosition;
  4627. while (position < bodyLength) {
  4628. var code = charCodeAt.call(body, position);
  4629. // tab | space | comma | BOM
  4630. if (code === 9 || code === 32 || code === 44 || code === 0xFEFF) {
  4631. ++position;
  4632. } else if (code === 10) {
  4633. // new line
  4634. ++position;
  4635. ++lexer.line;
  4636. lexer.lineStart = position;
  4637. } else if (code === 13) {
  4638. // carriage return
  4639. if (charCodeAt.call(body, position + 1) === 10) {
  4640. position += 2;
  4641. } else {
  4642. ++position;
  4643. }
  4644. ++lexer.line;
  4645. lexer.lineStart = position;
  4646. } else {
  4647. break;
  4648. }
  4649. }
  4650. return position;
  4651. }
  4652. /**
  4653. * Reads a comment token from the source file.
  4654. *
  4655. * #[\u0009\u0020-\uFFFF]*
  4656. */
  4657. function readComment(source, start, line, col, prev) {
  4658. var body = source.body;
  4659. var code = void 0;
  4660. var position = start;
  4661. do {
  4662. code = charCodeAt.call(body, ++position);
  4663. } while (code !== null && (
  4664. // SourceCharacter but not LineTerminator
  4665. code > 0x001F || code === 0x0009));
  4666. return new Tok(COMMENT, start, position, line, col, prev, slice.call(body, start + 1, position));
  4667. }
  4668. /**
  4669. * Reads a number token from the source file, either a float
  4670. * or an int depending on whether a decimal point appears.
  4671. *
  4672. * Int: -?(0|[1-9][0-9]*)
  4673. * Float: -?(0|[1-9][0-9]*)(\.[0-9]+)?((E|e)(+|-)?[0-9]+)?
  4674. */
  4675. function readNumber(source, start, firstCode, line, col, prev) {
  4676. var body = source.body;
  4677. var code = firstCode;
  4678. var position = start;
  4679. var isFloat = false;
  4680. if (code === 45) {
  4681. // -
  4682. code = charCodeAt.call(body, ++position);
  4683. }
  4684. if (code === 48) {
  4685. // 0
  4686. code = charCodeAt.call(body, ++position);
  4687. if (code >= 48 && code <= 57) {
  4688. throw (0, _error.syntaxError)(source, position, 'Invalid number, unexpected digit after 0: ' + printCharCode(code) + '.');
  4689. }
  4690. } else {
  4691. position = readDigits(source, position, code);
  4692. code = charCodeAt.call(body, position);
  4693. }
  4694. if (code === 46) {
  4695. // .
  4696. isFloat = true;
  4697. code = charCodeAt.call(body, ++position);
  4698. position = readDigits(source, position, code);
  4699. code = charCodeAt.call(body, position);
  4700. }
  4701. if (code === 69 || code === 101) {
  4702. // E e
  4703. isFloat = true;
  4704. code = charCodeAt.call(body, ++position);
  4705. if (code === 43 || code === 45) {
  4706. // + -
  4707. code = charCodeAt.call(body, ++position);
  4708. }
  4709. position = readDigits(source, position, code);
  4710. }
  4711. return new Tok(isFloat ? FLOAT : INT, start, position, line, col, prev, slice.call(body, start, position));
  4712. }
  4713. /**
  4714. * Returns the new position in the source after reading digits.
  4715. */
  4716. function readDigits(source, start, firstCode) {
  4717. var body = source.body;
  4718. var position = start;
  4719. var code = firstCode;
  4720. if (code >= 48 && code <= 57) {
  4721. // 0 - 9
  4722. do {
  4723. code = charCodeAt.call(body, ++position);
  4724. } while (code >= 48 && code <= 57); // 0 - 9
  4725. return position;
  4726. }
  4727. throw (0, _error.syntaxError)(source, position, 'Invalid number, expected digit but got: ' + printCharCode(code) + '.');
  4728. }
  4729. /**
  4730. * Reads a string token from the source file.
  4731. *
  4732. * "([^"\\\u000A\u000D]|(\\(u[0-9a-fA-F]{4}|["\\/bfnrt])))*"
  4733. */
  4734. function readString(source, start, line, col, prev) {
  4735. var body = source.body;
  4736. var position = start + 1;
  4737. var chunkStart = position;
  4738. var code = 0;
  4739. var value = '';
  4740. while (position < body.length && (code = charCodeAt.call(body, position)) !== null &&
  4741. // not LineTerminator
  4742. code !== 0x000A && code !== 0x000D &&
  4743. // not Quote (")
  4744. code !== 34) {
  4745. // SourceCharacter
  4746. if (code < 0x0020 && code !== 0x0009) {
  4747. throw (0, _error.syntaxError)(source, position, 'Invalid character within String: ' + printCharCode(code) + '.');
  4748. }
  4749. ++position;
  4750. if (code === 92) {
  4751. // \
  4752. value += slice.call(body, chunkStart, position - 1);
  4753. code = charCodeAt.call(body, position);
  4754. switch (code) {
  4755. case 34:
  4756. value += '"';break;
  4757. case 47:
  4758. value += '/';break;
  4759. case 92:
  4760. value += '\\';break;
  4761. case 98:
  4762. value += '\b';break;
  4763. case 102:
  4764. value += '\f';break;
  4765. case 110:
  4766. value += '\n';break;
  4767. case 114:
  4768. value += '\r';break;
  4769. case 116:
  4770. value += '\t';break;
  4771. case 117:
  4772. // u
  4773. var charCode = uniCharCode(charCodeAt.call(body, position + 1), charCodeAt.call(body, position + 2), charCodeAt.call(body, position + 3), charCodeAt.call(body, position + 4));
  4774. if (charCode < 0) {
  4775. throw (0, _error.syntaxError)(source, position, 'Invalid character escape sequence: ' + ('\\u' + body.slice(position + 1, position + 5) + '.'));
  4776. }
  4777. value += String.fromCharCode(charCode);
  4778. position += 4;
  4779. break;
  4780. default:
  4781. throw (0, _error.syntaxError)(source, position, 'Invalid character escape sequence: \\' + String.fromCharCode(code) + '.');
  4782. }
  4783. ++position;
  4784. chunkStart = position;
  4785. }
  4786. }
  4787. if (code !== 34) {
  4788. // quote (")
  4789. throw (0, _error.syntaxError)(source, position, 'Unterminated string.');
  4790. }
  4791. value += slice.call(body, chunkStart, position);
  4792. return new Tok(STRING, start, position + 1, line, col, prev, value);
  4793. }
  4794. /**
  4795. * Converts four hexidecimal chars to the integer that the
  4796. * string represents. For example, uniCharCode('0','0','0','f')
  4797. * will return 15, and uniCharCode('0','0','f','f') returns 255.
  4798. *
  4799. * Returns a negative number on error, if a char was invalid.
  4800. *
  4801. * This is implemented by noting that char2hex() returns -1 on error,
  4802. * which means the result of ORing the char2hex() will also be negative.
  4803. */
  4804. function uniCharCode(a, b, c, d) {
  4805. return char2hex(a) << 12 | char2hex(b) << 8 | char2hex(c) << 4 | char2hex(d);
  4806. }
  4807. /**
  4808. * Converts a hex character to its integer value.
  4809. * '0' becomes 0, '9' becomes 9
  4810. * 'A' becomes 10, 'F' becomes 15
  4811. * 'a' becomes 10, 'f' becomes 15
  4812. *
  4813. * Returns -1 on error.
  4814. */
  4815. function char2hex(a) {
  4816. return a >= 48 && a <= 57 ? a - 48 : // 0-9
  4817. a >= 65 && a <= 70 ? a - 55 : // A-F
  4818. a >= 97 && a <= 102 ? a - 87 : // a-f
  4819. -1;
  4820. }
  4821. /**
  4822. * Reads an alphanumeric + underscore name from the source.
  4823. *
  4824. * [_A-Za-z][_0-9A-Za-z]*
  4825. */
  4826. function readName(source, position, line, col, prev) {
  4827. var body = source.body;
  4828. var bodyLength = body.length;
  4829. var end = position + 1;
  4830. var code = 0;
  4831. while (end !== bodyLength && (code = charCodeAt.call(body, end)) !== null && (code === 95 || // _
  4832. code >= 48 && code <= 57 || // 0-9
  4833. code >= 65 && code <= 90 || // A-Z
  4834. code >= 97 && code <= 122 // a-z
  4835. )) {
  4836. ++end;
  4837. }
  4838. return new Tok(NAME, position, end, line, col, prev, slice.call(body, position, end));
  4839. }
  4840. /***/ }),
  4841. /* 25 */
  4842. /***/ (function(module, exports, __webpack_require__) {
  4843. "use strict";
  4844. Object.defineProperty(exports, "__esModule", {
  4845. value: true
  4846. });
  4847. exports.getLocation = getLocation;
  4848. /**
  4849. * Takes a Source and a UTF-8 character offset, and returns the corresponding
  4850. * line and column as a SourceLocation.
  4851. */
  4852. /**
  4853. * Copyright (c) 2015, Facebook, Inc.
  4854. * All rights reserved.
  4855. *
  4856. * This source code is licensed under the BSD-style license found in the
  4857. * LICENSE file in the root directory of this source tree. An additional grant
  4858. * of patent rights can be found in the PATENTS file in the same directory.
  4859. */
  4860. function getLocation(source, position) {
  4861. var lineRegexp = /\r\n|[\n\r]/g;
  4862. var line = 1;
  4863. var column = position + 1;
  4864. var match = void 0;
  4865. while ((match = lineRegexp.exec(source.body)) && match.index < position) {
  4866. line += 1;
  4867. column = position + 1 - (match.index + match[0].length);
  4868. }
  4869. return { line: line, column: column };
  4870. }
  4871. /**
  4872. * Represents a location in a Source.
  4873. */
  4874. /***/ }),
  4875. /* 26 */
  4876. /***/ (function(module, exports, __webpack_require__) {
  4877. "use strict";
  4878. Object.defineProperty(exports, "__esModule", {
  4879. value: true
  4880. });
  4881. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4882. /**
  4883. * Copyright (c) 2015, Facebook, Inc.
  4884. * All rights reserved.
  4885. *
  4886. * This source code is licensed under the BSD-style license found in the
  4887. * LICENSE file in the root directory of this source tree. An additional grant
  4888. * of patent rights can be found in the PATENTS file in the same directory.
  4889. */
  4890. /**
  4891. * A representation of source input to GraphQL. The name is optional,
  4892. * but is mostly useful for clients who store GraphQL documents in
  4893. * source files; for example, if the GraphQL input is in a file Foo.graphql,
  4894. * it might be useful for name to be "Foo.graphql".
  4895. */
  4896. var Source = exports.Source = function Source(body, name) {
  4897. _classCallCheck(this, Source);
  4898. this.body = body;
  4899. this.name = name || 'GraphQL';
  4900. };
  4901. /***/ }),
  4902. /* 27 */
  4903. /***/ (function(module, exports, __webpack_require__) {
  4904. "use strict";
  4905. Object.defineProperty(exports, "__esModule", {
  4906. value: true
  4907. });
  4908. exports.TypeInfo = undefined;
  4909. var _kinds = __webpack_require__(2);
  4910. var Kind = _interopRequireWildcard(_kinds);
  4911. var _definition = __webpack_require__(1);
  4912. var _introspection = __webpack_require__(11);
  4913. var _typeFromAST = __webpack_require__(9);
  4914. var _find = __webpack_require__(10);
  4915. var _find2 = _interopRequireDefault(_find);
  4916. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  4917. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  4918. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4919. /**
  4920. * Copyright (c) 2015, Facebook, Inc.
  4921. * All rights reserved.
  4922. *
  4923. * This source code is licensed under the BSD-style license found in the
  4924. * LICENSE file in the root directory of this source tree. An additional grant
  4925. * of patent rights can be found in the PATENTS file in the same directory.
  4926. */
  4927. /**
  4928. * TypeInfo is a utility class which, given a GraphQL schema, can keep track
  4929. * of the current field and type definitions at any point in a GraphQL document
  4930. * AST during a recursive descent by calling `enter(node)` and `leave(node)`.
  4931. */
  4932. var TypeInfo = exports.TypeInfo = function () {
  4933. function TypeInfo(schema,
  4934. // NOTE: this experimental optional second parameter is only needed in order
  4935. // to support non-spec-compliant codebases. You should never need to use it.
  4936. getFieldDefFn) {
  4937. _classCallCheck(this, TypeInfo);
  4938. this._schema = schema;
  4939. this._typeStack = [];
  4940. this._parentTypeStack = [];
  4941. this._inputTypeStack = [];
  4942. this._fieldDefStack = [];
  4943. this._directive = null;
  4944. this._argument = null;
  4945. this._enumValue = null;
  4946. this._getFieldDef = getFieldDefFn || getFieldDef;
  4947. }
  4948. TypeInfo.prototype.getType = function getType() {
  4949. if (this._typeStack.length > 0) {
  4950. return this._typeStack[this._typeStack.length - 1];
  4951. }
  4952. };
  4953. TypeInfo.prototype.getParentType = function getParentType() {
  4954. if (this._parentTypeStack.length > 0) {
  4955. return this._parentTypeStack[this._parentTypeStack.length - 1];
  4956. }
  4957. };
  4958. TypeInfo.prototype.getInputType = function getInputType() {
  4959. if (this._inputTypeStack.length > 0) {
  4960. return this._inputTypeStack[this._inputTypeStack.length - 1];
  4961. }
  4962. };
  4963. TypeInfo.prototype.getFieldDef = function getFieldDef() {
  4964. if (this._fieldDefStack.length > 0) {
  4965. return this._fieldDefStack[this._fieldDefStack.length - 1];
  4966. }
  4967. };
  4968. TypeInfo.prototype.getDirective = function getDirective() {
  4969. return this._directive;
  4970. };
  4971. TypeInfo.prototype.getArgument = function getArgument() {
  4972. return this._argument;
  4973. };
  4974. TypeInfo.prototype.getEnumValue = function getEnumValue() {
  4975. return this._enumValue;
  4976. };
  4977. // Flow does not yet handle this case.
  4978. TypeInfo.prototype.enter = function enter(node /* ASTNode */) {
  4979. var schema = this._schema;
  4980. switch (node.kind) {
  4981. case Kind.SELECTION_SET:
  4982. var namedType = (0, _definition.getNamedType)(this.getType());
  4983. var compositeType = void 0;
  4984. if ((0, _definition.isCompositeType)(namedType)) {
  4985. // isCompositeType is a type refining predicate, so this is safe.
  4986. compositeType = namedType;
  4987. }
  4988. this._parentTypeStack.push(compositeType);
  4989. break;
  4990. case Kind.FIELD:
  4991. var parentType = this.getParentType();
  4992. var fieldDef = void 0;
  4993. if (parentType) {
  4994. fieldDef = this._getFieldDef(schema, parentType, node);
  4995. }
  4996. this._fieldDefStack.push(fieldDef);
  4997. this._typeStack.push(fieldDef && fieldDef.type);
  4998. break;
  4999. case Kind.DIRECTIVE:
  5000. this._directive = schema.getDirective(node.name.value);
  5001. break;
  5002. case Kind.OPERATION_DEFINITION:
  5003. var type = void 0;
  5004. if (node.operation === 'query') {
  5005. type = schema.getQueryType();
  5006. } else if (node.operation === 'mutation') {
  5007. type = schema.getMutationType();
  5008. } else if (node.operation === 'subscription') {
  5009. type = schema.getSubscriptionType();
  5010. }
  5011. this._typeStack.push(type);
  5012. break;
  5013. case Kind.INLINE_FRAGMENT:
  5014. case Kind.FRAGMENT_DEFINITION:
  5015. var typeConditionAST = node.typeCondition;
  5016. var outputType = typeConditionAST ? (0, _typeFromAST.typeFromAST)(schema, typeConditionAST) : this.getType();
  5017. this._typeStack.push(outputType);
  5018. break;
  5019. case Kind.VARIABLE_DEFINITION:
  5020. var inputType = (0, _typeFromAST.typeFromAST)(schema, node.type);
  5021. this._inputTypeStack.push(inputType);
  5022. break;
  5023. case Kind.ARGUMENT:
  5024. var argDef = void 0;
  5025. var argType = void 0;
  5026. var fieldOrDirective = this.getDirective() || this.getFieldDef();
  5027. if (fieldOrDirective) {
  5028. argDef = (0, _find2.default)(fieldOrDirective.args, function (arg) {
  5029. return arg.name === node.name.value;
  5030. });
  5031. if (argDef) {
  5032. argType = argDef.type;
  5033. }
  5034. }
  5035. this._argument = argDef;
  5036. this._inputTypeStack.push(argType);
  5037. break;
  5038. case Kind.LIST:
  5039. var listType = (0, _definition.getNullableType)(this.getInputType());
  5040. this._inputTypeStack.push(listType instanceof _definition.GraphQLList ? listType.ofType : undefined);
  5041. break;
  5042. case Kind.OBJECT_FIELD:
  5043. var objectType = (0, _definition.getNamedType)(this.getInputType());
  5044. var fieldType = void 0;
  5045. if (objectType instanceof _definition.GraphQLInputObjectType) {
  5046. var inputField = objectType.getFields()[node.name.value];
  5047. fieldType = inputField ? inputField.type : undefined;
  5048. }
  5049. this._inputTypeStack.push(fieldType);
  5050. break;
  5051. case Kind.ENUM:
  5052. var enumType = (0, _definition.getNamedType)(this.getInputType());
  5053. var enumValue = void 0;
  5054. if (enumType instanceof _definition.GraphQLEnumType) {
  5055. enumValue = enumType.getValue(node.value);
  5056. }
  5057. this._enumValue = enumValue;
  5058. break;
  5059. }
  5060. };
  5061. TypeInfo.prototype.leave = function leave(node) {
  5062. switch (node.kind) {
  5063. case Kind.SELECTION_SET:
  5064. this._parentTypeStack.pop();
  5065. break;
  5066. case Kind.FIELD:
  5067. this._fieldDefStack.pop();
  5068. this._typeStack.pop();
  5069. break;
  5070. case Kind.DIRECTIVE:
  5071. this._directive = null;
  5072. break;
  5073. case Kind.OPERATION_DEFINITION:
  5074. case Kind.INLINE_FRAGMENT:
  5075. case Kind.FRAGMENT_DEFINITION:
  5076. this._typeStack.pop();
  5077. break;
  5078. case Kind.VARIABLE_DEFINITION:
  5079. this._inputTypeStack.pop();
  5080. break;
  5081. case Kind.ARGUMENT:
  5082. this._argument = null;
  5083. this._inputTypeStack.pop();
  5084. break;
  5085. case Kind.LIST:
  5086. case Kind.OBJECT_FIELD:
  5087. this._inputTypeStack.pop();
  5088. break;
  5089. case Kind.ENUM:
  5090. this._enumValue = null;
  5091. break;
  5092. }
  5093. };
  5094. return TypeInfo;
  5095. }();
  5096. /**
  5097. * Not exactly the same as the executor's definition of getFieldDef, in this
  5098. * statically evaluated environment we do not always have an Object type,
  5099. * and need to handle Interface and Union types.
  5100. */
  5101. function getFieldDef(schema, parentType, fieldNode) {
  5102. var name = fieldNode.name.value;
  5103. if (name === _introspection.SchemaMetaFieldDef.name && schema.getQueryType() === parentType) {
  5104. return _introspection.SchemaMetaFieldDef;
  5105. }
  5106. if (name === _introspection.TypeMetaFieldDef.name && schema.getQueryType() === parentType) {
  5107. return _introspection.TypeMetaFieldDef;
  5108. }
  5109. if (name === _introspection.TypeNameMetaFieldDef.name && (parentType instanceof _definition.GraphQLObjectType || parentType instanceof _definition.GraphQLInterfaceType || parentType instanceof _definition.GraphQLUnionType)) {
  5110. return _introspection.TypeNameMetaFieldDef;
  5111. }
  5112. if (parentType instanceof _definition.GraphQLObjectType || parentType instanceof _definition.GraphQLInterfaceType) {
  5113. return parentType.getFields()[name];
  5114. }
  5115. }
  5116. /***/ }),
  5117. /* 28 */
  5118. /***/ (function(module, exports, __webpack_require__) {
  5119. "use strict";
  5120. Object.defineProperty(exports, "__esModule", {
  5121. value: true
  5122. });
  5123. exports.assertValidName = assertValidName;
  5124. /**
  5125. * Copyright (c) 2015, Facebook, Inc.
  5126. * All rights reserved.
  5127. *
  5128. * This source code is licensed under the BSD-style license found in the
  5129. * LICENSE file in the root directory of this source tree. An additional grant
  5130. * of patent rights can be found in the PATENTS file in the same directory.
  5131. */
  5132. var NAME_RX = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
  5133. // Ensures console warnings are only issued once.
  5134. var hasWarnedAboutDunder = false;
  5135. /**
  5136. * Upholds the spec rules about naming.
  5137. */
  5138. function assertValidName(name, isIntrospection) {
  5139. if (!name || typeof name !== 'string') {
  5140. throw new Error('Must be named. Unexpected name: ' + name + '.');
  5141. }
  5142. if (!isIntrospection && name.slice(0, 2) === '__' && !hasWarnedAboutDunder) {
  5143. hasWarnedAboutDunder = true;
  5144. /* eslint-disable no-console */
  5145. if (console && console.error) {
  5146. var error = new Error('Name "' + name + '" must not begin with "__", which is reserved by ' + 'GraphQL introspection.');
  5147. console.error(error.stack || String(error));
  5148. }
  5149. /* eslint-enable no-console */
  5150. }
  5151. if (!NAME_RX.test(name)) {
  5152. throw new Error('Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but "' + name + '" does not.');
  5153. }
  5154. }
  5155. /***/ }),
  5156. /* 29 */
  5157. /***/ (function(module, exports, __webpack_require__) {
  5158. "use strict";
  5159. Object.defineProperty(exports, "__esModule", {
  5160. value: true
  5161. });
  5162. exports.astFromValue = astFromValue;
  5163. var _iterall = __webpack_require__(20);
  5164. var _invariant = __webpack_require__(3);
  5165. var _invariant2 = _interopRequireDefault(_invariant);
  5166. var _isNullish = __webpack_require__(6);
  5167. var _isNullish2 = _interopRequireDefault(_isNullish);
  5168. var _isInvalid = __webpack_require__(14);
  5169. var _isInvalid2 = _interopRequireDefault(_isInvalid);
  5170. var _kinds = __webpack_require__(2);
  5171. var _definition = __webpack_require__(1);
  5172. var _scalars = __webpack_require__(7);
  5173. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5174. /**
  5175. * Produces a GraphQL Value AST given a JavaScript value.
  5176. *
  5177. * A GraphQL type must be provided, which will be used to interpret different
  5178. * JavaScript values.
  5179. *
  5180. * | JSON Value | GraphQL Value |
  5181. * | ------------- | -------------------- |
  5182. * | Object | Input Object |
  5183. * | Array | List |
  5184. * | Boolean | Boolean |
  5185. * | String | String / Enum Value |
  5186. * | Number | Int / Float |
  5187. * | Mixed | Enum Value |
  5188. * | null | NullValue |
  5189. *
  5190. */
  5191. function astFromValue(value, type) {
  5192. // Ensure flow knows that we treat function params as const.
  5193. var _value = value;
  5194. if (type instanceof _definition.GraphQLNonNull) {
  5195. var astValue = astFromValue(_value, type.ofType);
  5196. if (astValue && astValue.kind === _kinds.NULL) {
  5197. return null;
  5198. }
  5199. return astValue;
  5200. }
  5201. // only explicit null, not undefined, NaN
  5202. if (_value === null) {
  5203. return { kind: _kinds.NULL };
  5204. }
  5205. // undefined, NaN
  5206. if ((0, _isInvalid2.default)(_value)) {
  5207. return null;
  5208. }
  5209. // Convert JavaScript array to GraphQL list. If the GraphQLType is a list, but
  5210. // the value is not an array, convert the value using the list's item type.
  5211. if (type instanceof _definition.GraphQLList) {
  5212. var _ret = function () {
  5213. var itemType = type.ofType;
  5214. if ((0, _iterall.isCollection)(_value)) {
  5215. var _ret2 = function () {
  5216. var valuesNodes = [];
  5217. (0, _iterall.forEach)(_value, function (item) {
  5218. var itemNode = astFromValue(item, itemType);
  5219. if (itemNode) {
  5220. valuesNodes.push(itemNode);
  5221. }
  5222. });
  5223. return {
  5224. v: {
  5225. v: { kind: _kinds.LIST, values: valuesNodes }
  5226. }
  5227. };
  5228. }();
  5229. if (typeof _ret2 === "object") return _ret2.v;
  5230. }
  5231. return {
  5232. v: astFromValue(_value, itemType)
  5233. };
  5234. }();
  5235. if (typeof _ret === "object") return _ret.v;
  5236. }
  5237. // Populate the fields of the input object by creating ASTs from each value
  5238. // in the JavaScript object according to the fields in the input type.
  5239. if (type instanceof _definition.GraphQLInputObjectType) {
  5240. var _ret3 = function () {
  5241. if (_value === null || typeof _value !== 'object') {
  5242. return {
  5243. v: null
  5244. };
  5245. }
  5246. var fields = type.getFields();
  5247. var fieldNodes = [];
  5248. Object.keys(fields).forEach(function (fieldName) {
  5249. var fieldType = fields[fieldName].type;
  5250. var fieldValue = astFromValue(_value[fieldName], fieldType);
  5251. if (fieldValue) {
  5252. fieldNodes.push({
  5253. kind: _kinds.OBJECT_FIELD,
  5254. name: { kind: _kinds.NAME, value: fieldName },
  5255. value: fieldValue
  5256. });
  5257. }
  5258. });
  5259. return {
  5260. v: { kind: _kinds.OBJECT, fields: fieldNodes }
  5261. };
  5262. }();
  5263. if (typeof _ret3 === "object") return _ret3.v;
  5264. }
  5265. (0, _invariant2.default)(type instanceof _definition.GraphQLScalarType || type instanceof _definition.GraphQLEnumType, 'Must provide Input Type, cannot use: ' + String(type));
  5266. // Since value is an internally represented value, it must be serialized
  5267. // to an externally represented value before converting into an AST.
  5268. var serialized = type.serialize(_value);
  5269. if ((0, _isNullish2.default)(serialized)) {
  5270. return null;
  5271. }
  5272. // Others serialize based on their corresponding JavaScript scalar types.
  5273. if (typeof serialized === 'boolean') {
  5274. return { kind: _kinds.BOOLEAN, value: serialized };
  5275. }
  5276. // JavaScript numbers can be Int or Float values.
  5277. if (typeof serialized === 'number') {
  5278. var stringNum = String(serialized);
  5279. return (/^[0-9]+$/.test(stringNum) ? { kind: _kinds.INT, value: stringNum } : { kind: _kinds.FLOAT, value: stringNum }
  5280. );
  5281. }
  5282. if (typeof serialized === 'string') {
  5283. // Enum types use Enum literals.
  5284. if (type instanceof _definition.GraphQLEnumType) {
  5285. return { kind: _kinds.ENUM, value: serialized };
  5286. }
  5287. // ID types can use Int literals.
  5288. if (type === _scalars.GraphQLID && /^[0-9]+$/.test(serialized)) {
  5289. return { kind: _kinds.INT, value: serialized };
  5290. }
  5291. // Use JSON stringify, which uses the same string encoding as GraphQL,
  5292. // then remove the quotes.
  5293. return {
  5294. kind: _kinds.STRING,
  5295. value: JSON.stringify(serialized).slice(1, -1)
  5296. };
  5297. }
  5298. throw new TypeError('Cannot convert value to AST: ' + String(serialized));
  5299. }
  5300. /**
  5301. * Copyright (c) 2015, Facebook, Inc.
  5302. * All rights reserved.
  5303. *
  5304. * This source code is licensed under the BSD-style license found in the
  5305. * LICENSE file in the root directory of this source tree. An additional grant
  5306. * of patent rights can be found in the PATENTS file in the same directory.
  5307. */
  5308. /***/ }),
  5309. /* 30 */
  5310. /***/ (function(module, exports, __webpack_require__) {
  5311. "use strict";
  5312. Object.defineProperty(exports, "__esModule", {
  5313. value: true
  5314. });
  5315. exports.defaultFieldResolver = undefined;
  5316. exports.execute = execute;
  5317. exports.responsePathAsArray = responsePathAsArray;
  5318. var _iterall = __webpack_require__(20);
  5319. var _error = __webpack_require__(0);
  5320. var _find = __webpack_require__(10);
  5321. var _find2 = _interopRequireDefault(_find);
  5322. var _invariant = __webpack_require__(3);
  5323. var _invariant2 = _interopRequireDefault(_invariant);
  5324. var _isNullish = __webpack_require__(6);
  5325. var _isNullish2 = _interopRequireDefault(_isNullish);
  5326. var _typeFromAST = __webpack_require__(9);
  5327. var _kinds = __webpack_require__(2);
  5328. var Kind = _interopRequireWildcard(_kinds);
  5329. var _values = __webpack_require__(31);
  5330. var _definition = __webpack_require__(1);
  5331. var _schema = __webpack_require__(8);
  5332. var _introspection = __webpack_require__(11);
  5333. var _directives = __webpack_require__(5);
  5334. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  5335. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  5336. /**
  5337. * Implements the "Evaluating requests" section of the GraphQL specification.
  5338. *
  5339. * Returns a Promise that will eventually be resolved and never rejected.
  5340. *
  5341. * If the arguments to this function do not result in a legal execution context,
  5342. * a GraphQLError will be thrown immediately explaining the invalid input.
  5343. */
  5344. /**
  5345. * Terminology
  5346. *
  5347. * "Definitions" are the generic name for top-level statements in the document.
  5348. * Examples of this include:
  5349. * 1) Operations (such as a query)
  5350. * 2) Fragments
  5351. *
  5352. * "Operations" are a generic name for requests in the document.
  5353. * Examples of this include:
  5354. * 1) query,
  5355. * 2) mutation
  5356. *
  5357. * "Selections" are the definitions that can appear legally and at
  5358. * single level of the query. These include:
  5359. * 1) field references e.g "a"
  5360. * 2) fragment "spreads" e.g. "...c"
  5361. * 3) inline fragment "spreads" e.g. "...on Type { a }"
  5362. */
  5363. /**
  5364. * Data that must be available at all points during query execution.
  5365. *
  5366. * Namely, schema of the type system that is currently executing,
  5367. * and the fragments defined in the query document
  5368. */
  5369. /**
  5370. * The result of GraphQL execution.
  5371. *
  5372. * - `data` is the result of a successful execution of the query.
  5373. * - `errors` is included when any errors occurred as a non-empty array.
  5374. */
  5375. /**
  5376. * Copyright (c) 2015, Facebook, Inc.
  5377. * All rights reserved.
  5378. *
  5379. * This source code is licensed under the BSD-style license found in the
  5380. * LICENSE file in the root directory of this source tree. An additional grant
  5381. * of patent rights can be found in the PATENTS file in the same directory.
  5382. */
  5383. function execute(schema, document, rootValue, contextValue, variableValues, operationName) {
  5384. (0, _invariant2.default)(schema, 'Must provide schema');
  5385. (0, _invariant2.default)(document, 'Must provide document');
  5386. (0, _invariant2.default)(schema instanceof _schema.GraphQLSchema, 'Schema must be an instance of GraphQLSchema. Also ensure that there are ' + 'not multiple versions of GraphQL installed in your node_modules directory.');
  5387. // Variables, if provided, must be an object.
  5388. (0, _invariant2.default)(!variableValues || typeof variableValues === 'object', 'Variables must be provided as an Object where each property is a ' + 'variable value. Perhaps look to see if an unparsed JSON string ' + 'was provided.');
  5389. // If a valid context cannot be created due to incorrect arguments,
  5390. // this will throw an error.
  5391. var context = buildExecutionContext(schema, document, rootValue, contextValue, variableValues, operationName);
  5392. // Return a Promise that will eventually resolve to the data described by
  5393. // The "Response" section of the GraphQL specification.
  5394. //
  5395. // If errors are encountered while executing a GraphQL field, only that
  5396. // field and its descendants will be omitted, and sibling fields will still
  5397. // be executed. An execution which encounters errors will still result in a
  5398. // resolved Promise.
  5399. return new Promise(function (resolve) {
  5400. resolve(executeOperation(context, context.operation, rootValue));
  5401. }).then(undefined, function (error) {
  5402. // Errors from sub-fields of a NonNull type may propagate to the top level,
  5403. // at which point we still log the error and null the parent field, which
  5404. // in this case is the entire response.
  5405. context.errors.push(error);
  5406. return null;
  5407. }).then(function (data) {
  5408. if (!context.errors.length) {
  5409. return { data: data };
  5410. }
  5411. return { data: data, errors: context.errors };
  5412. });
  5413. }
  5414. /**
  5415. * Given a ResponsePath (found in the `path` entry in the information provided
  5416. * as the last argument to a field resolver), return an Array of the path keys.
  5417. */
  5418. function responsePathAsArray(path) {
  5419. var flattened = [];
  5420. var curr = path;
  5421. while (curr) {
  5422. flattened.push(curr.key);
  5423. curr = curr.prev;
  5424. }
  5425. return flattened.reverse();
  5426. }
  5427. function addPath(prev, key) {
  5428. return { prev: prev, key: key };
  5429. }
  5430. /**
  5431. * Constructs a ExecutionContext object from the arguments passed to
  5432. * execute, which we will pass throughout the other execution methods.
  5433. *
  5434. * Throws a GraphQLError if a valid execution context cannot be created.
  5435. */
  5436. function buildExecutionContext(schema, document, rootValue, contextValue, rawVariableValues, operationName) {
  5437. var errors = [];
  5438. var operation = void 0;
  5439. var fragments = Object.create(null);
  5440. document.definitions.forEach(function (definition) {
  5441. switch (definition.kind) {
  5442. case Kind.OPERATION_DEFINITION:
  5443. if (!operationName && operation) {
  5444. throw new _error.GraphQLError('Must provide operation name if query contains multiple operations.');
  5445. }
  5446. if (!operationName || definition.name && definition.name.value === operationName) {
  5447. operation = definition;
  5448. }
  5449. break;
  5450. case Kind.FRAGMENT_DEFINITION:
  5451. fragments[definition.name.value] = definition;
  5452. break;
  5453. default:
  5454. throw new _error.GraphQLError('GraphQL cannot execute a request containing a ' + definition.kind + '.', [definition]);
  5455. }
  5456. });
  5457. if (!operation) {
  5458. if (operationName) {
  5459. throw new _error.GraphQLError('Unknown operation named "' + operationName + '".');
  5460. } else {
  5461. throw new _error.GraphQLError('Must provide an operation.');
  5462. }
  5463. }
  5464. var variableValues = (0, _values.getVariableValues)(schema, operation.variableDefinitions || [], rawVariableValues || {});
  5465. return {
  5466. schema: schema,
  5467. fragments: fragments,
  5468. rootValue: rootValue,
  5469. contextValue: contextValue,
  5470. operation: operation,
  5471. variableValues: variableValues,
  5472. errors: errors
  5473. };
  5474. }
  5475. /**
  5476. * Implements the "Evaluating operations" section of the spec.
  5477. */
  5478. function executeOperation(exeContext, operation, rootValue) {
  5479. var type = getOperationRootType(exeContext.schema, operation);
  5480. var fields = collectFields(exeContext, type, operation.selectionSet, Object.create(null), Object.create(null));
  5481. var path = undefined;
  5482. if (operation.operation === 'mutation') {
  5483. return executeFieldsSerially(exeContext, type, rootValue, path, fields);
  5484. }
  5485. return executeFields(exeContext, type, rootValue, path, fields);
  5486. }
  5487. /**
  5488. * Extracts the root type of the operation from the schema.
  5489. */
  5490. function getOperationRootType(schema, operation) {
  5491. switch (operation.operation) {
  5492. case 'query':
  5493. return schema.getQueryType();
  5494. case 'mutation':
  5495. var mutationType = schema.getMutationType();
  5496. if (!mutationType) {
  5497. throw new _error.GraphQLError('Schema is not configured for mutations', [operation]);
  5498. }
  5499. return mutationType;
  5500. case 'subscription':
  5501. var subscriptionType = schema.getSubscriptionType();
  5502. if (!subscriptionType) {
  5503. throw new _error.GraphQLError('Schema is not configured for subscriptions', [operation]);
  5504. }
  5505. return subscriptionType;
  5506. default:
  5507. throw new _error.GraphQLError('Can only execute queries, mutations and subscriptions', [operation]);
  5508. }
  5509. }
  5510. /**
  5511. * Implements the "Evaluating selection sets" section of the spec
  5512. * for "write" mode.
  5513. */
  5514. function executeFieldsSerially(exeContext, parentType, sourceValue, path, fields) {
  5515. return Object.keys(fields).reduce(function (prevPromise, responseName) {
  5516. return prevPromise.then(function (results) {
  5517. var fieldNodes = fields[responseName];
  5518. var fieldPath = addPath(path, responseName);
  5519. var result = resolveField(exeContext, parentType, sourceValue, fieldNodes, fieldPath);
  5520. if (result === undefined) {
  5521. return results;
  5522. }
  5523. if (isThenable(result)) {
  5524. return result.then(function (resolvedResult) {
  5525. results[responseName] = resolvedResult;
  5526. return results;
  5527. });
  5528. }
  5529. results[responseName] = result;
  5530. return results;
  5531. });
  5532. }, Promise.resolve({}));
  5533. }
  5534. /**
  5535. * Implements the "Evaluating selection sets" section of the spec
  5536. * for "read" mode.
  5537. */
  5538. function executeFields(exeContext, parentType, sourceValue, path, fields) {
  5539. var containsPromise = false;
  5540. var finalResults = Object.keys(fields).reduce(function (results, responseName) {
  5541. var fieldNodes = fields[responseName];
  5542. var fieldPath = addPath(path, responseName);
  5543. var result = resolveField(exeContext, parentType, sourceValue, fieldNodes, fieldPath);
  5544. if (result === undefined) {
  5545. return results;
  5546. }
  5547. results[responseName] = result;
  5548. if (isThenable(result)) {
  5549. containsPromise = true;
  5550. }
  5551. return results;
  5552. }, Object.create(null));
  5553. // If there are no promises, we can just return the object
  5554. if (!containsPromise) {
  5555. return finalResults;
  5556. }
  5557. // Otherwise, results is a map from field name to the result
  5558. // of resolving that field, which is possibly a promise. Return
  5559. // a promise that will return this same map, but with any
  5560. // promises replaced with the values they resolved to.
  5561. return promiseForObject(finalResults);
  5562. }
  5563. /**
  5564. * Given a selectionSet, adds all of the fields in that selection to
  5565. * the passed in map of fields, and returns it at the end.
  5566. *
  5567. * CollectFields requires the "runtime type" of an object. For a field which
  5568. * returns and Interface or Union type, the "runtime type" will be the actual
  5569. * Object type returned by that field.
  5570. */
  5571. function collectFields(exeContext, runtimeType, selectionSet, fields, visitedFragmentNames) {
  5572. for (var i = 0; i < selectionSet.selections.length; i++) {
  5573. var selection = selectionSet.selections[i];
  5574. switch (selection.kind) {
  5575. case Kind.FIELD:
  5576. if (!shouldIncludeNode(exeContext, selection.directives)) {
  5577. continue;
  5578. }
  5579. var _name = getFieldEntryKey(selection);
  5580. if (!fields[_name]) {
  5581. fields[_name] = [];
  5582. }
  5583. fields[_name].push(selection);
  5584. break;
  5585. case Kind.INLINE_FRAGMENT:
  5586. if (!shouldIncludeNode(exeContext, selection.directives) || !doesFragmentConditionMatch(exeContext, selection, runtimeType)) {
  5587. continue;
  5588. }
  5589. collectFields(exeContext, runtimeType, selection.selectionSet, fields, visitedFragmentNames);
  5590. break;
  5591. case Kind.FRAGMENT_SPREAD:
  5592. var fragName = selection.name.value;
  5593. if (visitedFragmentNames[fragName] || !shouldIncludeNode(exeContext, selection.directives)) {
  5594. continue;
  5595. }
  5596. visitedFragmentNames[fragName] = true;
  5597. var fragment = exeContext.fragments[fragName];
  5598. if (!fragment || !doesFragmentConditionMatch(exeContext, fragment, runtimeType)) {
  5599. continue;
  5600. }
  5601. collectFields(exeContext, runtimeType, fragment.selectionSet, fields, visitedFragmentNames);
  5602. break;
  5603. }
  5604. }
  5605. return fields;
  5606. }
  5607. /**
  5608. * Determines if a field should be included based on the @include and @skip
  5609. * directives, where @skip has higher precidence than @include.
  5610. */
  5611. function shouldIncludeNode(exeContext, directives) {
  5612. var skipNode = directives && (0, _find2.default)(directives, function (directive) {
  5613. return directive.name.value === _directives.GraphQLSkipDirective.name;
  5614. });
  5615. if (skipNode) {
  5616. var _getArgumentValues = (0, _values.getArgumentValues)(_directives.GraphQLSkipDirective, skipNode, exeContext.variableValues),
  5617. skipIf = _getArgumentValues.if;
  5618. if (skipIf === true) {
  5619. return false;
  5620. }
  5621. }
  5622. var includeNode = directives && (0, _find2.default)(directives, function (directive) {
  5623. return directive.name.value === _directives.GraphQLIncludeDirective.name;
  5624. });
  5625. if (includeNode) {
  5626. var _getArgumentValues2 = (0, _values.getArgumentValues)(_directives.GraphQLIncludeDirective, includeNode, exeContext.variableValues),
  5627. includeIf = _getArgumentValues2.if;
  5628. if (includeIf === false) {
  5629. return false;
  5630. }
  5631. }
  5632. return true;
  5633. }
  5634. /**
  5635. * Determines if a fragment is applicable to the given type.
  5636. */
  5637. function doesFragmentConditionMatch(exeContext, fragment, type) {
  5638. var typeConditionNode = fragment.typeCondition;
  5639. if (!typeConditionNode) {
  5640. return true;
  5641. }
  5642. var conditionalType = (0, _typeFromAST.typeFromAST)(exeContext.schema, typeConditionNode);
  5643. if (conditionalType === type) {
  5644. return true;
  5645. }
  5646. if ((0, _definition.isAbstractType)(conditionalType)) {
  5647. var abstractType = conditionalType;
  5648. return exeContext.schema.isPossibleType(abstractType, type);
  5649. }
  5650. return false;
  5651. }
  5652. /**
  5653. * This function transforms a JS object `{[key: string]: Promise<T>}` into
  5654. * a `Promise<{[key: string]: T}>`
  5655. *
  5656. * This is akin to bluebird's `Promise.props`, but implemented only using
  5657. * `Promise.all` so it will work with any implementation of ES6 promises.
  5658. */
  5659. function promiseForObject(object) {
  5660. var keys = Object.keys(object);
  5661. var valuesAndPromises = keys.map(function (name) {
  5662. return object[name];
  5663. });
  5664. return Promise.all(valuesAndPromises).then(function (values) {
  5665. return values.reduce(function (resolvedObject, value, i) {
  5666. resolvedObject[keys[i]] = value;
  5667. return resolvedObject;
  5668. }, Object.create(null));
  5669. });
  5670. }
  5671. /**
  5672. * Implements the logic to compute the key of a given field's entry
  5673. */
  5674. function getFieldEntryKey(node) {
  5675. return node.alias ? node.alias.value : node.name.value;
  5676. }
  5677. /**
  5678. * Resolves the field on the given source object. In particular, this
  5679. * figures out the value that the field returns by calling its resolve function,
  5680. * then calls completeValue to complete promises, serialize scalars, or execute
  5681. * the sub-selection-set for objects.
  5682. */
  5683. function resolveField(exeContext, parentType, source, fieldNodes, path) {
  5684. var fieldNode = fieldNodes[0];
  5685. var fieldName = fieldNode.name.value;
  5686. var fieldDef = getFieldDef(exeContext.schema, parentType, fieldName);
  5687. if (!fieldDef) {
  5688. return;
  5689. }
  5690. var returnType = fieldDef.type;
  5691. var resolveFn = fieldDef.resolve || defaultFieldResolver;
  5692. // The resolve function's optional third argument is a context value that
  5693. // is provided to every resolve function within an execution. It is commonly
  5694. // used to represent an authenticated user, or request-specific caches.
  5695. var context = exeContext.contextValue;
  5696. // The resolve function's optional fourth argument is a collection of
  5697. // information about the current execution state.
  5698. var info = {
  5699. fieldName: fieldName,
  5700. fieldNodes: fieldNodes,
  5701. returnType: returnType,
  5702. parentType: parentType,
  5703. path: path,
  5704. schema: exeContext.schema,
  5705. fragments: exeContext.fragments,
  5706. rootValue: exeContext.rootValue,
  5707. operation: exeContext.operation,
  5708. variableValues: exeContext.variableValues
  5709. };
  5710. // Get the resolve function, regardless of if its result is normal
  5711. // or abrupt (error).
  5712. var result = resolveOrError(exeContext, fieldDef, fieldNode, resolveFn, source, context, info);
  5713. return completeValueCatchingError(exeContext, returnType, fieldNodes, info, path, result);
  5714. }
  5715. // Isolates the "ReturnOrAbrupt" behavior to not de-opt the `resolveField`
  5716. // function. Returns the result of resolveFn or the abrupt-return Error object.
  5717. function resolveOrError(exeContext, fieldDef, fieldNode, resolveFn, source, context, info) {
  5718. try {
  5719. // Build a JS object of arguments from the field.arguments AST, using the
  5720. // variables scope to fulfill any variable references.
  5721. // TODO: find a way to memoize, in case this field is within a List type.
  5722. var args = (0, _values.getArgumentValues)(fieldDef, fieldNode, exeContext.variableValues);
  5723. return resolveFn(source, args, context, info);
  5724. } catch (error) {
  5725. // Sometimes a non-error is thrown, wrap it as an Error for a
  5726. // consistent interface.
  5727. return error instanceof Error ? error : new Error(error);
  5728. }
  5729. }
  5730. // This is a small wrapper around completeValue which detects and logs errors
  5731. // in the execution context.
  5732. function completeValueCatchingError(exeContext, returnType, fieldNodes, info, path, result) {
  5733. // If the field type is non-nullable, then it is resolved without any
  5734. // protection from errors, however it still properly locates the error.
  5735. if (returnType instanceof _definition.GraphQLNonNull) {
  5736. return completeValueWithLocatedError(exeContext, returnType, fieldNodes, info, path, result);
  5737. }
  5738. // Otherwise, error protection is applied, logging the error and resolving
  5739. // a null value for this field if one is encountered.
  5740. try {
  5741. var completed = completeValueWithLocatedError(exeContext, returnType, fieldNodes, info, path, result);
  5742. if (isThenable(completed)) {
  5743. // If `completeValueWithLocatedError` returned a rejected promise, log
  5744. // the rejection error and resolve to null.
  5745. // Note: we don't rely on a `catch` method, but we do expect "thenable"
  5746. // to take a second callback for the error case.
  5747. return completed.then(undefined, function (error) {
  5748. exeContext.errors.push(error);
  5749. return Promise.resolve(null);
  5750. });
  5751. }
  5752. return completed;
  5753. } catch (error) {
  5754. // If `completeValueWithLocatedError` returned abruptly (threw an error),
  5755. // log the error and return null.
  5756. exeContext.errors.push(error);
  5757. return null;
  5758. }
  5759. }
  5760. // This is a small wrapper around completeValue which annotates errors with
  5761. // location information.
  5762. function completeValueWithLocatedError(exeContext, returnType, fieldNodes, info, path, result) {
  5763. try {
  5764. var completed = completeValue(exeContext, returnType, fieldNodes, info, path, result);
  5765. if (isThenable(completed)) {
  5766. return completed.then(undefined, function (error) {
  5767. return Promise.reject((0, _error.locatedError)(error, fieldNodes, responsePathAsArray(path)));
  5768. });
  5769. }
  5770. return completed;
  5771. } catch (error) {
  5772. throw (0, _error.locatedError)(error, fieldNodes, responsePathAsArray(path));
  5773. }
  5774. }
  5775. /**
  5776. * Implements the instructions for completeValue as defined in the
  5777. * "Field entries" section of the spec.
  5778. *
  5779. * If the field type is Non-Null, then this recursively completes the value
  5780. * for the inner type. It throws a field error if that completion returns null,
  5781. * as per the "Nullability" section of the spec.
  5782. *
  5783. * If the field type is a List, then this recursively completes the value
  5784. * for the inner type on each item in the list.
  5785. *
  5786. * If the field type is a Scalar or Enum, ensures the completed value is a legal
  5787. * value of the type by calling the `serialize` method of GraphQL type
  5788. * definition.
  5789. *
  5790. * If the field is an abstract type, determine the runtime type of the value
  5791. * and then complete based on that type
  5792. *
  5793. * Otherwise, the field type expects a sub-selection set, and will complete the
  5794. * value by evaluating all sub-selections.
  5795. */
  5796. function completeValue(exeContext, returnType, fieldNodes, info, path, result) {
  5797. // If result is a Promise, apply-lift over completeValue.
  5798. if (isThenable(result)) {
  5799. return result.then(function (resolved) {
  5800. return completeValue(exeContext, returnType, fieldNodes, info, path, resolved);
  5801. });
  5802. }
  5803. // If result is an Error, throw a located error.
  5804. if (result instanceof Error) {
  5805. throw result;
  5806. }
  5807. // If field type is NonNull, complete for inner type, and throw field error
  5808. // if result is null.
  5809. if (returnType instanceof _definition.GraphQLNonNull) {
  5810. var completed = completeValue(exeContext, returnType.ofType, fieldNodes, info, path, result);
  5811. if (completed === null) {
  5812. throw new Error('Cannot return null for non-nullable field ' + info.parentType.name + '.' + info.fieldName + '.');
  5813. }
  5814. return completed;
  5815. }
  5816. // If result value is null-ish (null, undefined, or NaN) then return null.
  5817. if ((0, _isNullish2.default)(result)) {
  5818. return null;
  5819. }
  5820. // If field type is List, complete each item in the list with the inner type
  5821. if (returnType instanceof _definition.GraphQLList) {
  5822. return completeListValue(exeContext, returnType, fieldNodes, info, path, result);
  5823. }
  5824. // If field type is a leaf type, Scalar or Enum, serialize to a valid value,
  5825. // returning null if serialization is not possible.
  5826. if (returnType instanceof _definition.GraphQLScalarType || returnType instanceof _definition.GraphQLEnumType) {
  5827. return completeLeafValue(returnType, result);
  5828. }
  5829. // If field type is an abstract type, Interface or Union, determine the
  5830. // runtime Object type and complete for that type.
  5831. if (returnType instanceof _definition.GraphQLInterfaceType || returnType instanceof _definition.GraphQLUnionType) {
  5832. return completeAbstractValue(exeContext, returnType, fieldNodes, info, path, result);
  5833. }
  5834. // If field type is Object, execute and complete all sub-selections.
  5835. if (returnType instanceof _definition.GraphQLObjectType) {
  5836. return completeObjectValue(exeContext, returnType, fieldNodes, info, path, result);
  5837. }
  5838. // Not reachable. All possible output types have been considered.
  5839. throw new Error('Cannot complete value of unexpected type "' + String(returnType) + '".');
  5840. }
  5841. /**
  5842. * Complete a list value by completing each item in the list with the
  5843. * inner type
  5844. */
  5845. function completeListValue(exeContext, returnType, fieldNodes, info, path, result) {
  5846. (0, _invariant2.default)((0, _iterall.isCollection)(result), 'Expected Iterable, but did not find one for field ' + info.parentType.name + '.' + info.fieldName + '.');
  5847. // This is specified as a simple map, however we're optimizing the path
  5848. // where the list contains no Promises by avoiding creating another Promise.
  5849. var itemType = returnType.ofType;
  5850. var containsPromise = false;
  5851. var completedResults = [];
  5852. (0, _iterall.forEach)(result, function (item, index) {
  5853. // No need to modify the info object containing the path,
  5854. // since from here on it is not ever accessed by resolver functions.
  5855. var fieldPath = addPath(path, index);
  5856. var completedItem = completeValueCatchingError(exeContext, itemType, fieldNodes, info, fieldPath, item);
  5857. if (!containsPromise && isThenable(completedItem)) {
  5858. containsPromise = true;
  5859. }
  5860. completedResults.push(completedItem);
  5861. });
  5862. return containsPromise ? Promise.all(completedResults) : completedResults;
  5863. }
  5864. /**
  5865. * Complete a Scalar or Enum by serializing to a valid value, returning
  5866. * null if serialization is not possible.
  5867. */
  5868. function completeLeafValue(returnType, result) {
  5869. (0, _invariant2.default)(returnType.serialize, 'Missing serialize method on type');
  5870. var serializedResult = returnType.serialize(result);
  5871. if ((0, _isNullish2.default)(serializedResult)) {
  5872. throw new Error('Expected a value of type "' + String(returnType) + '" but ' + ('received: ' + String(result)));
  5873. }
  5874. return serializedResult;
  5875. }
  5876. /**
  5877. * Complete a value of an abstract type by determining the runtime object type
  5878. * of that value, then complete the value for that type.
  5879. */
  5880. function completeAbstractValue(exeContext, returnType, fieldNodes, info, path, result) {
  5881. var runtimeType = returnType.resolveType ? returnType.resolveType(result, exeContext.contextValue, info) : defaultResolveTypeFn(result, exeContext.contextValue, info, returnType);
  5882. if (isThenable(runtimeType)) {
  5883. // Cast to Promise
  5884. var runtimeTypePromise = runtimeType;
  5885. return runtimeTypePromise.then(function (resolvedRuntimeType) {
  5886. return completeObjectValue(exeContext, ensureValidRuntimeType(resolvedRuntimeType, exeContext, returnType, fieldNodes, info, result), fieldNodes, info, path, result);
  5887. });
  5888. }
  5889. return completeObjectValue(exeContext, ensureValidRuntimeType(runtimeType, exeContext, returnType, fieldNodes, info, result), fieldNodes, info, path, result);
  5890. }
  5891. function ensureValidRuntimeType(runtimeTypeOrName, exeContext, returnType, fieldNodes, info, result) {
  5892. var runtimeType = typeof runtimeTypeOrName === 'string' ? exeContext.schema.getType(runtimeTypeOrName) : runtimeTypeOrName;
  5893. if (!(runtimeType instanceof _definition.GraphQLObjectType)) {
  5894. throw new _error.GraphQLError('Abstract type ' + returnType.name + ' must resolve to an Object type at ' + ('runtime for field ' + info.parentType.name + '.' + info.fieldName + ' with ') + ('value "' + String(result) + '", received "' + String(runtimeType) + '".'), fieldNodes);
  5895. }
  5896. if (!exeContext.schema.isPossibleType(returnType, runtimeType)) {
  5897. throw new _error.GraphQLError('Runtime Object type "' + runtimeType.name + '" is not a possible type ' + ('for "' + returnType.name + '".'), fieldNodes);
  5898. }
  5899. return runtimeType;
  5900. }
  5901. /**
  5902. * Complete an Object value by executing all sub-selections.
  5903. */
  5904. function completeObjectValue(exeContext, returnType, fieldNodes, info, path, result) {
  5905. // If there is an isTypeOf predicate function, call it with the
  5906. // current result. If isTypeOf returns false, then raise an error rather
  5907. // than continuing execution.
  5908. if (returnType.isTypeOf) {
  5909. var isTypeOf = returnType.isTypeOf(result, exeContext.contextValue, info);
  5910. if (isThenable(isTypeOf)) {
  5911. return isTypeOf.then(function (isTypeOfResult) {
  5912. if (!isTypeOfResult) {
  5913. throw invalidReturnTypeError(returnType, result, fieldNodes);
  5914. }
  5915. return collectAndExecuteSubfields(exeContext, returnType, fieldNodes, info, path, result);
  5916. });
  5917. }
  5918. if (!isTypeOf) {
  5919. throw invalidReturnTypeError(returnType, result, fieldNodes);
  5920. }
  5921. }
  5922. return collectAndExecuteSubfields(exeContext, returnType, fieldNodes, info, path, result);
  5923. }
  5924. function invalidReturnTypeError(returnType, result, fieldNodes) {
  5925. return new _error.GraphQLError('Expected value of type "' + returnType.name + '" but got: ' + String(result) + '.', fieldNodes);
  5926. }
  5927. function collectAndExecuteSubfields(exeContext, returnType, fieldNodes, info, path, result) {
  5928. // Collect sub-fields to execute to complete this value.
  5929. var subFieldNodes = Object.create(null);
  5930. var visitedFragmentNames = Object.create(null);
  5931. for (var i = 0; i < fieldNodes.length; i++) {
  5932. var selectionSet = fieldNodes[i].selectionSet;
  5933. if (selectionSet) {
  5934. subFieldNodes = collectFields(exeContext, returnType, selectionSet, subFieldNodes, visitedFragmentNames);
  5935. }
  5936. }
  5937. return executeFields(exeContext, returnType, result, path, subFieldNodes);
  5938. }
  5939. /**
  5940. * If a resolveType function is not given, then a default resolve behavior is
  5941. * used which tests each possible type for the abstract type by calling
  5942. * isTypeOf for the object being coerced, returning the first type that matches.
  5943. */
  5944. function defaultResolveTypeFn(value, context, info, abstractType) {
  5945. var possibleTypes = info.schema.getPossibleTypes(abstractType);
  5946. var promisedIsTypeOfResults = [];
  5947. for (var i = 0; i < possibleTypes.length; i++) {
  5948. var type = possibleTypes[i];
  5949. if (type.isTypeOf) {
  5950. var isTypeOfResult = type.isTypeOf(value, context, info);
  5951. if (isThenable(isTypeOfResult)) {
  5952. promisedIsTypeOfResults[i] = isTypeOfResult;
  5953. } else if (isTypeOfResult) {
  5954. return type;
  5955. }
  5956. }
  5957. }
  5958. if (promisedIsTypeOfResults.length) {
  5959. return Promise.all(promisedIsTypeOfResults).then(function (isTypeOfResults) {
  5960. for (var _i = 0; _i < isTypeOfResults.length; _i++) {
  5961. if (isTypeOfResults[_i]) {
  5962. return possibleTypes[_i];
  5963. }
  5964. }
  5965. });
  5966. }
  5967. }
  5968. /**
  5969. * If a resolve function is not given, then a default resolve behavior is used
  5970. * which takes the property of the source object of the same name as the field
  5971. * and returns it as the result, or if it's a function, returns the result
  5972. * of calling that function while passing along args and context.
  5973. */
  5974. var defaultFieldResolver = exports.defaultFieldResolver = function defaultFieldResolver(source, args, context, info) {
  5975. // ensure source is a value for which property access is acceptable.
  5976. if (typeof source === 'object' || typeof source === 'function') {
  5977. var property = source[info.fieldName];
  5978. if (typeof property === 'function') {
  5979. return source[info.fieldName](args, context, info);
  5980. }
  5981. return property;
  5982. }
  5983. };
  5984. /**
  5985. * Checks to see if this object acts like a Promise, i.e. has a "then"
  5986. * function.
  5987. */
  5988. function isThenable(value) {
  5989. return typeof value === 'object' && value !== null && typeof value.then === 'function';
  5990. }
  5991. /**
  5992. * This method looks up the field on the given type defintion.
  5993. * It has special casing for the two introspection fields, __schema
  5994. * and __typename. __typename is special because it can always be
  5995. * queried as a field, even in situations where no other fields
  5996. * are allowed, like on a Union. __schema could get automatically
  5997. * added to the query type, but that would require mutating type
  5998. * definitions, which would cause issues.
  5999. */
  6000. function getFieldDef(schema, parentType, fieldName) {
  6001. if (fieldName === _introspection.SchemaMetaFieldDef.name && schema.getQueryType() === parentType) {
  6002. return _introspection.SchemaMetaFieldDef;
  6003. } else if (fieldName === _introspection.TypeMetaFieldDef.name && schema.getQueryType() === parentType) {
  6004. return _introspection.TypeMetaFieldDef;
  6005. } else if (fieldName === _introspection.TypeNameMetaFieldDef.name) {
  6006. return _introspection.TypeNameMetaFieldDef;
  6007. }
  6008. return parentType.getFields()[fieldName];
  6009. }
  6010. /***/ }),
  6011. /* 31 */
  6012. /***/ (function(module, exports, __webpack_require__) {
  6013. "use strict";
  6014. Object.defineProperty(exports, "__esModule", {
  6015. value: true
  6016. });
  6017. exports.getVariableValues = getVariableValues;
  6018. exports.getArgumentValues = getArgumentValues;
  6019. var _iterall = __webpack_require__(20);
  6020. var _error = __webpack_require__(0);
  6021. var _invariant = __webpack_require__(3);
  6022. var _invariant2 = _interopRequireDefault(_invariant);
  6023. var _isNullish = __webpack_require__(6);
  6024. var _isNullish2 = _interopRequireDefault(_isNullish);
  6025. var _isInvalid = __webpack_require__(14);
  6026. var _isInvalid2 = _interopRequireDefault(_isInvalid);
  6027. var _keyMap = __webpack_require__(12);
  6028. var _keyMap2 = _interopRequireDefault(_keyMap);
  6029. var _typeFromAST = __webpack_require__(9);
  6030. var _valueFromAST = __webpack_require__(16);
  6031. var _isValidJSValue = __webpack_require__(33);
  6032. var _isValidLiteralValue = __webpack_require__(18);
  6033. var _kinds = __webpack_require__(2);
  6034. var Kind = _interopRequireWildcard(_kinds);
  6035. var _printer = __webpack_require__(4);
  6036. var _definition = __webpack_require__(1);
  6037. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  6038. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6039. /**
  6040. * Prepares an object map of variableValues of the correct type based on the
  6041. * provided variable definitions and arbitrary input. If the input cannot be
  6042. * parsed to match the variable definitions, a GraphQLError will be thrown.
  6043. */
  6044. function getVariableValues(schema, varDefNodes, inputs) {
  6045. var coercedValues = Object.create(null);
  6046. for (var i = 0; i < varDefNodes.length; i++) {
  6047. var varDefNode = varDefNodes[i];
  6048. var varName = varDefNode.variable.name.value;
  6049. var varType = (0, _typeFromAST.typeFromAST)(schema, varDefNode.type);
  6050. if (!(0, _definition.isInputType)(varType)) {
  6051. throw new _error.GraphQLError('Variable "$' + varName + '" expected value of type ' + ('"' + (0, _printer.print)(varDefNode.type) + '" which cannot be used as an input type.'), [varDefNode.type]);
  6052. }
  6053. varType = varType;
  6054. var value = inputs[varName];
  6055. if ((0, _isInvalid2.default)(value)) {
  6056. var defaultValue = varDefNode.defaultValue;
  6057. if (defaultValue) {
  6058. coercedValues[varName] = (0, _valueFromAST.valueFromAST)(defaultValue, varType);
  6059. }
  6060. if (varType instanceof _definition.GraphQLNonNull) {
  6061. throw new _error.GraphQLError('Variable "$' + varName + '" of required type ' + ('"' + String(varType) + '" was not provided.'), [varDefNode]);
  6062. }
  6063. } else {
  6064. var errors = (0, _isValidJSValue.isValidJSValue)(value, varType);
  6065. if (errors.length) {
  6066. var message = errors ? '\n' + errors.join('\n') : '';
  6067. throw new _error.GraphQLError('Variable "$' + varName + '" got invalid value ' + (JSON.stringify(value) + '.' + message), [varDefNode]);
  6068. }
  6069. var coercedValue = coerceValue(varType, value);
  6070. (0, _invariant2.default)(!(0, _isInvalid2.default)(coercedValue), 'Should have reported error.');
  6071. coercedValues[varName] = coercedValue;
  6072. }
  6073. }
  6074. return coercedValues;
  6075. }
  6076. /**
  6077. * Prepares an object map of argument values given a list of argument
  6078. * definitions and list of argument AST nodes.
  6079. */
  6080. /**
  6081. * Copyright (c) 2015, Facebook, Inc.
  6082. * All rights reserved.
  6083. *
  6084. * This source code is licensed under the BSD-style license found in the
  6085. * LICENSE file in the root directory of this source tree. An additional grant
  6086. * of patent rights can be found in the PATENTS file in the same directory.
  6087. */
  6088. function getArgumentValues(def, node, variableValues) {
  6089. var argDefs = def.args;
  6090. var argNodes = node.arguments;
  6091. if (!argDefs || !argNodes) {
  6092. return {};
  6093. }
  6094. var coercedValues = Object.create(null);
  6095. var argNodeMap = (0, _keyMap2.default)(argNodes, function (arg) {
  6096. return arg.name.value;
  6097. });
  6098. for (var i = 0; i < argDefs.length; i++) {
  6099. var argDef = argDefs[i];
  6100. var name = argDef.name;
  6101. var argType = argDef.type;
  6102. var argumentNode = argNodeMap[name];
  6103. var defaultValue = argDef.defaultValue;
  6104. if (!argumentNode) {
  6105. if (!(0, _isInvalid2.default)(defaultValue)) {
  6106. coercedValues[name] = defaultValue;
  6107. } else if (argType instanceof _definition.GraphQLNonNull) {
  6108. throw new _error.GraphQLError('Argument "' + name + '" of required type ' + ('"' + String(argType) + '" was not provided.'), [node]);
  6109. }
  6110. } else if (argumentNode.value.kind === Kind.VARIABLE) {
  6111. var variableName = argumentNode.value.name.value;
  6112. if (variableValues && !(0, _isInvalid2.default)(variableValues[variableName])) {
  6113. // Note: this does not check that this variable value is correct.
  6114. // This assumes that this query has been validated and the variable
  6115. // usage here is of the correct type.
  6116. coercedValues[name] = variableValues[variableName];
  6117. } else if (!(0, _isInvalid2.default)(defaultValue)) {
  6118. coercedValues[name] = defaultValue;
  6119. } else if (argType instanceof _definition.GraphQLNonNull) {
  6120. throw new _error.GraphQLError('Argument "' + name + '" of required type "' + String(argType) + '" was ' + ('provided the variable "$' + variableName + '" which was not provided ') + 'a runtime value.', [argumentNode.value]);
  6121. }
  6122. } else {
  6123. var valueNode = argumentNode.value;
  6124. var coercedValue = (0, _valueFromAST.valueFromAST)(valueNode, argType, variableValues);
  6125. if ((0, _isInvalid2.default)(coercedValue)) {
  6126. var errors = (0, _isValidLiteralValue.isValidLiteralValue)(argType, valueNode);
  6127. var message = errors ? '\n' + errors.join('\n') : '';
  6128. throw new _error.GraphQLError('Argument "' + name + '" got invalid value ' + (0, _printer.print)(valueNode) + '.' + message, [argumentNode.value]);
  6129. }
  6130. coercedValues[name] = coercedValue;
  6131. }
  6132. }
  6133. return coercedValues;
  6134. }
  6135. /**
  6136. * Given a type and any value, return a runtime value coerced to match the type.
  6137. */
  6138. function coerceValue(type, value) {
  6139. // Ensure flow knows that we treat function params as const.
  6140. var _value = value;
  6141. if ((0, _isInvalid2.default)(_value)) {
  6142. return; // Intentionally return no value.
  6143. }
  6144. if (type instanceof _definition.GraphQLNonNull) {
  6145. if (_value === null) {
  6146. return; // Intentionally return no value.
  6147. }
  6148. return coerceValue(type.ofType, _value);
  6149. }
  6150. if (_value === null) {
  6151. // Intentionally return the value null.
  6152. return null;
  6153. }
  6154. if (type instanceof _definition.GraphQLList) {
  6155. var itemType = type.ofType;
  6156. if ((0, _iterall.isCollection)(_value)) {
  6157. var coercedValues = [];
  6158. var valueIter = (0, _iterall.createIterator)(_value);
  6159. if (!valueIter) {
  6160. return; // Intentionally return no value.
  6161. }
  6162. var step = void 0;
  6163. while (!(step = valueIter.next()).done) {
  6164. var itemValue = coerceValue(itemType, step.value);
  6165. if ((0, _isInvalid2.default)(itemValue)) {
  6166. return; // Intentionally return no value.
  6167. }
  6168. coercedValues.push(itemValue);
  6169. }
  6170. return coercedValues;
  6171. }
  6172. var coercedValue = coerceValue(itemType, _value);
  6173. if ((0, _isInvalid2.default)(coercedValue)) {
  6174. return; // Intentionally return no value.
  6175. }
  6176. return [coerceValue(itemType, _value)];
  6177. }
  6178. if (type instanceof _definition.GraphQLInputObjectType) {
  6179. if (typeof _value !== 'object') {
  6180. return; // Intentionally return no value.
  6181. }
  6182. var coercedObj = Object.create(null);
  6183. var fields = type.getFields();
  6184. var fieldNames = Object.keys(fields);
  6185. for (var i = 0; i < fieldNames.length; i++) {
  6186. var fieldName = fieldNames[i];
  6187. var field = fields[fieldName];
  6188. if ((0, _isInvalid2.default)(_value[fieldName])) {
  6189. if (!(0, _isInvalid2.default)(field.defaultValue)) {
  6190. coercedObj[fieldName] = field.defaultValue;
  6191. } else if (field.type instanceof _definition.GraphQLNonNull) {
  6192. return; // Intentionally return no value.
  6193. }
  6194. continue;
  6195. }
  6196. var fieldValue = coerceValue(field.type, _value[fieldName]);
  6197. if ((0, _isInvalid2.default)(fieldValue)) {
  6198. return; // Intentionally return no value.
  6199. }
  6200. coercedObj[fieldName] = fieldValue;
  6201. }
  6202. return coercedObj;
  6203. }
  6204. (0, _invariant2.default)(type instanceof _definition.GraphQLScalarType || type instanceof _definition.GraphQLEnumType, 'Must be input type');
  6205. var parsed = type.parseValue(_value);
  6206. if ((0, _isNullish2.default)(parsed)) {
  6207. // null or invalid values represent a failure to parse correctly,
  6208. // in which case no value is returned.
  6209. return;
  6210. }
  6211. return parsed;
  6212. }
  6213. /***/ }),
  6214. /* 32 */
  6215. /***/ (function(module, exports, __webpack_require__) {
  6216. "use strict";
  6217. Object.defineProperty(exports, "__esModule", {
  6218. value: true
  6219. });
  6220. exports.buildASTSchema = buildASTSchema;
  6221. exports.getDescription = getDescription;
  6222. exports.buildSchema = buildSchema;
  6223. var _find = __webpack_require__(10);
  6224. var _find2 = _interopRequireDefault(_find);
  6225. var _invariant = __webpack_require__(3);
  6226. var _invariant2 = _interopRequireDefault(_invariant);
  6227. var _keyValMap = __webpack_require__(21);
  6228. var _keyValMap2 = _interopRequireDefault(_keyValMap);
  6229. var _valueFromAST = __webpack_require__(16);
  6230. var _lexer = __webpack_require__(24);
  6231. var _parser = __webpack_require__(17);
  6232. var _values = __webpack_require__(31);
  6233. var _kinds = __webpack_require__(2);
  6234. var _schema = __webpack_require__(8);
  6235. var _scalars = __webpack_require__(7);
  6236. var _definition = __webpack_require__(1);
  6237. var _directives = __webpack_require__(5);
  6238. var _introspection = __webpack_require__(11);
  6239. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6240. function buildWrappedType(innerType, inputTypeNode) {
  6241. if (inputTypeNode.kind === _kinds.LIST_TYPE) {
  6242. return new _definition.GraphQLList(buildWrappedType(innerType, inputTypeNode.type));
  6243. }
  6244. if (inputTypeNode.kind === _kinds.NON_NULL_TYPE) {
  6245. var wrappedType = buildWrappedType(innerType, inputTypeNode.type);
  6246. (0, _invariant2.default)(!(wrappedType instanceof _definition.GraphQLNonNull), 'No nesting nonnull.');
  6247. return new _definition.GraphQLNonNull(wrappedType);
  6248. }
  6249. return innerType;
  6250. }
  6251. /**
  6252. * Copyright (c) 2015, Facebook, Inc.
  6253. * All rights reserved.
  6254. *
  6255. * This source code is licensed under the BSD-style license found in the
  6256. * LICENSE file in the root directory of this source tree. An additional grant
  6257. * of patent rights can be found in the PATENTS file in the same directory.
  6258. */
  6259. function getNamedTypeNode(typeNode) {
  6260. var namedType = typeNode;
  6261. while (namedType.kind === _kinds.LIST_TYPE || namedType.kind === _kinds.NON_NULL_TYPE) {
  6262. namedType = namedType.type;
  6263. }
  6264. return namedType;
  6265. }
  6266. /**
  6267. * This takes the ast of a schema document produced by the parse function in
  6268. * src/language/parser.js.
  6269. *
  6270. * If no schema definition is provided, then it will look for types named Query
  6271. * and Mutation.
  6272. *
  6273. * Given that AST it constructs a GraphQLSchema. The resulting schema
  6274. * has no resolve methods, so execution will use default resolvers.
  6275. */
  6276. function buildASTSchema(ast) {
  6277. if (!ast || ast.kind !== _kinds.DOCUMENT) {
  6278. throw new Error('Must provide a document ast.');
  6279. }
  6280. var schemaDef = void 0;
  6281. var typeDefs = [];
  6282. var nodeMap = Object.create(null);
  6283. var directiveDefs = [];
  6284. for (var i = 0; i < ast.definitions.length; i++) {
  6285. var d = ast.definitions[i];
  6286. switch (d.kind) {
  6287. case _kinds.SCHEMA_DEFINITION:
  6288. if (schemaDef) {
  6289. throw new Error('Must provide only one schema definition.');
  6290. }
  6291. schemaDef = d;
  6292. break;
  6293. case _kinds.SCALAR_TYPE_DEFINITION:
  6294. case _kinds.OBJECT_TYPE_DEFINITION:
  6295. case _kinds.INTERFACE_TYPE_DEFINITION:
  6296. case _kinds.ENUM_TYPE_DEFINITION:
  6297. case _kinds.UNION_TYPE_DEFINITION:
  6298. case _kinds.INPUT_OBJECT_TYPE_DEFINITION:
  6299. typeDefs.push(d);
  6300. nodeMap[d.name.value] = d;
  6301. break;
  6302. case _kinds.DIRECTIVE_DEFINITION:
  6303. directiveDefs.push(d);
  6304. break;
  6305. }
  6306. }
  6307. var queryTypeName = void 0;
  6308. var mutationTypeName = void 0;
  6309. var subscriptionTypeName = void 0;
  6310. if (schemaDef) {
  6311. schemaDef.operationTypes.forEach(function (operationType) {
  6312. var typeName = operationType.type.name.value;
  6313. if (operationType.operation === 'query') {
  6314. if (queryTypeName) {
  6315. throw new Error('Must provide only one query type in schema.');
  6316. }
  6317. if (!nodeMap[typeName]) {
  6318. throw new Error('Specified query type "' + typeName + '" not found in document.');
  6319. }
  6320. queryTypeName = typeName;
  6321. } else if (operationType.operation === 'mutation') {
  6322. if (mutationTypeName) {
  6323. throw new Error('Must provide only one mutation type in schema.');
  6324. }
  6325. if (!nodeMap[typeName]) {
  6326. throw new Error('Specified mutation type "' + typeName + '" not found in document.');
  6327. }
  6328. mutationTypeName = typeName;
  6329. } else if (operationType.operation === 'subscription') {
  6330. if (subscriptionTypeName) {
  6331. throw new Error('Must provide only one subscription type in schema.');
  6332. }
  6333. if (!nodeMap[typeName]) {
  6334. throw new Error('Specified subscription type "' + typeName + '" not found in document.');
  6335. }
  6336. subscriptionTypeName = typeName;
  6337. }
  6338. });
  6339. } else {
  6340. if (nodeMap.Query) {
  6341. queryTypeName = 'Query';
  6342. }
  6343. if (nodeMap.Mutation) {
  6344. mutationTypeName = 'Mutation';
  6345. }
  6346. if (nodeMap.Subscription) {
  6347. subscriptionTypeName = 'Subscription';
  6348. }
  6349. }
  6350. if (!queryTypeName) {
  6351. throw new Error('Must provide schema definition with query type or a type named Query.');
  6352. }
  6353. var innerTypeMap = {
  6354. String: _scalars.GraphQLString,
  6355. Int: _scalars.GraphQLInt,
  6356. Float: _scalars.GraphQLFloat,
  6357. Boolean: _scalars.GraphQLBoolean,
  6358. ID: _scalars.GraphQLID,
  6359. __Schema: _introspection.__Schema,
  6360. __Directive: _introspection.__Directive,
  6361. __DirectiveLocation: _introspection.__DirectiveLocation,
  6362. __Type: _introspection.__Type,
  6363. __Field: _introspection.__Field,
  6364. __InputValue: _introspection.__InputValue,
  6365. __EnumValue: _introspection.__EnumValue,
  6366. __TypeKind: _introspection.__TypeKind
  6367. };
  6368. var types = typeDefs.map(function (def) {
  6369. return typeDefNamed(def.name.value);
  6370. });
  6371. var directives = directiveDefs.map(getDirective);
  6372. // If specified directives were not explicitly declared, add them.
  6373. if (!directives.some(function (directive) {
  6374. return directive.name === 'skip';
  6375. })) {
  6376. directives.push(_directives.GraphQLSkipDirective);
  6377. }
  6378. if (!directives.some(function (directive) {
  6379. return directive.name === 'include';
  6380. })) {
  6381. directives.push(_directives.GraphQLIncludeDirective);
  6382. }
  6383. if (!directives.some(function (directive) {
  6384. return directive.name === 'deprecated';
  6385. })) {
  6386. directives.push(_directives.GraphQLDeprecatedDirective);
  6387. }
  6388. return new _schema.GraphQLSchema({
  6389. query: getObjectType(nodeMap[queryTypeName]),
  6390. mutation: mutationTypeName ? getObjectType(nodeMap[mutationTypeName]) : null,
  6391. subscription: subscriptionTypeName ? getObjectType(nodeMap[subscriptionTypeName]) : null,
  6392. types: types,
  6393. directives: directives
  6394. });
  6395. function getDirective(directiveNode) {
  6396. return new _directives.GraphQLDirective({
  6397. name: directiveNode.name.value,
  6398. description: getDescription(directiveNode),
  6399. locations: directiveNode.locations.map(function (node) {
  6400. return node.value;
  6401. }),
  6402. args: directiveNode.arguments && makeInputValues(directiveNode.arguments)
  6403. });
  6404. }
  6405. function getObjectType(typeNode) {
  6406. var type = typeDefNamed(typeNode.name.value);
  6407. (0, _invariant2.default)(type instanceof _definition.GraphQLObjectType, 'AST must provide object type.');
  6408. return type;
  6409. }
  6410. function produceType(typeNode) {
  6411. var typeName = getNamedTypeNode(typeNode).name.value;
  6412. var typeDef = typeDefNamed(typeName);
  6413. return buildWrappedType(typeDef, typeNode);
  6414. }
  6415. function produceInputType(typeNode) {
  6416. var type = produceType(typeNode);
  6417. (0, _invariant2.default)((0, _definition.isInputType)(type), 'Expected Input type.');
  6418. return type;
  6419. }
  6420. function produceOutputType(typeNode) {
  6421. var type = produceType(typeNode);
  6422. (0, _invariant2.default)((0, _definition.isOutputType)(type), 'Expected Output type.');
  6423. return type;
  6424. }
  6425. function produceObjectType(typeNode) {
  6426. var type = produceType(typeNode);
  6427. (0, _invariant2.default)(type instanceof _definition.GraphQLObjectType, 'Expected Object type.');
  6428. return type;
  6429. }
  6430. function produceInterfaceType(typeNode) {
  6431. var type = produceType(typeNode);
  6432. (0, _invariant2.default)(type instanceof _definition.GraphQLInterfaceType, 'Expected Interface type.');
  6433. return type;
  6434. }
  6435. function typeDefNamed(typeName) {
  6436. if (innerTypeMap[typeName]) {
  6437. return innerTypeMap[typeName];
  6438. }
  6439. if (!nodeMap[typeName]) {
  6440. throw new Error('Type "' + typeName + '" not found in document.');
  6441. }
  6442. var innerTypeDef = makeSchemaDef(nodeMap[typeName]);
  6443. if (!innerTypeDef) {
  6444. throw new Error('Nothing constructed for "' + typeName + '".');
  6445. }
  6446. innerTypeMap[typeName] = innerTypeDef;
  6447. return innerTypeDef;
  6448. }
  6449. function makeSchemaDef(def) {
  6450. if (!def) {
  6451. throw new Error('def must be defined');
  6452. }
  6453. switch (def.kind) {
  6454. case _kinds.OBJECT_TYPE_DEFINITION:
  6455. return makeTypeDef(def);
  6456. case _kinds.INTERFACE_TYPE_DEFINITION:
  6457. return makeInterfaceDef(def);
  6458. case _kinds.ENUM_TYPE_DEFINITION:
  6459. return makeEnumDef(def);
  6460. case _kinds.UNION_TYPE_DEFINITION:
  6461. return makeUnionDef(def);
  6462. case _kinds.SCALAR_TYPE_DEFINITION:
  6463. return makeScalarDef(def);
  6464. case _kinds.INPUT_OBJECT_TYPE_DEFINITION:
  6465. return makeInputObjectDef(def);
  6466. default:
  6467. throw new Error('Type kind "' + def.kind + '" not supported.');
  6468. }
  6469. }
  6470. function makeTypeDef(def) {
  6471. var typeName = def.name.value;
  6472. return new _definition.GraphQLObjectType({
  6473. name: typeName,
  6474. description: getDescription(def),
  6475. fields: function fields() {
  6476. return makeFieldDefMap(def);
  6477. },
  6478. interfaces: function interfaces() {
  6479. return makeImplementedInterfaces(def);
  6480. }
  6481. });
  6482. }
  6483. function makeFieldDefMap(def) {
  6484. return (0, _keyValMap2.default)(def.fields, function (field) {
  6485. return field.name.value;
  6486. }, function (field) {
  6487. return {
  6488. type: produceOutputType(field.type),
  6489. description: getDescription(field),
  6490. args: makeInputValues(field.arguments),
  6491. deprecationReason: getDeprecationReason(field.directives)
  6492. };
  6493. });
  6494. }
  6495. function makeImplementedInterfaces(def) {
  6496. return def.interfaces && def.interfaces.map(function (iface) {
  6497. return produceInterfaceType(iface);
  6498. });
  6499. }
  6500. function makeInputValues(values) {
  6501. return (0, _keyValMap2.default)(values, function (value) {
  6502. return value.name.value;
  6503. }, function (value) {
  6504. var type = produceInputType(value.type);
  6505. return {
  6506. type: type,
  6507. description: getDescription(value),
  6508. defaultValue: (0, _valueFromAST.valueFromAST)(value.defaultValue, type)
  6509. };
  6510. });
  6511. }
  6512. function makeInterfaceDef(def) {
  6513. var typeName = def.name.value;
  6514. return new _definition.GraphQLInterfaceType({
  6515. name: typeName,
  6516. description: getDescription(def),
  6517. fields: function fields() {
  6518. return makeFieldDefMap(def);
  6519. },
  6520. resolveType: cannotExecuteSchema
  6521. });
  6522. }
  6523. function makeEnumDef(def) {
  6524. var enumType = new _definition.GraphQLEnumType({
  6525. name: def.name.value,
  6526. description: getDescription(def),
  6527. values: (0, _keyValMap2.default)(def.values, function (enumValue) {
  6528. return enumValue.name.value;
  6529. }, function (enumValue) {
  6530. return {
  6531. description: getDescription(enumValue),
  6532. deprecationReason: getDeprecationReason(enumValue.directives)
  6533. };
  6534. })
  6535. });
  6536. return enumType;
  6537. }
  6538. function makeUnionDef(def) {
  6539. return new _definition.GraphQLUnionType({
  6540. name: def.name.value,
  6541. description: getDescription(def),
  6542. types: def.types.map(function (t) {
  6543. return produceObjectType(t);
  6544. }),
  6545. resolveType: cannotExecuteSchema
  6546. });
  6547. }
  6548. function makeScalarDef(def) {
  6549. return new _definition.GraphQLScalarType({
  6550. name: def.name.value,
  6551. description: getDescription(def),
  6552. serialize: function serialize() {
  6553. return null;
  6554. },
  6555. // Note: validation calls the parse functions to determine if a
  6556. // literal value is correct. Returning null would cause use of custom
  6557. // scalars to always fail validation. Returning false causes them to
  6558. // always pass validation.
  6559. parseValue: function parseValue() {
  6560. return false;
  6561. },
  6562. parseLiteral: function parseLiteral() {
  6563. return false;
  6564. }
  6565. });
  6566. }
  6567. function makeInputObjectDef(def) {
  6568. return new _definition.GraphQLInputObjectType({
  6569. name: def.name.value,
  6570. description: getDescription(def),
  6571. fields: function fields() {
  6572. return makeInputValues(def.fields);
  6573. }
  6574. });
  6575. }
  6576. }
  6577. function getDeprecationReason(directives) {
  6578. var deprecatedAST = directives && (0, _find2.default)(directives, function (directive) {
  6579. return directive.name.value === _directives.GraphQLDeprecatedDirective.name;
  6580. });
  6581. if (!deprecatedAST) {
  6582. return;
  6583. }
  6584. var _getArgumentValues = (0, _values.getArgumentValues)(_directives.GraphQLDeprecatedDirective, deprecatedAST),
  6585. reason = _getArgumentValues.reason;
  6586. return reason;
  6587. }
  6588. /**
  6589. * Given an ast node, returns its string description based on a contiguous
  6590. * block full-line of comments preceding it.
  6591. */
  6592. function getDescription(node) {
  6593. var loc = node.loc;
  6594. if (!loc) {
  6595. return;
  6596. }
  6597. var comments = [];
  6598. var minSpaces = void 0;
  6599. var token = loc.startToken.prev;
  6600. while (token && token.kind === _lexer.TokenKind.COMMENT && token.next && token.prev && token.line + 1 === token.next.line && token.line !== token.prev.line) {
  6601. var value = String(token.value);
  6602. var spaces = leadingSpaces(value);
  6603. if (minSpaces === undefined || spaces < minSpaces) {
  6604. minSpaces = spaces;
  6605. }
  6606. comments.push(value);
  6607. token = token.prev;
  6608. }
  6609. return comments.reverse().map(function (comment) {
  6610. return comment.slice(minSpaces);
  6611. }).join('\n');
  6612. }
  6613. /**
  6614. * A helper function to build a GraphQLSchema directly from a source
  6615. * document.
  6616. */
  6617. function buildSchema(source) {
  6618. return buildASTSchema((0, _parser.parse)(source));
  6619. }
  6620. // Count the number of spaces on the starting side of a string.
  6621. function leadingSpaces(str) {
  6622. var i = 0;
  6623. for (; i < str.length; i++) {
  6624. if (str[i] !== ' ') {
  6625. break;
  6626. }
  6627. }
  6628. return i;
  6629. }
  6630. function cannotExecuteSchema() {
  6631. throw new Error('Generated Schema cannot use Interface or Union types for execution.');
  6632. }
  6633. /***/ }),
  6634. /* 33 */
  6635. /***/ (function(module, exports, __webpack_require__) {
  6636. "use strict";
  6637. Object.defineProperty(exports, "__esModule", {
  6638. value: true
  6639. });
  6640. exports.isValidJSValue = isValidJSValue;
  6641. var _iterall = __webpack_require__(20);
  6642. var _invariant = __webpack_require__(3);
  6643. var _invariant2 = _interopRequireDefault(_invariant);
  6644. var _isNullish = __webpack_require__(6);
  6645. var _isNullish2 = _interopRequireDefault(_isNullish);
  6646. var _definition = __webpack_require__(1);
  6647. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6648. /**
  6649. * Given a JavaScript value and a GraphQL type, determine if the value will be
  6650. * accepted for that type. This is primarily useful for validating the
  6651. * runtime values of query variables.
  6652. */
  6653. /**
  6654. * Copyright (c) 2015, Facebook, Inc.
  6655. * All rights reserved.
  6656. *
  6657. * This source code is licensed under the BSD-style license found in the
  6658. * LICENSE file in the root directory of this source tree. An additional grant
  6659. * of patent rights can be found in the PATENTS file in the same directory.
  6660. */
  6661. function isValidJSValue(value, type) {
  6662. // A value must be provided if the type is non-null.
  6663. if (type instanceof _definition.GraphQLNonNull) {
  6664. if ((0, _isNullish2.default)(value)) {
  6665. return ['Expected "' + String(type) + '", found null.'];
  6666. }
  6667. return isValidJSValue(value, type.ofType);
  6668. }
  6669. if ((0, _isNullish2.default)(value)) {
  6670. return [];
  6671. }
  6672. // Lists accept a non-list value as a list of one.
  6673. if (type instanceof _definition.GraphQLList) {
  6674. var _ret = function () {
  6675. var itemType = type.ofType;
  6676. if ((0, _iterall.isCollection)(value)) {
  6677. var _ret2 = function () {
  6678. var errors = [];
  6679. (0, _iterall.forEach)(value, function (item, index) {
  6680. errors.push.apply(errors, isValidJSValue(item, itemType).map(function (error) {
  6681. return 'In element #' + index + ': ' + error;
  6682. }));
  6683. });
  6684. return {
  6685. v: {
  6686. v: errors
  6687. }
  6688. };
  6689. }();
  6690. if (typeof _ret2 === "object") return _ret2.v;
  6691. }
  6692. return {
  6693. v: isValidJSValue(value, itemType)
  6694. };
  6695. }();
  6696. if (typeof _ret === "object") return _ret.v;
  6697. }
  6698. // Input objects check each defined field.
  6699. if (type instanceof _definition.GraphQLInputObjectType) {
  6700. var _ret3 = function () {
  6701. if (typeof value !== 'object' || value === null) {
  6702. return {
  6703. v: ['Expected "' + type.name + '", found not an object.']
  6704. };
  6705. }
  6706. var fields = type.getFields();
  6707. var errors = [];
  6708. // Ensure every provided field is defined.
  6709. Object.keys(value).forEach(function (providedField) {
  6710. if (!fields[providedField]) {
  6711. errors.push('In field "' + providedField + '": Unknown field.');
  6712. }
  6713. });
  6714. // Ensure every defined field is valid.
  6715. Object.keys(fields).forEach(function (fieldName) {
  6716. var newErrors = isValidJSValue(value[fieldName], fields[fieldName].type);
  6717. errors.push.apply(errors, newErrors.map(function (error) {
  6718. return 'In field "' + fieldName + '": ' + error;
  6719. }));
  6720. });
  6721. return {
  6722. v: errors
  6723. };
  6724. }();
  6725. if (typeof _ret3 === "object") return _ret3.v;
  6726. }
  6727. (0, _invariant2.default)(type instanceof _definition.GraphQLScalarType || type instanceof _definition.GraphQLEnumType, 'Must be input type');
  6728. // Scalar/Enum input checks to ensure the type can parse the value to
  6729. // a non-null value.
  6730. try {
  6731. var parseResult = type.parseValue(value);
  6732. if ((0, _isNullish2.default)(parseResult)) {
  6733. return ['Expected type "' + type.name + '", found ' + JSON.stringify(value) + '.'];
  6734. }
  6735. } catch (error) {
  6736. return ['Expected type "' + type.name + '", found ' + JSON.stringify(value) + ': ' + error.message];
  6737. }
  6738. return [];
  6739. }
  6740. /***/ }),
  6741. /* 34 */
  6742. /***/ (function(module, exports, __webpack_require__) {
  6743. "use strict";
  6744. Object.defineProperty(exports, "__esModule", {
  6745. value: true
  6746. });
  6747. exports.specifiedRules = undefined;
  6748. var _UniqueOperationNames = __webpack_require__(77);
  6749. var _LoneAnonymousOperation = __webpack_require__(64);
  6750. var _KnownTypeNames = __webpack_require__(63);
  6751. var _FragmentsOnCompositeTypes = __webpack_require__(59);
  6752. var _VariablesAreInputTypes = __webpack_require__(79);
  6753. var _ScalarLeafs = __webpack_require__(72);
  6754. var _FieldsOnCorrectType = __webpack_require__(58);
  6755. var _UniqueFragmentNames = __webpack_require__(75);
  6756. var _KnownFragmentNames = __webpack_require__(62);
  6757. var _NoUnusedFragments = __webpack_require__(67);
  6758. var _PossibleFragmentSpreads = __webpack_require__(70);
  6759. var _NoFragmentCycles = __webpack_require__(65);
  6760. var _UniqueVariableNames = __webpack_require__(78);
  6761. var _NoUndefinedVariables = __webpack_require__(66);
  6762. var _NoUnusedVariables = __webpack_require__(68);
  6763. var _KnownDirectives = __webpack_require__(61);
  6764. var _UniqueDirectivesPerLocation = __webpack_require__(74);
  6765. var _KnownArgumentNames = __webpack_require__(60);
  6766. var _UniqueArgumentNames = __webpack_require__(73);
  6767. var _ArgumentsOfCorrectType = __webpack_require__(56);
  6768. var _ProvidedNonNullArguments = __webpack_require__(71);
  6769. var _DefaultValuesOfCorrectType = __webpack_require__(57);
  6770. var _VariablesInAllowedPosition = __webpack_require__(80);
  6771. var _OverlappingFieldsCanBeMerged = __webpack_require__(69);
  6772. var _UniqueInputFieldNames = __webpack_require__(76);
  6773. /**
  6774. * This set includes all validation rules defined by the GraphQL spec.
  6775. */
  6776. // Spec Section: "Field Selection Merging"
  6777. // Spec Section: "Variable Default Values Are Correctly Typed"
  6778. // Spec Section: "Argument Values Type Correctness"
  6779. // Spec Section: "Argument Names"
  6780. // Spec Section: "Directives Are Defined"
  6781. // Spec Section: "All Variable Used Defined"
  6782. // Spec Section: "Fragments must not form cycles"
  6783. // Spec Section: "Fragments must be used"
  6784. // Spec Section: "Fragment Name Uniqueness"
  6785. // Spec Section: "Leaf Field Selections"
  6786. // Spec Section: "Fragments on Composite Types"
  6787. // Spec Section: "Lone Anonymous Operation"
  6788. var specifiedRules = exports.specifiedRules = [_UniqueOperationNames.UniqueOperationNames, _LoneAnonymousOperation.LoneAnonymousOperation, _KnownTypeNames.KnownTypeNames, _FragmentsOnCompositeTypes.FragmentsOnCompositeTypes, _VariablesAreInputTypes.VariablesAreInputTypes, _ScalarLeafs.ScalarLeafs, _FieldsOnCorrectType.FieldsOnCorrectType, _UniqueFragmentNames.UniqueFragmentNames, _KnownFragmentNames.KnownFragmentNames, _NoUnusedFragments.NoUnusedFragments, _PossibleFragmentSpreads.PossibleFragmentSpreads, _NoFragmentCycles.NoFragmentCycles, _UniqueVariableNames.UniqueVariableNames, _NoUndefinedVariables.NoUndefinedVariables, _NoUnusedVariables.NoUnusedVariables, _KnownDirectives.KnownDirectives, _UniqueDirectivesPerLocation.UniqueDirectivesPerLocation, _KnownArgumentNames.KnownArgumentNames, _UniqueArgumentNames.UniqueArgumentNames, _ArgumentsOfCorrectType.ArgumentsOfCorrectType, _ProvidedNonNullArguments.ProvidedNonNullArguments, _DefaultValuesOfCorrectType.DefaultValuesOfCorrectType, _VariablesInAllowedPosition.VariablesInAllowedPosition, _OverlappingFieldsCanBeMerged.OverlappingFieldsCanBeMerged, _UniqueInputFieldNames.UniqueInputFieldNames];
  6789. // Spec Section: "Input Object Field Uniqueness"
  6790. // Spec Section: "All Variable Usages Are Allowed"
  6791. // Spec Section: "Argument Optionality"
  6792. // Spec Section: "Argument Uniqueness"
  6793. // Spec Section: "Directives Are Unique Per Location"
  6794. // Spec Section: "All Variables Used"
  6795. // Spec Section: "Variable Uniqueness"
  6796. // Spec Section: "Fragment spread is possible"
  6797. // Spec Section: "Fragment spread target defined"
  6798. // Spec Section: "Field Selections on Objects, Interfaces, and Unions Types"
  6799. // Spec Section: "Variables are Input Types"
  6800. // Spec Section: "Fragment Spread Type Existence"
  6801. /**
  6802. * Copyright (c) 2015, Facebook, Inc.
  6803. * All rights reserved.
  6804. *
  6805. * This source code is licensed under the BSD-style license found in the
  6806. * LICENSE file in the root directory of this source tree. An additional grant
  6807. * of patent rights can be found in the PATENTS file in the same directory.
  6808. */
  6809. // Spec Section: "Operation Name Uniqueness"
  6810. /***/ }),
  6811. /* 35 */
  6812. /***/ (function(module, exports, __webpack_require__) {
  6813. "use strict";
  6814. Object.defineProperty(exports, "__esModule", {
  6815. value: true
  6816. });
  6817. exports.ValidationContext = undefined;
  6818. exports.validate = validate;
  6819. exports.visitUsingRules = visitUsingRules;
  6820. var _invariant = __webpack_require__(3);
  6821. var _invariant2 = _interopRequireDefault(_invariant);
  6822. var _error = __webpack_require__(0);
  6823. var _visitor = __webpack_require__(15);
  6824. var _kinds = __webpack_require__(2);
  6825. var Kind = _interopRequireWildcard(_kinds);
  6826. var _schema = __webpack_require__(8);
  6827. var _TypeInfo = __webpack_require__(27);
  6828. var _specifiedRules = __webpack_require__(34);
  6829. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  6830. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  6831. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6832. /**
  6833. * Copyright (c) 2015, Facebook, Inc.
  6834. * All rights reserved.
  6835. *
  6836. * This source code is licensed under the BSD-style license found in the
  6837. * LICENSE file in the root directory of this source tree. An additional grant
  6838. * of patent rights can be found in the PATENTS file in the same directory.
  6839. */
  6840. /**
  6841. * Implements the "Validation" section of the spec.
  6842. *
  6843. * Validation runs synchronously, returning an array of encountered errors, or
  6844. * an empty array if no errors were encountered and the document is valid.
  6845. *
  6846. * A list of specific validation rules may be provided. If not provided, the
  6847. * default list of rules defined by the GraphQL specification will be used.
  6848. *
  6849. * Each validation rules is a function which returns a visitor
  6850. * (see the language/visitor API). Visitor methods are expected to return
  6851. * GraphQLErrors, or Arrays of GraphQLErrors when invalid.
  6852. */
  6853. function validate(schema, ast, rules) {
  6854. (0, _invariant2.default)(schema, 'Must provide schema');
  6855. (0, _invariant2.default)(ast, 'Must provide document');
  6856. (0, _invariant2.default)(schema instanceof _schema.GraphQLSchema, 'Schema must be an instance of GraphQLSchema. Also ensure that there are ' + 'not multiple versions of GraphQL installed in your node_modules directory.');
  6857. var typeInfo = new _TypeInfo.TypeInfo(schema);
  6858. return visitUsingRules(schema, typeInfo, ast, rules || _specifiedRules.specifiedRules);
  6859. }
  6860. /**
  6861. * This uses a specialized visitor which runs multiple visitors in parallel,
  6862. * while maintaining the visitor skip and break API.
  6863. *
  6864. * @internal
  6865. */
  6866. function visitUsingRules(schema, typeInfo, documentAST, rules) {
  6867. var context = new ValidationContext(schema, documentAST, typeInfo);
  6868. var visitors = rules.map(function (rule) {
  6869. return rule(context);
  6870. });
  6871. // Visit the whole document with each instance of all provided rules.
  6872. (0, _visitor.visit)(documentAST, (0, _visitor.visitWithTypeInfo)(typeInfo, (0, _visitor.visitInParallel)(visitors)));
  6873. return context.getErrors();
  6874. }
  6875. /**
  6876. * An instance of this class is passed as the "this" context to all validators,
  6877. * allowing access to commonly useful contextual information from within a
  6878. * validation rule.
  6879. */
  6880. var ValidationContext = exports.ValidationContext = function () {
  6881. function ValidationContext(schema, ast, typeInfo) {
  6882. _classCallCheck(this, ValidationContext);
  6883. this._schema = schema;
  6884. this._ast = ast;
  6885. this._typeInfo = typeInfo;
  6886. this._errors = [];
  6887. this._fragmentSpreads = new Map();
  6888. this._recursivelyReferencedFragments = new Map();
  6889. this._variableUsages = new Map();
  6890. this._recursiveVariableUsages = new Map();
  6891. }
  6892. ValidationContext.prototype.reportError = function reportError(error) {
  6893. this._errors.push(error);
  6894. };
  6895. ValidationContext.prototype.getErrors = function getErrors() {
  6896. return this._errors;
  6897. };
  6898. ValidationContext.prototype.getSchema = function getSchema() {
  6899. return this._schema;
  6900. };
  6901. ValidationContext.prototype.getDocument = function getDocument() {
  6902. return this._ast;
  6903. };
  6904. ValidationContext.prototype.getFragment = function getFragment(name) {
  6905. var fragments = this._fragments;
  6906. if (!fragments) {
  6907. this._fragments = fragments = this.getDocument().definitions.reduce(function (frags, statement) {
  6908. if (statement.kind === Kind.FRAGMENT_DEFINITION) {
  6909. frags[statement.name.value] = statement;
  6910. }
  6911. return frags;
  6912. }, {});
  6913. }
  6914. return fragments[name];
  6915. };
  6916. ValidationContext.prototype.getFragmentSpreads = function getFragmentSpreads(node) {
  6917. var spreads = this._fragmentSpreads.get(node);
  6918. if (!spreads) {
  6919. spreads = [];
  6920. var setsToVisit = [node];
  6921. while (setsToVisit.length !== 0) {
  6922. var set = setsToVisit.pop();
  6923. for (var i = 0; i < set.selections.length; i++) {
  6924. var selection = set.selections[i];
  6925. if (selection.kind === Kind.FRAGMENT_SPREAD) {
  6926. spreads.push(selection);
  6927. } else if (selection.selectionSet) {
  6928. setsToVisit.push(selection.selectionSet);
  6929. }
  6930. }
  6931. }
  6932. this._fragmentSpreads.set(node, spreads);
  6933. }
  6934. return spreads;
  6935. };
  6936. ValidationContext.prototype.getRecursivelyReferencedFragments = function getRecursivelyReferencedFragments(operation) {
  6937. var fragments = this._recursivelyReferencedFragments.get(operation);
  6938. if (!fragments) {
  6939. fragments = [];
  6940. var collectedNames = Object.create(null);
  6941. var nodesToVisit = [operation.selectionSet];
  6942. while (nodesToVisit.length !== 0) {
  6943. var _node = nodesToVisit.pop();
  6944. var spreads = this.getFragmentSpreads(_node);
  6945. for (var i = 0; i < spreads.length; i++) {
  6946. var fragName = spreads[i].name.value;
  6947. if (collectedNames[fragName] !== true) {
  6948. collectedNames[fragName] = true;
  6949. var fragment = this.getFragment(fragName);
  6950. if (fragment) {
  6951. fragments.push(fragment);
  6952. nodesToVisit.push(fragment.selectionSet);
  6953. }
  6954. }
  6955. }
  6956. }
  6957. this._recursivelyReferencedFragments.set(operation, fragments);
  6958. }
  6959. return fragments;
  6960. };
  6961. ValidationContext.prototype.getVariableUsages = function getVariableUsages(node) {
  6962. var _this = this;
  6963. var usages = this._variableUsages.get(node);
  6964. if (!usages) {
  6965. (function () {
  6966. var newUsages = [];
  6967. var typeInfo = new _TypeInfo.TypeInfo(_this._schema);
  6968. (0, _visitor.visit)(node, (0, _visitor.visitWithTypeInfo)(typeInfo, {
  6969. VariableDefinition: function VariableDefinition() {
  6970. return false;
  6971. },
  6972. Variable: function Variable(variable) {
  6973. newUsages.push({ node: variable, type: typeInfo.getInputType() });
  6974. }
  6975. }));
  6976. usages = newUsages;
  6977. _this._variableUsages.set(node, usages);
  6978. })();
  6979. }
  6980. return usages;
  6981. };
  6982. ValidationContext.prototype.getRecursiveVariableUsages = function getRecursiveVariableUsages(operation) {
  6983. var usages = this._recursiveVariableUsages.get(operation);
  6984. if (!usages) {
  6985. usages = this.getVariableUsages(operation);
  6986. var fragments = this.getRecursivelyReferencedFragments(operation);
  6987. for (var i = 0; i < fragments.length; i++) {
  6988. Array.prototype.push.apply(usages, this.getVariableUsages(fragments[i]));
  6989. }
  6990. this._recursiveVariableUsages.set(operation, usages);
  6991. }
  6992. return usages;
  6993. };
  6994. ValidationContext.prototype.getType = function getType() {
  6995. return this._typeInfo.getType();
  6996. };
  6997. ValidationContext.prototype.getParentType = function getParentType() {
  6998. return this._typeInfo.getParentType();
  6999. };
  7000. ValidationContext.prototype.getInputType = function getInputType() {
  7001. return this._typeInfo.getInputType();
  7002. };
  7003. ValidationContext.prototype.getFieldDef = function getFieldDef() {
  7004. return this._typeInfo.getFieldDef();
  7005. };
  7006. ValidationContext.prototype.getDirective = function getDirective() {
  7007. return this._typeInfo.getDirective();
  7008. };
  7009. ValidationContext.prototype.getArgument = function getArgument() {
  7010. return this._typeInfo.getArgument();
  7011. };
  7012. return ValidationContext;
  7013. }();
  7014. /***/ }),
  7015. /* 36 */
  7016. /***/ (function(module, exports, __webpack_require__) {
  7017. "use strict";
  7018. Object.defineProperty(exports, "__esModule", {
  7019. value: true
  7020. });
  7021. var _graphql = __webpack_require__(42);
  7022. Object.defineProperty(exports, 'graphql', {
  7023. enumerable: true,
  7024. get: function get() {
  7025. return _graphql.graphql;
  7026. }
  7027. });
  7028. var _type = __webpack_require__(44);
  7029. Object.defineProperty(exports, 'GraphQLSchema', {
  7030. enumerable: true,
  7031. get: function get() {
  7032. return _type.GraphQLSchema;
  7033. }
  7034. });
  7035. Object.defineProperty(exports, 'GraphQLScalarType', {
  7036. enumerable: true,
  7037. get: function get() {
  7038. return _type.GraphQLScalarType;
  7039. }
  7040. });
  7041. Object.defineProperty(exports, 'GraphQLObjectType', {
  7042. enumerable: true,
  7043. get: function get() {
  7044. return _type.GraphQLObjectType;
  7045. }
  7046. });
  7047. Object.defineProperty(exports, 'GraphQLInterfaceType', {
  7048. enumerable: true,
  7049. get: function get() {
  7050. return _type.GraphQLInterfaceType;
  7051. }
  7052. });
  7053. Object.defineProperty(exports, 'GraphQLUnionType', {
  7054. enumerable: true,
  7055. get: function get() {
  7056. return _type.GraphQLUnionType;
  7057. }
  7058. });
  7059. Object.defineProperty(exports, 'GraphQLEnumType', {
  7060. enumerable: true,
  7061. get: function get() {
  7062. return _type.GraphQLEnumType;
  7063. }
  7064. });
  7065. Object.defineProperty(exports, 'GraphQLInputObjectType', {
  7066. enumerable: true,
  7067. get: function get() {
  7068. return _type.GraphQLInputObjectType;
  7069. }
  7070. });
  7071. Object.defineProperty(exports, 'GraphQLList', {
  7072. enumerable: true,
  7073. get: function get() {
  7074. return _type.GraphQLList;
  7075. }
  7076. });
  7077. Object.defineProperty(exports, 'GraphQLNonNull', {
  7078. enumerable: true,
  7079. get: function get() {
  7080. return _type.GraphQLNonNull;
  7081. }
  7082. });
  7083. Object.defineProperty(exports, 'GraphQLDirective', {
  7084. enumerable: true,
  7085. get: function get() {
  7086. return _type.GraphQLDirective;
  7087. }
  7088. });
  7089. Object.defineProperty(exports, 'TypeKind', {
  7090. enumerable: true,
  7091. get: function get() {
  7092. return _type.TypeKind;
  7093. }
  7094. });
  7095. Object.defineProperty(exports, 'DirectiveLocation', {
  7096. enumerable: true,
  7097. get: function get() {
  7098. return _type.DirectiveLocation;
  7099. }
  7100. });
  7101. Object.defineProperty(exports, 'GraphQLInt', {
  7102. enumerable: true,
  7103. get: function get() {
  7104. return _type.GraphQLInt;
  7105. }
  7106. });
  7107. Object.defineProperty(exports, 'GraphQLFloat', {
  7108. enumerable: true,
  7109. get: function get() {
  7110. return _type.GraphQLFloat;
  7111. }
  7112. });
  7113. Object.defineProperty(exports, 'GraphQLString', {
  7114. enumerable: true,
  7115. get: function get() {
  7116. return _type.GraphQLString;
  7117. }
  7118. });
  7119. Object.defineProperty(exports, 'GraphQLBoolean', {
  7120. enumerable: true,
  7121. get: function get() {
  7122. return _type.GraphQLBoolean;
  7123. }
  7124. });
  7125. Object.defineProperty(exports, 'GraphQLID', {
  7126. enumerable: true,
  7127. get: function get() {
  7128. return _type.GraphQLID;
  7129. }
  7130. });
  7131. Object.defineProperty(exports, 'specifiedDirectives', {
  7132. enumerable: true,
  7133. get: function get() {
  7134. return _type.specifiedDirectives;
  7135. }
  7136. });
  7137. Object.defineProperty(exports, 'GraphQLIncludeDirective', {
  7138. enumerable: true,
  7139. get: function get() {
  7140. return _type.GraphQLIncludeDirective;
  7141. }
  7142. });
  7143. Object.defineProperty(exports, 'GraphQLSkipDirective', {
  7144. enumerable: true,
  7145. get: function get() {
  7146. return _type.GraphQLSkipDirective;
  7147. }
  7148. });
  7149. Object.defineProperty(exports, 'GraphQLDeprecatedDirective', {
  7150. enumerable: true,
  7151. get: function get() {
  7152. return _type.GraphQLDeprecatedDirective;
  7153. }
  7154. });
  7155. Object.defineProperty(exports, 'DEFAULT_DEPRECATION_REASON', {
  7156. enumerable: true,
  7157. get: function get() {
  7158. return _type.DEFAULT_DEPRECATION_REASON;
  7159. }
  7160. });
  7161. Object.defineProperty(exports, 'SchemaMetaFieldDef', {
  7162. enumerable: true,
  7163. get: function get() {
  7164. return _type.SchemaMetaFieldDef;
  7165. }
  7166. });
  7167. Object.defineProperty(exports, 'TypeMetaFieldDef', {
  7168. enumerable: true,
  7169. get: function get() {
  7170. return _type.TypeMetaFieldDef;
  7171. }
  7172. });
  7173. Object.defineProperty(exports, 'TypeNameMetaFieldDef', {
  7174. enumerable: true,
  7175. get: function get() {
  7176. return _type.TypeNameMetaFieldDef;
  7177. }
  7178. });
  7179. Object.defineProperty(exports, '__Schema', {
  7180. enumerable: true,
  7181. get: function get() {
  7182. return _type.__Schema;
  7183. }
  7184. });
  7185. Object.defineProperty(exports, '__Directive', {
  7186. enumerable: true,
  7187. get: function get() {
  7188. return _type.__Directive;
  7189. }
  7190. });
  7191. Object.defineProperty(exports, '__DirectiveLocation', {
  7192. enumerable: true,
  7193. get: function get() {
  7194. return _type.__DirectiveLocation;
  7195. }
  7196. });
  7197. Object.defineProperty(exports, '__Type', {
  7198. enumerable: true,
  7199. get: function get() {
  7200. return _type.__Type;
  7201. }
  7202. });
  7203. Object.defineProperty(exports, '__Field', {
  7204. enumerable: true,
  7205. get: function get() {
  7206. return _type.__Field;
  7207. }
  7208. });
  7209. Object.defineProperty(exports, '__InputValue', {
  7210. enumerable: true,
  7211. get: function get() {
  7212. return _type.__InputValue;
  7213. }
  7214. });
  7215. Object.defineProperty(exports, '__EnumValue', {
  7216. enumerable: true,
  7217. get: function get() {
  7218. return _type.__EnumValue;
  7219. }
  7220. });
  7221. Object.defineProperty(exports, '__TypeKind', {
  7222. enumerable: true,
  7223. get: function get() {
  7224. return _type.__TypeKind;
  7225. }
  7226. });
  7227. Object.defineProperty(exports, 'isType', {
  7228. enumerable: true,
  7229. get: function get() {
  7230. return _type.isType;
  7231. }
  7232. });
  7233. Object.defineProperty(exports, 'isInputType', {
  7234. enumerable: true,
  7235. get: function get() {
  7236. return _type.isInputType;
  7237. }
  7238. });
  7239. Object.defineProperty(exports, 'isOutputType', {
  7240. enumerable: true,
  7241. get: function get() {
  7242. return _type.isOutputType;
  7243. }
  7244. });
  7245. Object.defineProperty(exports, 'isLeafType', {
  7246. enumerable: true,
  7247. get: function get() {
  7248. return _type.isLeafType;
  7249. }
  7250. });
  7251. Object.defineProperty(exports, 'isCompositeType', {
  7252. enumerable: true,
  7253. get: function get() {
  7254. return _type.isCompositeType;
  7255. }
  7256. });
  7257. Object.defineProperty(exports, 'isAbstractType', {
  7258. enumerable: true,
  7259. get: function get() {
  7260. return _type.isAbstractType;
  7261. }
  7262. });
  7263. Object.defineProperty(exports, 'isNamedType', {
  7264. enumerable: true,
  7265. get: function get() {
  7266. return _type.isNamedType;
  7267. }
  7268. });
  7269. Object.defineProperty(exports, 'assertType', {
  7270. enumerable: true,
  7271. get: function get() {
  7272. return _type.assertType;
  7273. }
  7274. });
  7275. Object.defineProperty(exports, 'assertInputType', {
  7276. enumerable: true,
  7277. get: function get() {
  7278. return _type.assertInputType;
  7279. }
  7280. });
  7281. Object.defineProperty(exports, 'assertOutputType', {
  7282. enumerable: true,
  7283. get: function get() {
  7284. return _type.assertOutputType;
  7285. }
  7286. });
  7287. Object.defineProperty(exports, 'assertLeafType', {
  7288. enumerable: true,
  7289. get: function get() {
  7290. return _type.assertLeafType;
  7291. }
  7292. });
  7293. Object.defineProperty(exports, 'assertCompositeType', {
  7294. enumerable: true,
  7295. get: function get() {
  7296. return _type.assertCompositeType;
  7297. }
  7298. });
  7299. Object.defineProperty(exports, 'assertAbstractType', {
  7300. enumerable: true,
  7301. get: function get() {
  7302. return _type.assertAbstractType;
  7303. }
  7304. });
  7305. Object.defineProperty(exports, 'assertNamedType', {
  7306. enumerable: true,
  7307. get: function get() {
  7308. return _type.assertNamedType;
  7309. }
  7310. });
  7311. Object.defineProperty(exports, 'getNullableType', {
  7312. enumerable: true,
  7313. get: function get() {
  7314. return _type.getNullableType;
  7315. }
  7316. });
  7317. Object.defineProperty(exports, 'getNamedType', {
  7318. enumerable: true,
  7319. get: function get() {
  7320. return _type.getNamedType;
  7321. }
  7322. });
  7323. var _language = __webpack_require__(43);
  7324. Object.defineProperty(exports, 'Source', {
  7325. enumerable: true,
  7326. get: function get() {
  7327. return _language.Source;
  7328. }
  7329. });
  7330. Object.defineProperty(exports, 'getLocation', {
  7331. enumerable: true,
  7332. get: function get() {
  7333. return _language.getLocation;
  7334. }
  7335. });
  7336. Object.defineProperty(exports, 'parse', {
  7337. enumerable: true,
  7338. get: function get() {
  7339. return _language.parse;
  7340. }
  7341. });
  7342. Object.defineProperty(exports, 'parseValue', {
  7343. enumerable: true,
  7344. get: function get() {
  7345. return _language.parseValue;
  7346. }
  7347. });
  7348. Object.defineProperty(exports, 'parseType', {
  7349. enumerable: true,
  7350. get: function get() {
  7351. return _language.parseType;
  7352. }
  7353. });
  7354. Object.defineProperty(exports, 'print', {
  7355. enumerable: true,
  7356. get: function get() {
  7357. return _language.print;
  7358. }
  7359. });
  7360. Object.defineProperty(exports, 'visit', {
  7361. enumerable: true,
  7362. get: function get() {
  7363. return _language.visit;
  7364. }
  7365. });
  7366. Object.defineProperty(exports, 'visitInParallel', {
  7367. enumerable: true,
  7368. get: function get() {
  7369. return _language.visitInParallel;
  7370. }
  7371. });
  7372. Object.defineProperty(exports, 'visitWithTypeInfo', {
  7373. enumerable: true,
  7374. get: function get() {
  7375. return _language.visitWithTypeInfo;
  7376. }
  7377. });
  7378. Object.defineProperty(exports, 'Kind', {
  7379. enumerable: true,
  7380. get: function get() {
  7381. return _language.Kind;
  7382. }
  7383. });
  7384. Object.defineProperty(exports, 'TokenKind', {
  7385. enumerable: true,
  7386. get: function get() {
  7387. return _language.TokenKind;
  7388. }
  7389. });
  7390. Object.defineProperty(exports, 'BREAK', {
  7391. enumerable: true,
  7392. get: function get() {
  7393. return _language.BREAK;
  7394. }
  7395. });
  7396. var _execution = __webpack_require__(41);
  7397. Object.defineProperty(exports, 'execute', {
  7398. enumerable: true,
  7399. get: function get() {
  7400. return _execution.execute;
  7401. }
  7402. });
  7403. Object.defineProperty(exports, 'defaultFieldResolver', {
  7404. enumerable: true,
  7405. get: function get() {
  7406. return _execution.defaultFieldResolver;
  7407. }
  7408. });
  7409. Object.defineProperty(exports, 'responsePathAsArray', {
  7410. enumerable: true,
  7411. get: function get() {
  7412. return _execution.responsePathAsArray;
  7413. }
  7414. });
  7415. var _validation = __webpack_require__(55);
  7416. Object.defineProperty(exports, 'validate', {
  7417. enumerable: true,
  7418. get: function get() {
  7419. return _validation.validate;
  7420. }
  7421. });
  7422. Object.defineProperty(exports, 'ValidationContext', {
  7423. enumerable: true,
  7424. get: function get() {
  7425. return _validation.ValidationContext;
  7426. }
  7427. });
  7428. Object.defineProperty(exports, 'specifiedRules', {
  7429. enumerable: true,
  7430. get: function get() {
  7431. return _validation.specifiedRules;
  7432. }
  7433. });
  7434. var _error = __webpack_require__(0);
  7435. Object.defineProperty(exports, 'GraphQLError', {
  7436. enumerable: true,
  7437. get: function get() {
  7438. return _error.GraphQLError;
  7439. }
  7440. });
  7441. Object.defineProperty(exports, 'formatError', {
  7442. enumerable: true,
  7443. get: function get() {
  7444. return _error.formatError;
  7445. }
  7446. });
  7447. var _utilities = __webpack_require__(51);
  7448. Object.defineProperty(exports, 'introspectionQuery', {
  7449. enumerable: true,
  7450. get: function get() {
  7451. return _utilities.introspectionQuery;
  7452. }
  7453. });
  7454. Object.defineProperty(exports, 'getOperationAST', {
  7455. enumerable: true,
  7456. get: function get() {
  7457. return _utilities.getOperationAST;
  7458. }
  7459. });
  7460. Object.defineProperty(exports, 'buildClientSchema', {
  7461. enumerable: true,
  7462. get: function get() {
  7463. return _utilities.buildClientSchema;
  7464. }
  7465. });
  7466. Object.defineProperty(exports, 'buildASTSchema', {
  7467. enumerable: true,
  7468. get: function get() {
  7469. return _utilities.buildASTSchema;
  7470. }
  7471. });
  7472. Object.defineProperty(exports, 'buildSchema', {
  7473. enumerable: true,
  7474. get: function get() {
  7475. return _utilities.buildSchema;
  7476. }
  7477. });
  7478. Object.defineProperty(exports, 'extendSchema', {
  7479. enumerable: true,
  7480. get: function get() {
  7481. return _utilities.extendSchema;
  7482. }
  7483. });
  7484. Object.defineProperty(exports, 'printSchema', {
  7485. enumerable: true,
  7486. get: function get() {
  7487. return _utilities.printSchema;
  7488. }
  7489. });
  7490. Object.defineProperty(exports, 'printType', {
  7491. enumerable: true,
  7492. get: function get() {
  7493. return _utilities.printType;
  7494. }
  7495. });
  7496. Object.defineProperty(exports, 'typeFromAST', {
  7497. enumerable: true,
  7498. get: function get() {
  7499. return _utilities.typeFromAST;
  7500. }
  7501. });
  7502. Object.defineProperty(exports, 'valueFromAST', {
  7503. enumerable: true,
  7504. get: function get() {
  7505. return _utilities.valueFromAST;
  7506. }
  7507. });
  7508. Object.defineProperty(exports, 'astFromValue', {
  7509. enumerable: true,
  7510. get: function get() {
  7511. return _utilities.astFromValue;
  7512. }
  7513. });
  7514. Object.defineProperty(exports, 'TypeInfo', {
  7515. enumerable: true,
  7516. get: function get() {
  7517. return _utilities.TypeInfo;
  7518. }
  7519. });
  7520. Object.defineProperty(exports, 'isValidJSValue', {
  7521. enumerable: true,
  7522. get: function get() {
  7523. return _utilities.isValidJSValue;
  7524. }
  7525. });
  7526. Object.defineProperty(exports, 'isValidLiteralValue', {
  7527. enumerable: true,
  7528. get: function get() {
  7529. return _utilities.isValidLiteralValue;
  7530. }
  7531. });
  7532. Object.defineProperty(exports, 'concatAST', {
  7533. enumerable: true,
  7534. get: function get() {
  7535. return _utilities.concatAST;
  7536. }
  7537. });
  7538. Object.defineProperty(exports, 'separateOperations', {
  7539. enumerable: true,
  7540. get: function get() {
  7541. return _utilities.separateOperations;
  7542. }
  7543. });
  7544. Object.defineProperty(exports, 'isEqualType', {
  7545. enumerable: true,
  7546. get: function get() {
  7547. return _utilities.isEqualType;
  7548. }
  7549. });
  7550. Object.defineProperty(exports, 'isTypeSubTypeOf', {
  7551. enumerable: true,
  7552. get: function get() {
  7553. return _utilities.isTypeSubTypeOf;
  7554. }
  7555. });
  7556. Object.defineProperty(exports, 'doTypesOverlap', {
  7557. enumerable: true,
  7558. get: function get() {
  7559. return _utilities.doTypesOverlap;
  7560. }
  7561. });
  7562. Object.defineProperty(exports, 'assertValidName', {
  7563. enumerable: true,
  7564. get: function get() {
  7565. return _utilities.assertValidName;
  7566. }
  7567. });
  7568. Object.defineProperty(exports, 'findBreakingChanges', {
  7569. enumerable: true,
  7570. get: function get() {
  7571. return _utilities.findBreakingChanges;
  7572. }
  7573. });
  7574. Object.defineProperty(exports, 'findDeprecatedUsages', {
  7575. enumerable: true,
  7576. get: function get() {
  7577. return _utilities.findDeprecatedUsages;
  7578. }
  7579. });
  7580. /***/ }),
  7581. /* 37 */
  7582. /***/ (function(module, exports, __webpack_require__) {
  7583. "use strict";
  7584. Object.defineProperty(exports, "__esModule", { value: true });
  7585. var graphql_1 = __webpack_require__(36);
  7586. var hasSubscriptionOperation = function (graphQlParams) {
  7587. var queryDoc = graphql_1.parse(graphQlParams.query);
  7588. for (var _i = 0, _a = queryDoc.definitions; _i < _a.length; _i++) {
  7589. var definition = _a[_i];
  7590. if (definition.kind === 'OperationDefinition') {
  7591. var operation = definition.operation;
  7592. if (operation === 'subscription') {
  7593. return true;
  7594. }
  7595. }
  7596. }
  7597. return false;
  7598. };
  7599. exports.graphQLFetcher = function (subscriptionsClient, fallbackFetcher) {
  7600. var activeSubscriptionId = null;
  7601. return function (graphQLParams) {
  7602. if (subscriptionsClient && activeSubscriptionId !== null) {
  7603. subscriptionsClient.unsubscribe(activeSubscriptionId);
  7604. }
  7605. if (subscriptionsClient && hasSubscriptionOperation(graphQLParams)) {
  7606. return {
  7607. subscribe: function (observer) {
  7608. observer.next('Your subscription data will appear here after server publication!');
  7609. activeSubscriptionId = subscriptionsClient.subscribe({
  7610. query: graphQLParams.query,
  7611. variables: graphQLParams.variables,
  7612. }, function (error, result) {
  7613. if (error) {
  7614. observer.error(error);
  7615. }
  7616. else {
  7617. observer.next(result);
  7618. }
  7619. });
  7620. },
  7621. };
  7622. }
  7623. else {
  7624. return fallbackFetcher(graphQLParams);
  7625. }
  7626. };
  7627. };
  7628. //# sourceMappingURL=fetcher.js.map
  7629. /***/ }),
  7630. /* 38 */
  7631. /***/ (function(module, exports, __webpack_require__) {
  7632. "use strict";
  7633. Object.defineProperty(exports, "__esModule", {
  7634. value: true
  7635. });
  7636. exports.formatError = formatError;
  7637. var _invariant = __webpack_require__(3);
  7638. var _invariant2 = _interopRequireDefault(_invariant);
  7639. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  7640. /**
  7641. * Given a GraphQLError, format it according to the rules described by the
  7642. * Response Format, Errors section of the GraphQL Specification.
  7643. */
  7644. function formatError(error) {
  7645. (0, _invariant2.default)(error, 'Received null or undefined error.');
  7646. return {
  7647. message: error.message,
  7648. locations: error.locations,
  7649. path: error.path
  7650. };
  7651. }
  7652. /**
  7653. * Copyright (c) 2015, Facebook, Inc.
  7654. * All rights reserved.
  7655. *
  7656. * This source code is licensed under the BSD-style license found in the
  7657. * LICENSE file in the root directory of this source tree. An additional grant
  7658. * of patent rights can be found in the PATENTS file in the same directory.
  7659. */
  7660. /***/ }),
  7661. /* 39 */
  7662. /***/ (function(module, exports, __webpack_require__) {
  7663. "use strict";
  7664. Object.defineProperty(exports, "__esModule", {
  7665. value: true
  7666. });
  7667. exports.locatedError = locatedError;
  7668. var _GraphQLError = __webpack_require__(13);
  7669. /**
  7670. * Given an arbitrary Error, presumably thrown while attempting to execute a
  7671. * GraphQL operation, produce a new GraphQLError aware of the location in the
  7672. * document responsible for the original Error.
  7673. */
  7674. function locatedError(originalError, nodes, path) {
  7675. // Note: this uses a brand-check to support GraphQL errors originating from
  7676. // other contexts.
  7677. if (originalError && originalError.path) {
  7678. return originalError;
  7679. }
  7680. var message = originalError ? originalError.message || String(originalError) : 'An unknown error occurred.';
  7681. return new _GraphQLError.GraphQLError(message, originalError && originalError.nodes || nodes, originalError && originalError.source, originalError && originalError.positions, path, originalError);
  7682. }
  7683. /**
  7684. * Copyright (c) 2015, Facebook, Inc.
  7685. * All rights reserved.
  7686. *
  7687. * This source code is licensed under the BSD-style license found in the
  7688. * LICENSE file in the root directory of this source tree. An additional grant
  7689. * of patent rights can be found in the PATENTS file in the same directory.
  7690. */
  7691. /***/ }),
  7692. /* 40 */
  7693. /***/ (function(module, exports, __webpack_require__) {
  7694. "use strict";
  7695. Object.defineProperty(exports, "__esModule", {
  7696. value: true
  7697. });
  7698. exports.syntaxError = syntaxError;
  7699. var _location = __webpack_require__(25);
  7700. var _GraphQLError = __webpack_require__(13);
  7701. /**
  7702. * Produces a GraphQLError representing a syntax error, containing useful
  7703. * descriptive information about the syntax error's position in the source.
  7704. */
  7705. /**
  7706. * Copyright (c) 2015, Facebook, Inc.
  7707. * All rights reserved.
  7708. *
  7709. * This source code is licensed under the BSD-style license found in the
  7710. * LICENSE file in the root directory of this source tree. An additional grant
  7711. * of patent rights can be found in the PATENTS file in the same directory.
  7712. */
  7713. function syntaxError(source, position, description) {
  7714. var location = (0, _location.getLocation)(source, position);
  7715. var error = new _GraphQLError.GraphQLError('Syntax Error ' + source.name + ' (' + location.line + ':' + location.column + ') ' + description + '\n\n' + highlightSourceAtLocation(source, location), undefined, source, [position]);
  7716. return error;
  7717. }
  7718. /**
  7719. * Render a helpful description of the location of the error in the GraphQL
  7720. * Source document.
  7721. */
  7722. function highlightSourceAtLocation(source, location) {
  7723. var line = location.line;
  7724. var prevLineNum = (line - 1).toString();
  7725. var lineNum = line.toString();
  7726. var nextLineNum = (line + 1).toString();
  7727. var padLen = nextLineNum.length;
  7728. var lines = source.body.split(/\r\n|[\n\r]/g);
  7729. return (line >= 2 ? lpad(padLen, prevLineNum) + ': ' + lines[line - 2] + '\n' : '') + lpad(padLen, lineNum) + ': ' + lines[line - 1] + '\n' + Array(2 + padLen + location.column).join(' ') + '^\n' + (line < lines.length ? lpad(padLen, nextLineNum) + ': ' + lines[line] + '\n' : '');
  7730. }
  7731. function lpad(len, str) {
  7732. return Array(len - str.length + 1).join(' ') + str;
  7733. }
  7734. /***/ }),
  7735. /* 41 */
  7736. /***/ (function(module, exports, __webpack_require__) {
  7737. "use strict";
  7738. Object.defineProperty(exports, "__esModule", {
  7739. value: true
  7740. });
  7741. var _execute = __webpack_require__(30);
  7742. Object.defineProperty(exports, 'execute', {
  7743. enumerable: true,
  7744. get: function get() {
  7745. return _execute.execute;
  7746. }
  7747. });
  7748. Object.defineProperty(exports, 'defaultFieldResolver', {
  7749. enumerable: true,
  7750. get: function get() {
  7751. return _execute.defaultFieldResolver;
  7752. }
  7753. });
  7754. Object.defineProperty(exports, 'responsePathAsArray', {
  7755. enumerable: true,
  7756. get: function get() {
  7757. return _execute.responsePathAsArray;
  7758. }
  7759. });
  7760. /***/ }),
  7761. /* 42 */
  7762. /***/ (function(module, exports, __webpack_require__) {
  7763. "use strict";
  7764. Object.defineProperty(exports, "__esModule", {
  7765. value: true
  7766. });
  7767. exports.graphql = graphql;
  7768. var _source = __webpack_require__(26);
  7769. var _parser = __webpack_require__(17);
  7770. var _validate = __webpack_require__(35);
  7771. var _execute = __webpack_require__(30);
  7772. /**
  7773. * This is the primary entry point function for fulfilling GraphQL operations
  7774. * by parsing, validating, and executing a GraphQL document along side a
  7775. * GraphQL schema.
  7776. *
  7777. * More sophisticated GraphQL servers, such as those which persist queries,
  7778. * may wish to separate the validation and execution phases to a static time
  7779. * tooling step, and a server runtime step.
  7780. *
  7781. * schema:
  7782. * The GraphQL type system to use when validating and executing a query.
  7783. * requestString:
  7784. * A GraphQL language formatted string representing the requested operation.
  7785. * rootValue:
  7786. * The value provided as the first argument to resolver functions on the top
  7787. * level type (e.g. the query object type).
  7788. * variableValues:
  7789. * A mapping of variable name to runtime value to use for all variables
  7790. * defined in the requestString.
  7791. * operationName:
  7792. * The name of the operation to use if requestString contains multiple
  7793. * possible operations. Can be omitted if requestString contains only
  7794. * one operation.
  7795. */
  7796. /**
  7797. * Copyright (c) 2015, Facebook, Inc.
  7798. * All rights reserved.
  7799. *
  7800. * This source code is licensed under the BSD-style license found in the
  7801. * LICENSE file in the root directory of this source tree. An additional grant
  7802. * of patent rights can be found in the PATENTS file in the same directory.
  7803. */
  7804. function graphql(schema, requestString, rootValue, contextValue, variableValues, operationName) {
  7805. return new Promise(function (resolve) {
  7806. var source = new _source.Source(requestString || '', 'GraphQL request');
  7807. var documentAST = (0, _parser.parse)(source);
  7808. var validationErrors = (0, _validate.validate)(schema, documentAST);
  7809. if (validationErrors.length > 0) {
  7810. resolve({ errors: validationErrors });
  7811. } else {
  7812. resolve((0, _execute.execute)(schema, documentAST, rootValue, contextValue, variableValues, operationName));
  7813. }
  7814. }).then(undefined, function (error) {
  7815. return { errors: [error] };
  7816. });
  7817. }
  7818. /***/ }),
  7819. /* 43 */
  7820. /***/ (function(module, exports, __webpack_require__) {
  7821. "use strict";
  7822. Object.defineProperty(exports, "__esModule", {
  7823. value: true
  7824. });
  7825. exports.BREAK = exports.visitWithTypeInfo = exports.visitInParallel = exports.visit = exports.Source = exports.print = exports.parseType = exports.parseValue = exports.parse = exports.TokenKind = exports.createLexer = exports.Kind = exports.getLocation = undefined;
  7826. var _location = __webpack_require__(25);
  7827. Object.defineProperty(exports, 'getLocation', {
  7828. enumerable: true,
  7829. get: function get() {
  7830. return _location.getLocation;
  7831. }
  7832. });
  7833. var _lexer = __webpack_require__(24);
  7834. Object.defineProperty(exports, 'createLexer', {
  7835. enumerable: true,
  7836. get: function get() {
  7837. return _lexer.createLexer;
  7838. }
  7839. });
  7840. Object.defineProperty(exports, 'TokenKind', {
  7841. enumerable: true,
  7842. get: function get() {
  7843. return _lexer.TokenKind;
  7844. }
  7845. });
  7846. var _parser = __webpack_require__(17);
  7847. Object.defineProperty(exports, 'parse', {
  7848. enumerable: true,
  7849. get: function get() {
  7850. return _parser.parse;
  7851. }
  7852. });
  7853. Object.defineProperty(exports, 'parseValue', {
  7854. enumerable: true,
  7855. get: function get() {
  7856. return _parser.parseValue;
  7857. }
  7858. });
  7859. Object.defineProperty(exports, 'parseType', {
  7860. enumerable: true,
  7861. get: function get() {
  7862. return _parser.parseType;
  7863. }
  7864. });
  7865. var _printer = __webpack_require__(4);
  7866. Object.defineProperty(exports, 'print', {
  7867. enumerable: true,
  7868. get: function get() {
  7869. return _printer.print;
  7870. }
  7871. });
  7872. var _source = __webpack_require__(26);
  7873. Object.defineProperty(exports, 'Source', {
  7874. enumerable: true,
  7875. get: function get() {
  7876. return _source.Source;
  7877. }
  7878. });
  7879. var _visitor = __webpack_require__(15);
  7880. Object.defineProperty(exports, 'visit', {
  7881. enumerable: true,
  7882. get: function get() {
  7883. return _visitor.visit;
  7884. }
  7885. });
  7886. Object.defineProperty(exports, 'visitInParallel', {
  7887. enumerable: true,
  7888. get: function get() {
  7889. return _visitor.visitInParallel;
  7890. }
  7891. });
  7892. Object.defineProperty(exports, 'visitWithTypeInfo', {
  7893. enumerable: true,
  7894. get: function get() {
  7895. return _visitor.visitWithTypeInfo;
  7896. }
  7897. });
  7898. Object.defineProperty(exports, 'BREAK', {
  7899. enumerable: true,
  7900. get: function get() {
  7901. return _visitor.BREAK;
  7902. }
  7903. });
  7904. var _kinds = __webpack_require__(2);
  7905. var Kind = _interopRequireWildcard(_kinds);
  7906. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  7907. exports.Kind = Kind;
  7908. /***/ }),
  7909. /* 44 */
  7910. /***/ (function(module, exports, __webpack_require__) {
  7911. "use strict";
  7912. Object.defineProperty(exports, "__esModule", {
  7913. value: true
  7914. });
  7915. var _schema = __webpack_require__(8);
  7916. Object.defineProperty(exports, 'GraphQLSchema', {
  7917. enumerable: true,
  7918. get: function get() {
  7919. return _schema.GraphQLSchema;
  7920. }
  7921. });
  7922. var _definition = __webpack_require__(1);
  7923. Object.defineProperty(exports, 'isType', {
  7924. enumerable: true,
  7925. get: function get() {
  7926. return _definition.isType;
  7927. }
  7928. });
  7929. Object.defineProperty(exports, 'isInputType', {
  7930. enumerable: true,
  7931. get: function get() {
  7932. return _definition.isInputType;
  7933. }
  7934. });
  7935. Object.defineProperty(exports, 'isOutputType', {
  7936. enumerable: true,
  7937. get: function get() {
  7938. return _definition.isOutputType;
  7939. }
  7940. });
  7941. Object.defineProperty(exports, 'isLeafType', {
  7942. enumerable: true,
  7943. get: function get() {
  7944. return _definition.isLeafType;
  7945. }
  7946. });
  7947. Object.defineProperty(exports, 'isCompositeType', {
  7948. enumerable: true,
  7949. get: function get() {
  7950. return _definition.isCompositeType;
  7951. }
  7952. });
  7953. Object.defineProperty(exports, 'isAbstractType', {
  7954. enumerable: true,
  7955. get: function get() {
  7956. return _definition.isAbstractType;
  7957. }
  7958. });
  7959. Object.defineProperty(exports, 'isNamedType', {
  7960. enumerable: true,
  7961. get: function get() {
  7962. return _definition.isNamedType;
  7963. }
  7964. });
  7965. Object.defineProperty(exports, 'assertType', {
  7966. enumerable: true,
  7967. get: function get() {
  7968. return _definition.assertType;
  7969. }
  7970. });
  7971. Object.defineProperty(exports, 'assertInputType', {
  7972. enumerable: true,
  7973. get: function get() {
  7974. return _definition.assertInputType;
  7975. }
  7976. });
  7977. Object.defineProperty(exports, 'assertOutputType', {
  7978. enumerable: true,
  7979. get: function get() {
  7980. return _definition.assertOutputType;
  7981. }
  7982. });
  7983. Object.defineProperty(exports, 'assertLeafType', {
  7984. enumerable: true,
  7985. get: function get() {
  7986. return _definition.assertLeafType;
  7987. }
  7988. });
  7989. Object.defineProperty(exports, 'assertCompositeType', {
  7990. enumerable: true,
  7991. get: function get() {
  7992. return _definition.assertCompositeType;
  7993. }
  7994. });
  7995. Object.defineProperty(exports, 'assertAbstractType', {
  7996. enumerable: true,
  7997. get: function get() {
  7998. return _definition.assertAbstractType;
  7999. }
  8000. });
  8001. Object.defineProperty(exports, 'assertNamedType', {
  8002. enumerable: true,
  8003. get: function get() {
  8004. return _definition.assertNamedType;
  8005. }
  8006. });
  8007. Object.defineProperty(exports, 'getNullableType', {
  8008. enumerable: true,
  8009. get: function get() {
  8010. return _definition.getNullableType;
  8011. }
  8012. });
  8013. Object.defineProperty(exports, 'getNamedType', {
  8014. enumerable: true,
  8015. get: function get() {
  8016. return _definition.getNamedType;
  8017. }
  8018. });
  8019. Object.defineProperty(exports, 'GraphQLScalarType', {
  8020. enumerable: true,
  8021. get: function get() {
  8022. return _definition.GraphQLScalarType;
  8023. }
  8024. });
  8025. Object.defineProperty(exports, 'GraphQLObjectType', {
  8026. enumerable: true,
  8027. get: function get() {
  8028. return _definition.GraphQLObjectType;
  8029. }
  8030. });
  8031. Object.defineProperty(exports, 'GraphQLInterfaceType', {
  8032. enumerable: true,
  8033. get: function get() {
  8034. return _definition.GraphQLInterfaceType;
  8035. }
  8036. });
  8037. Object.defineProperty(exports, 'GraphQLUnionType', {
  8038. enumerable: true,
  8039. get: function get() {
  8040. return _definition.GraphQLUnionType;
  8041. }
  8042. });
  8043. Object.defineProperty(exports, 'GraphQLEnumType', {
  8044. enumerable: true,
  8045. get: function get() {
  8046. return _definition.GraphQLEnumType;
  8047. }
  8048. });
  8049. Object.defineProperty(exports, 'GraphQLInputObjectType', {
  8050. enumerable: true,
  8051. get: function get() {
  8052. return _definition.GraphQLInputObjectType;
  8053. }
  8054. });
  8055. Object.defineProperty(exports, 'GraphQLList', {
  8056. enumerable: true,
  8057. get: function get() {
  8058. return _definition.GraphQLList;
  8059. }
  8060. });
  8061. Object.defineProperty(exports, 'GraphQLNonNull', {
  8062. enumerable: true,
  8063. get: function get() {
  8064. return _definition.GraphQLNonNull;
  8065. }
  8066. });
  8067. var _directives = __webpack_require__(5);
  8068. Object.defineProperty(exports, 'DirectiveLocation', {
  8069. enumerable: true,
  8070. get: function get() {
  8071. return _directives.DirectiveLocation;
  8072. }
  8073. });
  8074. Object.defineProperty(exports, 'GraphQLDirective', {
  8075. enumerable: true,
  8076. get: function get() {
  8077. return _directives.GraphQLDirective;
  8078. }
  8079. });
  8080. Object.defineProperty(exports, 'specifiedDirectives', {
  8081. enumerable: true,
  8082. get: function get() {
  8083. return _directives.specifiedDirectives;
  8084. }
  8085. });
  8086. Object.defineProperty(exports, 'GraphQLIncludeDirective', {
  8087. enumerable: true,
  8088. get: function get() {
  8089. return _directives.GraphQLIncludeDirective;
  8090. }
  8091. });
  8092. Object.defineProperty(exports, 'GraphQLSkipDirective', {
  8093. enumerable: true,
  8094. get: function get() {
  8095. return _directives.GraphQLSkipDirective;
  8096. }
  8097. });
  8098. Object.defineProperty(exports, 'GraphQLDeprecatedDirective', {
  8099. enumerable: true,
  8100. get: function get() {
  8101. return _directives.GraphQLDeprecatedDirective;
  8102. }
  8103. });
  8104. Object.defineProperty(exports, 'DEFAULT_DEPRECATION_REASON', {
  8105. enumerable: true,
  8106. get: function get() {
  8107. return _directives.DEFAULT_DEPRECATION_REASON;
  8108. }
  8109. });
  8110. var _scalars = __webpack_require__(7);
  8111. Object.defineProperty(exports, 'GraphQLInt', {
  8112. enumerable: true,
  8113. get: function get() {
  8114. return _scalars.GraphQLInt;
  8115. }
  8116. });
  8117. Object.defineProperty(exports, 'GraphQLFloat', {
  8118. enumerable: true,
  8119. get: function get() {
  8120. return _scalars.GraphQLFloat;
  8121. }
  8122. });
  8123. Object.defineProperty(exports, 'GraphQLString', {
  8124. enumerable: true,
  8125. get: function get() {
  8126. return _scalars.GraphQLString;
  8127. }
  8128. });
  8129. Object.defineProperty(exports, 'GraphQLBoolean', {
  8130. enumerable: true,
  8131. get: function get() {
  8132. return _scalars.GraphQLBoolean;
  8133. }
  8134. });
  8135. Object.defineProperty(exports, 'GraphQLID', {
  8136. enumerable: true,
  8137. get: function get() {
  8138. return _scalars.GraphQLID;
  8139. }
  8140. });
  8141. var _introspection = __webpack_require__(11);
  8142. Object.defineProperty(exports, 'TypeKind', {
  8143. enumerable: true,
  8144. get: function get() {
  8145. return _introspection.TypeKind;
  8146. }
  8147. });
  8148. Object.defineProperty(exports, '__Schema', {
  8149. enumerable: true,
  8150. get: function get() {
  8151. return _introspection.__Schema;
  8152. }
  8153. });
  8154. Object.defineProperty(exports, '__Directive', {
  8155. enumerable: true,
  8156. get: function get() {
  8157. return _introspection.__Directive;
  8158. }
  8159. });
  8160. Object.defineProperty(exports, '__DirectiveLocation', {
  8161. enumerable: true,
  8162. get: function get() {
  8163. return _introspection.__DirectiveLocation;
  8164. }
  8165. });
  8166. Object.defineProperty(exports, '__Type', {
  8167. enumerable: true,
  8168. get: function get() {
  8169. return _introspection.__Type;
  8170. }
  8171. });
  8172. Object.defineProperty(exports, '__Field', {
  8173. enumerable: true,
  8174. get: function get() {
  8175. return _introspection.__Field;
  8176. }
  8177. });
  8178. Object.defineProperty(exports, '__InputValue', {
  8179. enumerable: true,
  8180. get: function get() {
  8181. return _introspection.__InputValue;
  8182. }
  8183. });
  8184. Object.defineProperty(exports, '__EnumValue', {
  8185. enumerable: true,
  8186. get: function get() {
  8187. return _introspection.__EnumValue;
  8188. }
  8189. });
  8190. Object.defineProperty(exports, '__TypeKind', {
  8191. enumerable: true,
  8192. get: function get() {
  8193. return _introspection.__TypeKind;
  8194. }
  8195. });
  8196. Object.defineProperty(exports, 'SchemaMetaFieldDef', {
  8197. enumerable: true,
  8198. get: function get() {
  8199. return _introspection.SchemaMetaFieldDef;
  8200. }
  8201. });
  8202. Object.defineProperty(exports, 'TypeMetaFieldDef', {
  8203. enumerable: true,
  8204. get: function get() {
  8205. return _introspection.TypeMetaFieldDef;
  8206. }
  8207. });
  8208. Object.defineProperty(exports, 'TypeNameMetaFieldDef', {
  8209. enumerable: true,
  8210. get: function get() {
  8211. return _introspection.TypeNameMetaFieldDef;
  8212. }
  8213. });
  8214. /***/ }),
  8215. /* 45 */
  8216. /***/ (function(module, exports, __webpack_require__) {
  8217. "use strict";
  8218. Object.defineProperty(exports, "__esModule", {
  8219. value: true
  8220. });
  8221. exports.buildClientSchema = buildClientSchema;
  8222. var _invariant = __webpack_require__(3);
  8223. var _invariant2 = _interopRequireDefault(_invariant);
  8224. var _keyMap = __webpack_require__(12);
  8225. var _keyMap2 = _interopRequireDefault(_keyMap);
  8226. var _keyValMap = __webpack_require__(21);
  8227. var _keyValMap2 = _interopRequireDefault(_keyValMap);
  8228. var _valueFromAST = __webpack_require__(16);
  8229. var _parser = __webpack_require__(17);
  8230. var _schema = __webpack_require__(8);
  8231. var _definition = __webpack_require__(1);
  8232. var _introspection = __webpack_require__(11);
  8233. var _scalars = __webpack_require__(7);
  8234. var _directives = __webpack_require__(5);
  8235. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  8236. /**
  8237. * Build a GraphQLSchema for use by client tools.
  8238. *
  8239. * Given the result of a client running the introspection query, creates and
  8240. * returns a GraphQLSchema instance which can be then used with all graphql-js
  8241. * tools, but cannot be used to execute a query, as introspection does not
  8242. * represent the "resolver", "parse" or "serialize" functions or any other
  8243. * server-internal mechanisms.
  8244. */
  8245. function buildClientSchema(introspection) {
  8246. // Get the schema from the introspection result.
  8247. var schemaIntrospection = introspection.__schema;
  8248. // Converts the list of types into a keyMap based on the type names.
  8249. var typeIntrospectionMap = (0, _keyMap2.default)(schemaIntrospection.types, function (type) {
  8250. return type.name;
  8251. });
  8252. // A cache to use to store the actual GraphQLType definition objects by name.
  8253. // Initialize to the GraphQL built in scalars. All functions below are inline
  8254. // so that this type def cache is within the scope of the closure.
  8255. var typeDefCache = {
  8256. String: _scalars.GraphQLString,
  8257. Int: _scalars.GraphQLInt,
  8258. Float: _scalars.GraphQLFloat,
  8259. Boolean: _scalars.GraphQLBoolean,
  8260. ID: _scalars.GraphQLID,
  8261. __Schema: _introspection.__Schema,
  8262. __Directive: _introspection.__Directive,
  8263. __DirectiveLocation: _introspection.__DirectiveLocation,
  8264. __Type: _introspection.__Type,
  8265. __Field: _introspection.__Field,
  8266. __InputValue: _introspection.__InputValue,
  8267. __EnumValue: _introspection.__EnumValue,
  8268. __TypeKind: _introspection.__TypeKind
  8269. };
  8270. // Given a type reference in introspection, return the GraphQLType instance.
  8271. // preferring cached instances before building new instances.
  8272. function getType(typeRef) {
  8273. if (typeRef.kind === _introspection.TypeKind.LIST) {
  8274. var itemRef = typeRef.ofType;
  8275. if (!itemRef) {
  8276. throw new Error('Decorated type deeper than introspection query.');
  8277. }
  8278. return new _definition.GraphQLList(getType(itemRef));
  8279. }
  8280. if (typeRef.kind === _introspection.TypeKind.NON_NULL) {
  8281. var nullableRef = typeRef.ofType;
  8282. if (!nullableRef) {
  8283. throw new Error('Decorated type deeper than introspection query.');
  8284. }
  8285. var nullableType = getType(nullableRef);
  8286. (0, _invariant2.default)(!(nullableType instanceof _definition.GraphQLNonNull), 'No nesting nonnull.');
  8287. return new _definition.GraphQLNonNull(nullableType);
  8288. }
  8289. return getNamedType(typeRef.name);
  8290. }
  8291. function getNamedType(typeName) {
  8292. if (typeDefCache[typeName]) {
  8293. return typeDefCache[typeName];
  8294. }
  8295. var typeIntrospection = typeIntrospectionMap[typeName];
  8296. if (!typeIntrospection) {
  8297. throw new Error('Invalid or incomplete schema, unknown type: ' + typeName + '. Ensure ' + 'that a full introspection query is used in order to build a ' + 'client schema.');
  8298. }
  8299. var typeDef = buildType(typeIntrospection);
  8300. typeDefCache[typeName] = typeDef;
  8301. return typeDef;
  8302. }
  8303. function getInputType(typeRef) {
  8304. var type = getType(typeRef);
  8305. (0, _invariant2.default)((0, _definition.isInputType)(type), 'Introspection must provide input type for arguments.');
  8306. return type;
  8307. }
  8308. function getOutputType(typeRef) {
  8309. var type = getType(typeRef);
  8310. (0, _invariant2.default)((0, _definition.isOutputType)(type), 'Introspection must provide output type for fields.');
  8311. return type;
  8312. }
  8313. function getObjectType(typeRef) {
  8314. var type = getType(typeRef);
  8315. (0, _invariant2.default)(type instanceof _definition.GraphQLObjectType, 'Introspection must provide object type for possibleTypes.');
  8316. return type;
  8317. }
  8318. function getInterfaceType(typeRef) {
  8319. var type = getType(typeRef);
  8320. (0, _invariant2.default)(type instanceof _definition.GraphQLInterfaceType, 'Introspection must provide interface type for interfaces.');
  8321. return type;
  8322. }
  8323. // Given a type's introspection result, construct the correct
  8324. // GraphQLType instance.
  8325. function buildType(type) {
  8326. switch (type.kind) {
  8327. case _introspection.TypeKind.SCALAR:
  8328. return buildScalarDef(type);
  8329. case _introspection.TypeKind.OBJECT:
  8330. return buildObjectDef(type);
  8331. case _introspection.TypeKind.INTERFACE:
  8332. return buildInterfaceDef(type);
  8333. case _introspection.TypeKind.UNION:
  8334. return buildUnionDef(type);
  8335. case _introspection.TypeKind.ENUM:
  8336. return buildEnumDef(type);
  8337. case _introspection.TypeKind.INPUT_OBJECT:
  8338. return buildInputObjectDef(type);
  8339. default:
  8340. throw new Error('Invalid or incomplete schema, unknown kind: ' + type.kind + '. Ensure ' + 'that a full introspection query is used in order to build a ' + 'client schema.');
  8341. }
  8342. }
  8343. function buildScalarDef(scalarIntrospection) {
  8344. return new _definition.GraphQLScalarType({
  8345. name: scalarIntrospection.name,
  8346. description: scalarIntrospection.description,
  8347. serialize: function serialize(id) {
  8348. return id;
  8349. },
  8350. // Note: validation calls the parse functions to determine if a
  8351. // literal value is correct. Returning null would cause use of custom
  8352. // scalars to always fail validation. Returning false causes them to
  8353. // always pass validation.
  8354. parseValue: function parseValue() {
  8355. return false;
  8356. },
  8357. parseLiteral: function parseLiteral() {
  8358. return false;
  8359. }
  8360. });
  8361. }
  8362. function buildObjectDef(objectIntrospection) {
  8363. return new _definition.GraphQLObjectType({
  8364. name: objectIntrospection.name,
  8365. description: objectIntrospection.description,
  8366. interfaces: objectIntrospection.interfaces.map(getInterfaceType),
  8367. fields: function fields() {
  8368. return buildFieldDefMap(objectIntrospection);
  8369. }
  8370. });
  8371. }
  8372. function buildInterfaceDef(interfaceIntrospection) {
  8373. return new _definition.GraphQLInterfaceType({
  8374. name: interfaceIntrospection.name,
  8375. description: interfaceIntrospection.description,
  8376. fields: function fields() {
  8377. return buildFieldDefMap(interfaceIntrospection);
  8378. },
  8379. resolveType: cannotExecuteClientSchema
  8380. });
  8381. }
  8382. function buildUnionDef(unionIntrospection) {
  8383. return new _definition.GraphQLUnionType({
  8384. name: unionIntrospection.name,
  8385. description: unionIntrospection.description,
  8386. types: unionIntrospection.possibleTypes.map(getObjectType),
  8387. resolveType: cannotExecuteClientSchema
  8388. });
  8389. }
  8390. function buildEnumDef(enumIntrospection) {
  8391. return new _definition.GraphQLEnumType({
  8392. name: enumIntrospection.name,
  8393. description: enumIntrospection.description,
  8394. values: (0, _keyValMap2.default)(enumIntrospection.enumValues, function (valueIntrospection) {
  8395. return valueIntrospection.name;
  8396. }, function (valueIntrospection) {
  8397. return {
  8398. description: valueIntrospection.description,
  8399. deprecationReason: valueIntrospection.deprecationReason
  8400. };
  8401. })
  8402. });
  8403. }
  8404. function buildInputObjectDef(inputObjectIntrospection) {
  8405. return new _definition.GraphQLInputObjectType({
  8406. name: inputObjectIntrospection.name,
  8407. description: inputObjectIntrospection.description,
  8408. fields: function fields() {
  8409. return buildInputValueDefMap(inputObjectIntrospection.inputFields);
  8410. }
  8411. });
  8412. }
  8413. function buildFieldDefMap(typeIntrospection) {
  8414. return (0, _keyValMap2.default)(typeIntrospection.fields, function (fieldIntrospection) {
  8415. return fieldIntrospection.name;
  8416. }, function (fieldIntrospection) {
  8417. return {
  8418. description: fieldIntrospection.description,
  8419. deprecationReason: fieldIntrospection.deprecationReason,
  8420. type: getOutputType(fieldIntrospection.type),
  8421. args: buildInputValueDefMap(fieldIntrospection.args)
  8422. };
  8423. });
  8424. }
  8425. function buildInputValueDefMap(inputValueIntrospections) {
  8426. return (0, _keyValMap2.default)(inputValueIntrospections, function (inputValue) {
  8427. return inputValue.name;
  8428. }, buildInputValue);
  8429. }
  8430. function buildInputValue(inputValueIntrospection) {
  8431. var type = getInputType(inputValueIntrospection.type);
  8432. var defaultValue = inputValueIntrospection.defaultValue ? (0, _valueFromAST.valueFromAST)((0, _parser.parseValue)(inputValueIntrospection.defaultValue), type) : undefined;
  8433. return {
  8434. name: inputValueIntrospection.name,
  8435. description: inputValueIntrospection.description,
  8436. type: type,
  8437. defaultValue: defaultValue
  8438. };
  8439. }
  8440. function buildDirective(directiveIntrospection) {
  8441. // Support deprecated `on****` fields for building `locations`, as this
  8442. // is used by GraphiQL which may need to support outdated servers.
  8443. var locations = directiveIntrospection.locations ? directiveIntrospection.locations.slice() : [].concat(!directiveIntrospection.onField ? [] : [_directives.DirectiveLocation.FIELD], !directiveIntrospection.onOperation ? [] : [_directives.DirectiveLocation.QUERY, _directives.DirectiveLocation.MUTATION, _directives.DirectiveLocation.SUBSCRIPTION], !directiveIntrospection.onFragment ? [] : [_directives.DirectiveLocation.FRAGMENT_DEFINITION, _directives.DirectiveLocation.FRAGMENT_SPREAD, _directives.DirectiveLocation.INLINE_FRAGMENT]);
  8444. return new _directives.GraphQLDirective({
  8445. name: directiveIntrospection.name,
  8446. description: directiveIntrospection.description,
  8447. locations: locations,
  8448. args: buildInputValueDefMap(directiveIntrospection.args)
  8449. });
  8450. }
  8451. // Iterate through all types, getting the type definition for each, ensuring
  8452. // that any type not directly referenced by a field will get created.
  8453. var types = schemaIntrospection.types.map(function (typeIntrospection) {
  8454. return getNamedType(typeIntrospection.name);
  8455. });
  8456. // Get the root Query, Mutation, and Subscription types.
  8457. var queryType = getObjectType(schemaIntrospection.queryType);
  8458. var mutationType = schemaIntrospection.mutationType ? getObjectType(schemaIntrospection.mutationType) : null;
  8459. var subscriptionType = schemaIntrospection.subscriptionType ? getObjectType(schemaIntrospection.subscriptionType) : null;
  8460. // Get the directives supported by Introspection, assuming empty-set if
  8461. // directives were not queried for.
  8462. var directives = schemaIntrospection.directives ? schemaIntrospection.directives.map(buildDirective) : [];
  8463. // Then produce and return a Schema with these types.
  8464. return new _schema.GraphQLSchema({
  8465. query: queryType,
  8466. mutation: mutationType,
  8467. subscription: subscriptionType,
  8468. types: types,
  8469. directives: directives
  8470. });
  8471. }
  8472. /**
  8473. * Copyright (c) 2015, Facebook, Inc.
  8474. * All rights reserved.
  8475. *
  8476. * This source code is licensed under the BSD-style license found in the
  8477. * LICENSE file in the root directory of this source tree. An additional grant
  8478. * of patent rights can be found in the PATENTS file in the same directory.
  8479. */
  8480. function cannotExecuteClientSchema() {
  8481. throw new Error('Client Schema cannot use Interface or Union types for execution.');
  8482. }
  8483. /***/ }),
  8484. /* 46 */
  8485. /***/ (function(module, exports, __webpack_require__) {
  8486. "use strict";
  8487. Object.defineProperty(exports, "__esModule", {
  8488. value: true
  8489. });
  8490. exports.concatAST = concatAST;
  8491. /**
  8492. * Provided a collection of ASTs, presumably each from different files,
  8493. * concatenate the ASTs together into batched AST, useful for validating many
  8494. * GraphQL source files which together represent one conceptual application.
  8495. */
  8496. function concatAST(asts) {
  8497. var batchDefinitions = [];
  8498. for (var i = 0; i < asts.length; i++) {
  8499. var definitions = asts[i].definitions;
  8500. for (var j = 0; j < definitions.length; j++) {
  8501. batchDefinitions.push(definitions[j]);
  8502. }
  8503. }
  8504. return {
  8505. kind: 'Document',
  8506. definitions: batchDefinitions
  8507. };
  8508. }
  8509. /**
  8510. * Copyright (c) 2015, Facebook, Inc.
  8511. * All rights reserved.
  8512. *
  8513. * This source code is licensed under the BSD-style license found in the
  8514. * LICENSE file in the root directory of this source tree. An additional grant
  8515. * of patent rights can be found in the PATENTS file in the same directory.
  8516. */
  8517. /***/ }),
  8518. /* 47 */
  8519. /***/ (function(module, exports, __webpack_require__) {
  8520. "use strict";
  8521. Object.defineProperty(exports, "__esModule", {
  8522. value: true
  8523. });
  8524. exports.extendSchema = extendSchema;
  8525. var _invariant = __webpack_require__(3);
  8526. var _invariant2 = _interopRequireDefault(_invariant);
  8527. var _keyMap = __webpack_require__(12);
  8528. var _keyMap2 = _interopRequireDefault(_keyMap);
  8529. var _keyValMap = __webpack_require__(21);
  8530. var _keyValMap2 = _interopRequireDefault(_keyValMap);
  8531. var _buildASTSchema = __webpack_require__(32);
  8532. var _valueFromAST = __webpack_require__(16);
  8533. var _GraphQLError = __webpack_require__(13);
  8534. var _schema = __webpack_require__(8);
  8535. var _definition = __webpack_require__(1);
  8536. var _directives = __webpack_require__(5);
  8537. var _introspection = __webpack_require__(11);
  8538. var _scalars = __webpack_require__(7);
  8539. var _kinds = __webpack_require__(2);
  8540. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  8541. /**
  8542. * Produces a new schema given an existing schema and a document which may
  8543. * contain GraphQL type extensions and definitions. The original schema will
  8544. * remain unaltered.
  8545. *
  8546. * Because a schema represents a graph of references, a schema cannot be
  8547. * extended without effectively making an entire copy. We do not know until it's
  8548. * too late if subgraphs remain unchanged.
  8549. *
  8550. * This algorithm copies the provided schema, applying extensions while
  8551. * producing the copy. The original schema remains unaltered.
  8552. */
  8553. /**
  8554. * Copyright (c) 2015, Facebook, Inc.
  8555. * All rights reserved.
  8556. *
  8557. * This source code is licensed under the BSD-style license found in the
  8558. * LICENSE file in the root directory of this source tree. An additional grant
  8559. * of patent rights can be found in the PATENTS file in the same directory.
  8560. */
  8561. function extendSchema(schema, documentAST) {
  8562. (0, _invariant2.default)(schema instanceof _schema.GraphQLSchema, 'Must provide valid GraphQLSchema');
  8563. (0, _invariant2.default)(documentAST && documentAST.kind === _kinds.DOCUMENT, 'Must provide valid Document AST');
  8564. // Collect the type definitions and extensions found in the document.
  8565. var typeDefinitionMap = {};
  8566. var typeExtensionsMap = {};
  8567. // New directives and types are separate because a directives and types can
  8568. // have the same name. For example, a type named "skip".
  8569. var directiveDefinitions = [];
  8570. for (var i = 0; i < documentAST.definitions.length; i++) {
  8571. var def = documentAST.definitions[i];
  8572. switch (def.kind) {
  8573. case _kinds.OBJECT_TYPE_DEFINITION:
  8574. case _kinds.INTERFACE_TYPE_DEFINITION:
  8575. case _kinds.ENUM_TYPE_DEFINITION:
  8576. case _kinds.UNION_TYPE_DEFINITION:
  8577. case _kinds.SCALAR_TYPE_DEFINITION:
  8578. case _kinds.INPUT_OBJECT_TYPE_DEFINITION:
  8579. // Sanity check that none of the defined types conflict with the
  8580. // schema's existing types.
  8581. var typeName = def.name.value;
  8582. if (schema.getType(typeName)) {
  8583. throw new _GraphQLError.GraphQLError('Type "' + typeName + '" already exists in the schema. It cannot also ' + 'be defined in this type definition.', [def]);
  8584. }
  8585. typeDefinitionMap[typeName] = def;
  8586. break;
  8587. case _kinds.TYPE_EXTENSION_DEFINITION:
  8588. // Sanity check that this type extension exists within the
  8589. // schema's existing types.
  8590. var extendedTypeName = def.definition.name.value;
  8591. var existingType = schema.getType(extendedTypeName);
  8592. if (!existingType) {
  8593. throw new _GraphQLError.GraphQLError('Cannot extend type "' + extendedTypeName + '" because it does not ' + 'exist in the existing schema.', [def.definition]);
  8594. }
  8595. if (!(existingType instanceof _definition.GraphQLObjectType)) {
  8596. throw new _GraphQLError.GraphQLError('Cannot extend non-object type "' + extendedTypeName + '".', [def.definition]);
  8597. }
  8598. var extensions = typeExtensionsMap[extendedTypeName];
  8599. if (extensions) {
  8600. extensions.push(def);
  8601. } else {
  8602. extensions = [def];
  8603. }
  8604. typeExtensionsMap[extendedTypeName] = extensions;
  8605. break;
  8606. case _kinds.DIRECTIVE_DEFINITION:
  8607. var directiveName = def.name.value;
  8608. var existingDirective = schema.getDirective(directiveName);
  8609. if (existingDirective) {
  8610. throw new _GraphQLError.GraphQLError('Directive "' + directiveName + '" already exists in the schema. It ' + 'cannot be redefined.', [def]);
  8611. }
  8612. directiveDefinitions.push(def);
  8613. break;
  8614. }
  8615. }
  8616. // If this document contains no new types, extensions, or directives then
  8617. // return the same unmodified GraphQLSchema instance.
  8618. if (Object.keys(typeExtensionsMap).length === 0 && Object.keys(typeDefinitionMap).length === 0 && directiveDefinitions.length === 0) {
  8619. return schema;
  8620. }
  8621. // A cache to use to store the actual GraphQLType definition objects by name.
  8622. // Initialize to the GraphQL built in scalars and introspection types. All
  8623. // functions below are inline so that this type def cache is within the scope
  8624. // of the closure.
  8625. var typeDefCache = {
  8626. String: _scalars.GraphQLString,
  8627. Int: _scalars.GraphQLInt,
  8628. Float: _scalars.GraphQLFloat,
  8629. Boolean: _scalars.GraphQLBoolean,
  8630. ID: _scalars.GraphQLID,
  8631. __Schema: _introspection.__Schema,
  8632. __Directive: _introspection.__Directive,
  8633. __DirectiveLocation: _introspection.__DirectiveLocation,
  8634. __Type: _introspection.__Type,
  8635. __Field: _introspection.__Field,
  8636. __InputValue: _introspection.__InputValue,
  8637. __EnumValue: _introspection.__EnumValue,
  8638. __TypeKind: _introspection.__TypeKind
  8639. };
  8640. // Get the root Query, Mutation, and Subscription object types.
  8641. var queryType = getTypeFromDef(schema.getQueryType());
  8642. var existingMutationType = schema.getMutationType();
  8643. var mutationType = existingMutationType ? getTypeFromDef(existingMutationType) : null;
  8644. var existingSubscriptionType = schema.getSubscriptionType();
  8645. var subscriptionType = existingSubscriptionType ? getTypeFromDef(existingSubscriptionType) : null;
  8646. // Iterate through all types, getting the type definition for each, ensuring
  8647. // that any type not directly referenced by a field will get created.
  8648. var typeMap = schema.getTypeMap();
  8649. var types = Object.keys(typeMap).map(function (typeName) {
  8650. return getTypeFromDef(typeMap[typeName]);
  8651. });
  8652. // Do the same with new types, appending to the list of defined types.
  8653. Object.keys(typeDefinitionMap).forEach(function (typeName) {
  8654. types.push(getTypeFromAST(typeDefinitionMap[typeName]));
  8655. });
  8656. // Then produce and return a Schema with these types.
  8657. return new _schema.GraphQLSchema({
  8658. query: queryType,
  8659. mutation: mutationType,
  8660. subscription: subscriptionType,
  8661. types: types,
  8662. directives: getMergedDirectives()
  8663. });
  8664. // Below are functions used for producing this schema that have closed over
  8665. // this scope and have access to the schema, cache, and newly defined types.
  8666. function getMergedDirectives() {
  8667. var existingDirectives = schema.getDirectives();
  8668. (0, _invariant2.default)(existingDirectives, 'schema must have default directives');
  8669. var newDirectives = directiveDefinitions.map(function (directiveNode) {
  8670. return getDirective(directiveNode);
  8671. });
  8672. return existingDirectives.concat(newDirectives);
  8673. }
  8674. function getTypeFromDef(typeDef) {
  8675. var type = _getNamedType(typeDef.name);
  8676. (0, _invariant2.default)(type, 'Missing type from schema');
  8677. return type;
  8678. }
  8679. function getTypeFromAST(node) {
  8680. var type = _getNamedType(node.name.value);
  8681. if (!type) {
  8682. throw new _GraphQLError.GraphQLError('Unknown type: "' + node.name.value + '". Ensure that this type exists ' + 'either in the original schema, or is added in a type definition.', [node]);
  8683. }
  8684. return type;
  8685. }
  8686. function getObjectTypeFromAST(node) {
  8687. var type = getTypeFromAST(node);
  8688. (0, _invariant2.default)(type instanceof _definition.GraphQLObjectType, 'Must be Object type.');
  8689. return type;
  8690. }
  8691. function getInterfaceTypeFromAST(node) {
  8692. var type = getTypeFromAST(node);
  8693. (0, _invariant2.default)(type instanceof _definition.GraphQLInterfaceType, 'Must be Interface type.');
  8694. return type;
  8695. }
  8696. function getInputTypeFromAST(node) {
  8697. var type = getTypeFromAST(node);
  8698. (0, _invariant2.default)((0, _definition.isInputType)(type), 'Must be Input type.');
  8699. return type;
  8700. }
  8701. function getOutputTypeFromAST(node) {
  8702. var type = getTypeFromAST(node);
  8703. (0, _invariant2.default)((0, _definition.isOutputType)(type), 'Must be Output type.');
  8704. return type;
  8705. }
  8706. // Given a name, returns a type from either the existing schema or an
  8707. // added type.
  8708. function _getNamedType(typeName) {
  8709. var cachedTypeDef = typeDefCache[typeName];
  8710. if (cachedTypeDef) {
  8711. return cachedTypeDef;
  8712. }
  8713. var existingType = schema.getType(typeName);
  8714. if (existingType) {
  8715. var typeDef = extendType(existingType);
  8716. typeDefCache[typeName] = typeDef;
  8717. return typeDef;
  8718. }
  8719. var typeNode = typeDefinitionMap[typeName];
  8720. if (typeNode) {
  8721. var _typeDef = buildType(typeNode);
  8722. typeDefCache[typeName] = _typeDef;
  8723. return _typeDef;
  8724. }
  8725. }
  8726. // Given a type's introspection result, construct the correct
  8727. // GraphQLType instance.
  8728. function extendType(type) {
  8729. if (type instanceof _definition.GraphQLObjectType) {
  8730. return extendObjectType(type);
  8731. }
  8732. if (type instanceof _definition.GraphQLInterfaceType) {
  8733. return extendInterfaceType(type);
  8734. }
  8735. if (type instanceof _definition.GraphQLUnionType) {
  8736. return extendUnionType(type);
  8737. }
  8738. return type;
  8739. }
  8740. function extendObjectType(type) {
  8741. return new _definition.GraphQLObjectType({
  8742. name: type.name,
  8743. description: type.description,
  8744. interfaces: function interfaces() {
  8745. return extendImplementedInterfaces(type);
  8746. },
  8747. fields: function fields() {
  8748. return extendFieldMap(type);
  8749. },
  8750. isTypeOf: type.isTypeOf
  8751. });
  8752. }
  8753. function extendInterfaceType(type) {
  8754. return new _definition.GraphQLInterfaceType({
  8755. name: type.name,
  8756. description: type.description,
  8757. fields: function fields() {
  8758. return extendFieldMap(type);
  8759. },
  8760. resolveType: type.resolveType
  8761. });
  8762. }
  8763. function extendUnionType(type) {
  8764. return new _definition.GraphQLUnionType({
  8765. name: type.name,
  8766. description: type.description,
  8767. types: type.getTypes().map(getTypeFromDef),
  8768. resolveType: type.resolveType
  8769. });
  8770. }
  8771. function extendImplementedInterfaces(type) {
  8772. var interfaces = type.getInterfaces().map(getTypeFromDef);
  8773. // If there are any extensions to the interfaces, apply those here.
  8774. var extensions = typeExtensionsMap[type.name];
  8775. if (extensions) {
  8776. extensions.forEach(function (extension) {
  8777. extension.definition.interfaces.forEach(function (namedType) {
  8778. var interfaceName = namedType.name.value;
  8779. if (interfaces.some(function (def) {
  8780. return def.name === interfaceName;
  8781. })) {
  8782. throw new _GraphQLError.GraphQLError('Type "' + type.name + '" already implements "' + interfaceName + '". ' + 'It cannot also be implemented in this type extension.', [namedType]);
  8783. }
  8784. interfaces.push(getInterfaceTypeFromAST(namedType));
  8785. });
  8786. });
  8787. }
  8788. return interfaces;
  8789. }
  8790. function extendFieldMap(type) {
  8791. var newFieldMap = {};
  8792. var oldFieldMap = type.getFields();
  8793. Object.keys(oldFieldMap).forEach(function (fieldName) {
  8794. var field = oldFieldMap[fieldName];
  8795. newFieldMap[fieldName] = {
  8796. description: field.description,
  8797. deprecationReason: field.deprecationReason,
  8798. type: extendFieldType(field.type),
  8799. args: (0, _keyMap2.default)(field.args, function (arg) {
  8800. return arg.name;
  8801. }),
  8802. resolve: field.resolve
  8803. };
  8804. });
  8805. // If there are any extensions to the fields, apply those here.
  8806. var extensions = typeExtensionsMap[type.name];
  8807. if (extensions) {
  8808. extensions.forEach(function (extension) {
  8809. extension.definition.fields.forEach(function (field) {
  8810. var fieldName = field.name.value;
  8811. if (oldFieldMap[fieldName]) {
  8812. throw new _GraphQLError.GraphQLError('Field "' + type.name + '.' + fieldName + '" already exists in the ' + 'schema. It cannot also be defined in this type extension.', [field]);
  8813. }
  8814. newFieldMap[fieldName] = {
  8815. description: (0, _buildASTSchema.getDescription)(field),
  8816. type: buildOutputFieldType(field.type),
  8817. args: buildInputValues(field.arguments)
  8818. };
  8819. });
  8820. });
  8821. }
  8822. return newFieldMap;
  8823. }
  8824. function extendFieldType(typeDef) {
  8825. if (typeDef instanceof _definition.GraphQLList) {
  8826. return new _definition.GraphQLList(extendFieldType(typeDef.ofType));
  8827. }
  8828. if (typeDef instanceof _definition.GraphQLNonNull) {
  8829. return new _definition.GraphQLNonNull(extendFieldType(typeDef.ofType));
  8830. }
  8831. return getTypeFromDef(typeDef);
  8832. }
  8833. function buildType(typeNode) {
  8834. switch (typeNode.kind) {
  8835. case _kinds.OBJECT_TYPE_DEFINITION:
  8836. return buildObjectType(typeNode);
  8837. case _kinds.INTERFACE_TYPE_DEFINITION:
  8838. return buildInterfaceType(typeNode);
  8839. case _kinds.UNION_TYPE_DEFINITION:
  8840. return buildUnionType(typeNode);
  8841. case _kinds.SCALAR_TYPE_DEFINITION:
  8842. return buildScalarType(typeNode);
  8843. case _kinds.ENUM_TYPE_DEFINITION:
  8844. return buildEnumType(typeNode);
  8845. case _kinds.INPUT_OBJECT_TYPE_DEFINITION:
  8846. return buildInputObjectType(typeNode);
  8847. }
  8848. throw new TypeError('Unknown type kind ' + typeNode.kind);
  8849. }
  8850. function buildObjectType(typeNode) {
  8851. return new _definition.GraphQLObjectType({
  8852. name: typeNode.name.value,
  8853. description: (0, _buildASTSchema.getDescription)(typeNode),
  8854. interfaces: function interfaces() {
  8855. return buildImplementedInterfaces(typeNode);
  8856. },
  8857. fields: function fields() {
  8858. return buildFieldMap(typeNode);
  8859. }
  8860. });
  8861. }
  8862. function buildInterfaceType(typeNode) {
  8863. return new _definition.GraphQLInterfaceType({
  8864. name: typeNode.name.value,
  8865. description: (0, _buildASTSchema.getDescription)(typeNode),
  8866. fields: function fields() {
  8867. return buildFieldMap(typeNode);
  8868. },
  8869. resolveType: cannotExecuteExtendedSchema
  8870. });
  8871. }
  8872. function buildUnionType(typeNode) {
  8873. return new _definition.GraphQLUnionType({
  8874. name: typeNode.name.value,
  8875. description: (0, _buildASTSchema.getDescription)(typeNode),
  8876. types: typeNode.types.map(getObjectTypeFromAST),
  8877. resolveType: cannotExecuteExtendedSchema
  8878. });
  8879. }
  8880. function buildScalarType(typeNode) {
  8881. return new _definition.GraphQLScalarType({
  8882. name: typeNode.name.value,
  8883. description: (0, _buildASTSchema.getDescription)(typeNode),
  8884. serialize: function serialize(id) {
  8885. return id;
  8886. },
  8887. // Note: validation calls the parse functions to determine if a
  8888. // literal value is correct. Returning null would cause use of custom
  8889. // scalars to always fail validation. Returning false causes them to
  8890. // always pass validation.
  8891. parseValue: function parseValue() {
  8892. return false;
  8893. },
  8894. parseLiteral: function parseLiteral() {
  8895. return false;
  8896. }
  8897. });
  8898. }
  8899. function buildEnumType(typeNode) {
  8900. return new _definition.GraphQLEnumType({
  8901. name: typeNode.name.value,
  8902. description: (0, _buildASTSchema.getDescription)(typeNode),
  8903. values: (0, _keyValMap2.default)(typeNode.values, function (v) {
  8904. return v.name.value;
  8905. }, function () {
  8906. return {};
  8907. })
  8908. });
  8909. }
  8910. function buildInputObjectType(typeNode) {
  8911. return new _definition.GraphQLInputObjectType({
  8912. name: typeNode.name.value,
  8913. description: (0, _buildASTSchema.getDescription)(typeNode),
  8914. fields: function fields() {
  8915. return buildInputValues(typeNode.fields);
  8916. }
  8917. });
  8918. }
  8919. function getDirective(directiveNode) {
  8920. return new _directives.GraphQLDirective({
  8921. name: directiveNode.name.value,
  8922. locations: directiveNode.locations.map(function (node) {
  8923. return node.value;
  8924. }),
  8925. args: directiveNode.arguments && buildInputValues(directiveNode.arguments)
  8926. });
  8927. }
  8928. function buildImplementedInterfaces(typeNode) {
  8929. return typeNode.interfaces && typeNode.interfaces.map(getInterfaceTypeFromAST);
  8930. }
  8931. function buildFieldMap(typeNode) {
  8932. return (0, _keyValMap2.default)(typeNode.fields, function (field) {
  8933. return field.name.value;
  8934. }, function (field) {
  8935. return {
  8936. type: buildOutputFieldType(field.type),
  8937. description: (0, _buildASTSchema.getDescription)(field),
  8938. args: buildInputValues(field.arguments)
  8939. };
  8940. });
  8941. }
  8942. function buildInputValues(values) {
  8943. return (0, _keyValMap2.default)(values, function (value) {
  8944. return value.name.value;
  8945. }, function (value) {
  8946. var type = buildInputFieldType(value.type);
  8947. return {
  8948. type: type,
  8949. description: (0, _buildASTSchema.getDescription)(value),
  8950. defaultValue: (0, _valueFromAST.valueFromAST)(value.defaultValue, type)
  8951. };
  8952. });
  8953. }
  8954. function buildInputFieldType(typeNode) {
  8955. if (typeNode.kind === _kinds.LIST_TYPE) {
  8956. return new _definition.GraphQLList(buildInputFieldType(typeNode.type));
  8957. }
  8958. if (typeNode.kind === _kinds.NON_NULL_TYPE) {
  8959. var nullableType = buildInputFieldType(typeNode.type);
  8960. (0, _invariant2.default)(!(nullableType instanceof _definition.GraphQLNonNull), 'Must be nullable');
  8961. return new _definition.GraphQLNonNull(nullableType);
  8962. }
  8963. return getInputTypeFromAST(typeNode);
  8964. }
  8965. function buildOutputFieldType(typeNode) {
  8966. if (typeNode.kind === _kinds.LIST_TYPE) {
  8967. return new _definition.GraphQLList(buildOutputFieldType(typeNode.type));
  8968. }
  8969. if (typeNode.kind === _kinds.NON_NULL_TYPE) {
  8970. var nullableType = buildOutputFieldType(typeNode.type);
  8971. (0, _invariant2.default)(!(nullableType instanceof _definition.GraphQLNonNull), 'Must be nullable');
  8972. return new _definition.GraphQLNonNull(nullableType);
  8973. }
  8974. return getOutputTypeFromAST(typeNode);
  8975. }
  8976. }
  8977. function cannotExecuteExtendedSchema() {
  8978. throw new Error('Extended Schema cannot use Interface or Union types for execution.');
  8979. }
  8980. /***/ }),
  8981. /* 48 */
  8982. /***/ (function(module, exports, __webpack_require__) {
  8983. "use strict";
  8984. Object.defineProperty(exports, "__esModule", {
  8985. value: true
  8986. });
  8987. exports.BreakingChangeType = undefined;
  8988. exports.findBreakingChanges = findBreakingChanges;
  8989. exports.findRemovedTypes = findRemovedTypes;
  8990. exports.findTypesThatChangedKind = findTypesThatChangedKind;
  8991. exports.findFieldsThatChangedType = findFieldsThatChangedType;
  8992. exports.findTypesRemovedFromUnions = findTypesRemovedFromUnions;
  8993. exports.findValuesRemovedFromEnums = findValuesRemovedFromEnums;
  8994. var _definition = __webpack_require__(1);
  8995. var _schema = __webpack_require__(8);
  8996. /**
  8997. * Copyright (c) 2016, Facebook, Inc.
  8998. * All rights reserved.
  8999. *
  9000. * This source code is licensed under the BSD-style license found in the
  9001. * LICENSE file in the root directory of this source tree. An additional grant
  9002. * of patent rights can be found in the PATENTS file in the same directory.
  9003. */
  9004. var BreakingChangeType = exports.BreakingChangeType = {
  9005. FIELD_CHANGED_KIND: 'FIELD_CHANGED_KIND',
  9006. FIELD_REMOVED: 'FIELD_REMOVED',
  9007. TYPE_CHANGED_KIND: 'TYPE_CHANGED_KIND',
  9008. TYPE_REMOVED: 'TYPE_REMOVED',
  9009. TYPE_REMOVED_FROM_UNION: 'TYPE_REMOVED_FROM_UNION',
  9010. VALUE_REMOVED_FROM_ENUM: 'VALUE_REMOVED_FROM_ENUM'
  9011. };
  9012. /**
  9013. * Given two schemas, returns an Array containing descriptions of all the types
  9014. * of breaking changes covered by the other functions down below.
  9015. */
  9016. function findBreakingChanges(oldSchema, newSchema) {
  9017. return [].concat(findRemovedTypes(oldSchema, newSchema), findTypesThatChangedKind(oldSchema, newSchema), findFieldsThatChangedType(oldSchema, newSchema), findTypesRemovedFromUnions(oldSchema, newSchema), findValuesRemovedFromEnums(oldSchema, newSchema));
  9018. }
  9019. /**
  9020. * Given two schemas, returns an Array containing descriptions of any breaking
  9021. * changes in the newSchema related to removing an entire type.
  9022. */
  9023. function findRemovedTypes(oldSchema, newSchema) {
  9024. var oldTypeMap = oldSchema.getTypeMap();
  9025. var newTypeMap = newSchema.getTypeMap();
  9026. var breakingChanges = [];
  9027. Object.keys(oldTypeMap).forEach(function (typeName) {
  9028. if (!newTypeMap[typeName]) {
  9029. breakingChanges.push({
  9030. type: BreakingChangeType.TYPE_REMOVED,
  9031. description: typeName + ' was removed.'
  9032. });
  9033. }
  9034. });
  9035. return breakingChanges;
  9036. }
  9037. /**
  9038. * Given two schemas, returns an Array containing descriptions of any breaking
  9039. * changes in the newSchema related to changing the type of a type.
  9040. */
  9041. function findTypesThatChangedKind(oldSchema, newSchema) {
  9042. var oldTypeMap = oldSchema.getTypeMap();
  9043. var newTypeMap = newSchema.getTypeMap();
  9044. var breakingChanges = [];
  9045. Object.keys(oldTypeMap).forEach(function (typeName) {
  9046. if (!newTypeMap[typeName]) {
  9047. return;
  9048. }
  9049. var oldType = oldTypeMap[typeName];
  9050. var newType = newTypeMap[typeName];
  9051. if (!(oldType instanceof newType.constructor)) {
  9052. breakingChanges.push({
  9053. type: BreakingChangeType.TYPE_CHANGED_KIND,
  9054. description: typeName + ' changed from ' + (typeKindName(oldType) + ' to ' + typeKindName(newType) + '.')
  9055. });
  9056. }
  9057. });
  9058. return breakingChanges;
  9059. }
  9060. function typeKindName(type) {
  9061. if (type instanceof _definition.GraphQLScalarType) {
  9062. return 'a Scalar type';
  9063. }
  9064. if (type instanceof _definition.GraphQLObjectType) {
  9065. return 'an Object type';
  9066. }
  9067. if (type instanceof _definition.GraphQLInterfaceType) {
  9068. return 'an Interface type';
  9069. }
  9070. if (type instanceof _definition.GraphQLUnionType) {
  9071. return 'a Union type';
  9072. }
  9073. if (type instanceof _definition.GraphQLEnumType) {
  9074. return 'an Enum type';
  9075. }
  9076. if (type instanceof _definition.GraphQLInputObjectType) {
  9077. return 'an Input type';
  9078. }
  9079. throw new TypeError('Unknown type ' + type.constructor.name);
  9080. }
  9081. /**
  9082. * Given two schemas, returns an Array containing descriptions of any breaking
  9083. * changes in the newSchema related to the fields on a type. This includes if
  9084. * a field has been removed from a type or if a field has changed type.
  9085. */
  9086. function findFieldsThatChangedType(oldSchema, newSchema) {
  9087. var oldTypeMap = oldSchema.getTypeMap();
  9088. var newTypeMap = newSchema.getTypeMap();
  9089. var breakingFieldChanges = [];
  9090. Object.keys(oldTypeMap).forEach(function (typeName) {
  9091. var oldType = oldTypeMap[typeName];
  9092. var newType = newTypeMap[typeName];
  9093. if (!(oldType instanceof _definition.GraphQLObjectType || oldType instanceof _definition.GraphQLInterfaceType || oldType instanceof _definition.GraphQLInputObjectType) || !(newType instanceof oldType.constructor)) {
  9094. return;
  9095. }
  9096. var oldTypeFieldsDef = oldType.getFields();
  9097. var newTypeFieldsDef = newType.getFields();
  9098. Object.keys(oldTypeFieldsDef).forEach(function (fieldName) {
  9099. // Check if the field is missing on the type in the new schema.
  9100. if (!(fieldName in newTypeFieldsDef)) {
  9101. breakingFieldChanges.push({
  9102. type: BreakingChangeType.FIELD_REMOVED,
  9103. description: typeName + '.' + fieldName + ' was removed.'
  9104. });
  9105. } else {
  9106. // Check if the field's type has changed in the new schema.
  9107. var oldFieldType = (0, _definition.getNamedType)(oldTypeFieldsDef[fieldName].type);
  9108. var newFieldType = (0, _definition.getNamedType)(newTypeFieldsDef[fieldName].type);
  9109. if (oldFieldType && newFieldType && oldFieldType.name !== newFieldType.name) {
  9110. breakingFieldChanges.push({
  9111. type: BreakingChangeType.FIELD_CHANGED_KIND,
  9112. description: typeName + '.' + fieldName + ' changed type from ' + (oldFieldType.name + ' to ' + newFieldType.name + '.')
  9113. });
  9114. }
  9115. }
  9116. });
  9117. });
  9118. return breakingFieldChanges;
  9119. }
  9120. /**
  9121. * Given two schemas, returns an Array containing descriptions of any breaking
  9122. * changes in the newSchema related to removing types from a union type.
  9123. */
  9124. function findTypesRemovedFromUnions(oldSchema, newSchema) {
  9125. var oldTypeMap = oldSchema.getTypeMap();
  9126. var newTypeMap = newSchema.getTypeMap();
  9127. var typesRemovedFromUnion = [];
  9128. Object.keys(oldTypeMap).forEach(function (typeName) {
  9129. var oldType = oldTypeMap[typeName];
  9130. var newType = newTypeMap[typeName];
  9131. if (!(oldType instanceof _definition.GraphQLUnionType) || !(newType instanceof _definition.GraphQLUnionType)) {
  9132. return;
  9133. }
  9134. var typeNamesInNewUnion = Object.create(null);
  9135. newType.getTypes().forEach(function (type) {
  9136. typeNamesInNewUnion[type.name] = true;
  9137. });
  9138. oldType.getTypes().forEach(function (type) {
  9139. if (!typeNamesInNewUnion[type.name]) {
  9140. typesRemovedFromUnion.push({
  9141. type: BreakingChangeType.TYPE_REMOVED_FROM_UNION,
  9142. description: type.name + ' was removed from union type ' + typeName + '.'
  9143. });
  9144. }
  9145. });
  9146. });
  9147. return typesRemovedFromUnion;
  9148. }
  9149. /**
  9150. * Given two schemas, returns an Array containing descriptions of any breaking
  9151. * changes in the newSchema related to removing values from an enum type.
  9152. */
  9153. function findValuesRemovedFromEnums(oldSchema, newSchema) {
  9154. var oldTypeMap = oldSchema.getTypeMap();
  9155. var newTypeMap = newSchema.getTypeMap();
  9156. var valuesRemovedFromEnums = [];
  9157. Object.keys(oldTypeMap).forEach(function (typeName) {
  9158. var oldType = oldTypeMap[typeName];
  9159. var newType = newTypeMap[typeName];
  9160. if (!(oldType instanceof _definition.GraphQLEnumType) || !(newType instanceof _definition.GraphQLEnumType)) {
  9161. return;
  9162. }
  9163. var valuesInNewEnum = Object.create(null);
  9164. newType.getValues().forEach(function (value) {
  9165. valuesInNewEnum[value.name] = true;
  9166. });
  9167. oldType.getValues().forEach(function (value) {
  9168. if (!valuesInNewEnum[value.name]) {
  9169. valuesRemovedFromEnums.push({
  9170. type: BreakingChangeType.VALUE_REMOVED_FROM_ENUM,
  9171. description: value.name + ' was removed from enum type ' + typeName + '.'
  9172. });
  9173. }
  9174. });
  9175. });
  9176. return valuesRemovedFromEnums;
  9177. }
  9178. /***/ }),
  9179. /* 49 */
  9180. /***/ (function(module, exports, __webpack_require__) {
  9181. "use strict";
  9182. Object.defineProperty(exports, "__esModule", {
  9183. value: true
  9184. });
  9185. exports.findDeprecatedUsages = findDeprecatedUsages;
  9186. var _GraphQLError = __webpack_require__(13);
  9187. var _visitor = __webpack_require__(15);
  9188. var _definition = __webpack_require__(1);
  9189. var _schema = __webpack_require__(8);
  9190. var _TypeInfo = __webpack_require__(27);
  9191. /**
  9192. * A validation rule which reports deprecated usages.
  9193. *
  9194. * Returns a list of GraphQLError instances describing each deprecated use.
  9195. */
  9196. function findDeprecatedUsages(schema, ast) {
  9197. var errors = [];
  9198. var typeInfo = new _TypeInfo.TypeInfo(schema);
  9199. (0, _visitor.visit)(ast, (0, _visitor.visitWithTypeInfo)(typeInfo, {
  9200. Field: function Field(node) {
  9201. var fieldDef = typeInfo.getFieldDef();
  9202. if (fieldDef && fieldDef.isDeprecated) {
  9203. var parentType = typeInfo.getParentType();
  9204. if (parentType) {
  9205. var reason = fieldDef.deprecationReason;
  9206. errors.push(new _GraphQLError.GraphQLError('The field ' + parentType.name + '.' + fieldDef.name + ' is deprecated.' + (reason ? ' ' + reason : ''), [node]));
  9207. }
  9208. }
  9209. },
  9210. EnumValue: function EnumValue(node) {
  9211. var enumVal = typeInfo.getEnumValue();
  9212. if (enumVal && enumVal.isDeprecated) {
  9213. var type = (0, _definition.getNamedType)(typeInfo.getInputType());
  9214. if (type) {
  9215. var reason = enumVal.deprecationReason;
  9216. errors.push(new _GraphQLError.GraphQLError('The enum value ' + type.name + '.' + enumVal.name + ' is deprecated.' + (reason ? ' ' + reason : ''), [node]));
  9217. }
  9218. }
  9219. }
  9220. }));
  9221. return errors;
  9222. }
  9223. /**
  9224. * Copyright (c) Facebook, Inc.
  9225. * All rights reserved.
  9226. *
  9227. * This source code is licensed under the BSD-style license found in the
  9228. * LICENSE file in the root directory of this source tree. An additional grant
  9229. * of patent rights can be found in the PATENTS file in the same directory.
  9230. */
  9231. /***/ }),
  9232. /* 50 */
  9233. /***/ (function(module, exports, __webpack_require__) {
  9234. "use strict";
  9235. Object.defineProperty(exports, "__esModule", {
  9236. value: true
  9237. });
  9238. exports.getOperationAST = getOperationAST;
  9239. var _kinds = __webpack_require__(2);
  9240. /**
  9241. * Returns an operation AST given a document AST and optionally an operation
  9242. * name. If a name is not provided, an operation is only returned if only one is
  9243. * provided in the document.
  9244. */
  9245. function getOperationAST(documentAST, operationName) {
  9246. var operation = null;
  9247. for (var i = 0; i < documentAST.definitions.length; i++) {
  9248. var definition = documentAST.definitions[i];
  9249. if (definition.kind === _kinds.OPERATION_DEFINITION) {
  9250. if (!operationName) {
  9251. // If no operation name was provided, only return an Operation if there
  9252. // is one defined in the document. Upon encountering the second, return
  9253. // null.
  9254. if (operation) {
  9255. return null;
  9256. }
  9257. operation = definition;
  9258. } else if (definition.name && definition.name.value === operationName) {
  9259. return definition;
  9260. }
  9261. }
  9262. }
  9263. return operation;
  9264. }
  9265. /**
  9266. * Copyright (c) 2015, Facebook, Inc.
  9267. * All rights reserved.
  9268. *
  9269. * This source code is licensed under the BSD-style license found in the
  9270. * LICENSE file in the root directory of this source tree. An additional grant
  9271. * of patent rights can be found in the PATENTS file in the same directory.
  9272. */
  9273. /***/ }),
  9274. /* 51 */
  9275. /***/ (function(module, exports, __webpack_require__) {
  9276. "use strict";
  9277. Object.defineProperty(exports, "__esModule", {
  9278. value: true
  9279. });
  9280. var _introspectionQuery = __webpack_require__(52);
  9281. Object.defineProperty(exports, 'introspectionQuery', {
  9282. enumerable: true,
  9283. get: function get() {
  9284. return _introspectionQuery.introspectionQuery;
  9285. }
  9286. });
  9287. var _getOperationAST = __webpack_require__(50);
  9288. Object.defineProperty(exports, 'getOperationAST', {
  9289. enumerable: true,
  9290. get: function get() {
  9291. return _getOperationAST.getOperationAST;
  9292. }
  9293. });
  9294. var _buildClientSchema = __webpack_require__(45);
  9295. Object.defineProperty(exports, 'buildClientSchema', {
  9296. enumerable: true,
  9297. get: function get() {
  9298. return _buildClientSchema.buildClientSchema;
  9299. }
  9300. });
  9301. var _buildASTSchema = __webpack_require__(32);
  9302. Object.defineProperty(exports, 'buildASTSchema', {
  9303. enumerable: true,
  9304. get: function get() {
  9305. return _buildASTSchema.buildASTSchema;
  9306. }
  9307. });
  9308. Object.defineProperty(exports, 'buildSchema', {
  9309. enumerable: true,
  9310. get: function get() {
  9311. return _buildASTSchema.buildSchema;
  9312. }
  9313. });
  9314. var _extendSchema = __webpack_require__(47);
  9315. Object.defineProperty(exports, 'extendSchema', {
  9316. enumerable: true,
  9317. get: function get() {
  9318. return _extendSchema.extendSchema;
  9319. }
  9320. });
  9321. var _schemaPrinter = __webpack_require__(53);
  9322. Object.defineProperty(exports, 'printSchema', {
  9323. enumerable: true,
  9324. get: function get() {
  9325. return _schemaPrinter.printSchema;
  9326. }
  9327. });
  9328. Object.defineProperty(exports, 'printType', {
  9329. enumerable: true,
  9330. get: function get() {
  9331. return _schemaPrinter.printType;
  9332. }
  9333. });
  9334. Object.defineProperty(exports, 'printIntrospectionSchema', {
  9335. enumerable: true,
  9336. get: function get() {
  9337. return _schemaPrinter.printIntrospectionSchema;
  9338. }
  9339. });
  9340. var _typeFromAST = __webpack_require__(9);
  9341. Object.defineProperty(exports, 'typeFromAST', {
  9342. enumerable: true,
  9343. get: function get() {
  9344. return _typeFromAST.typeFromAST;
  9345. }
  9346. });
  9347. var _valueFromAST = __webpack_require__(16);
  9348. Object.defineProperty(exports, 'valueFromAST', {
  9349. enumerable: true,
  9350. get: function get() {
  9351. return _valueFromAST.valueFromAST;
  9352. }
  9353. });
  9354. var _astFromValue = __webpack_require__(29);
  9355. Object.defineProperty(exports, 'astFromValue', {
  9356. enumerable: true,
  9357. get: function get() {
  9358. return _astFromValue.astFromValue;
  9359. }
  9360. });
  9361. var _TypeInfo = __webpack_require__(27);
  9362. Object.defineProperty(exports, 'TypeInfo', {
  9363. enumerable: true,
  9364. get: function get() {
  9365. return _TypeInfo.TypeInfo;
  9366. }
  9367. });
  9368. var _isValidJSValue = __webpack_require__(33);
  9369. Object.defineProperty(exports, 'isValidJSValue', {
  9370. enumerable: true,
  9371. get: function get() {
  9372. return _isValidJSValue.isValidJSValue;
  9373. }
  9374. });
  9375. var _isValidLiteralValue = __webpack_require__(18);
  9376. Object.defineProperty(exports, 'isValidLiteralValue', {
  9377. enumerable: true,
  9378. get: function get() {
  9379. return _isValidLiteralValue.isValidLiteralValue;
  9380. }
  9381. });
  9382. var _concatAST = __webpack_require__(46);
  9383. Object.defineProperty(exports, 'concatAST', {
  9384. enumerable: true,
  9385. get: function get() {
  9386. return _concatAST.concatAST;
  9387. }
  9388. });
  9389. var _separateOperations = __webpack_require__(54);
  9390. Object.defineProperty(exports, 'separateOperations', {
  9391. enumerable: true,
  9392. get: function get() {
  9393. return _separateOperations.separateOperations;
  9394. }
  9395. });
  9396. var _typeComparators = __webpack_require__(19);
  9397. Object.defineProperty(exports, 'isEqualType', {
  9398. enumerable: true,
  9399. get: function get() {
  9400. return _typeComparators.isEqualType;
  9401. }
  9402. });
  9403. Object.defineProperty(exports, 'isTypeSubTypeOf', {
  9404. enumerable: true,
  9405. get: function get() {
  9406. return _typeComparators.isTypeSubTypeOf;
  9407. }
  9408. });
  9409. Object.defineProperty(exports, 'doTypesOverlap', {
  9410. enumerable: true,
  9411. get: function get() {
  9412. return _typeComparators.doTypesOverlap;
  9413. }
  9414. });
  9415. var _assertValidName = __webpack_require__(28);
  9416. Object.defineProperty(exports, 'assertValidName', {
  9417. enumerable: true,
  9418. get: function get() {
  9419. return _assertValidName.assertValidName;
  9420. }
  9421. });
  9422. var _findBreakingChanges = __webpack_require__(48);
  9423. Object.defineProperty(exports, 'findBreakingChanges', {
  9424. enumerable: true,
  9425. get: function get() {
  9426. return _findBreakingChanges.findBreakingChanges;
  9427. }
  9428. });
  9429. var _findDeprecatedUsages = __webpack_require__(49);
  9430. Object.defineProperty(exports, 'findDeprecatedUsages', {
  9431. enumerable: true,
  9432. get: function get() {
  9433. return _findDeprecatedUsages.findDeprecatedUsages;
  9434. }
  9435. });
  9436. /***/ }),
  9437. /* 52 */
  9438. /***/ (function(module, exports, __webpack_require__) {
  9439. "use strict";
  9440. Object.defineProperty(exports, "__esModule", {
  9441. value: true
  9442. });
  9443. var introspectionQuery = exports.introspectionQuery = '\n query IntrospectionQuery {\n __schema {\n queryType { name }\n mutationType { name }\n subscriptionType { name }\n types {\n ...FullType\n }\n directives {\n name\n description\n locations\n args {\n ...InputValue\n }\n }\n }\n }\n\n fragment FullType on __Type {\n kind\n name\n description\n fields(includeDeprecated: true) {\n name\n description\n args {\n ...InputValue\n }\n type {\n ...TypeRef\n }\n isDeprecated\n deprecationReason\n }\n inputFields {\n ...InputValue\n }\n interfaces {\n ...TypeRef\n }\n enumValues(includeDeprecated: true) {\n name\n description\n isDeprecated\n deprecationReason\n }\n possibleTypes {\n ...TypeRef\n }\n }\n\n fragment InputValue on __InputValue {\n name\n description\n type { ...TypeRef }\n defaultValue\n }\n\n fragment TypeRef on __Type {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n ofType {\n kind\n name\n }\n }\n }\n }\n }\n }\n }\n }\n';
  9444. /**
  9445. * Copyright (c) 2015, Facebook, Inc.
  9446. * All rights reserved.
  9447. *
  9448. * This source code is licensed under the BSD-style license found in the
  9449. * LICENSE file in the root directory of this source tree. An additional grant
  9450. * of patent rights can be found in the PATENTS file in the same directory.
  9451. */
  9452. /***/ }),
  9453. /* 53 */
  9454. /***/ (function(module, exports, __webpack_require__) {
  9455. "use strict";
  9456. Object.defineProperty(exports, "__esModule", {
  9457. value: true
  9458. });
  9459. exports.printSchema = printSchema;
  9460. exports.printIntrospectionSchema = printIntrospectionSchema;
  9461. exports.printType = printType;
  9462. var _invariant = __webpack_require__(3);
  9463. var _invariant2 = _interopRequireDefault(_invariant);
  9464. var _isNullish = __webpack_require__(6);
  9465. var _isNullish2 = _interopRequireDefault(_isNullish);
  9466. var _isInvalid = __webpack_require__(14);
  9467. var _isInvalid2 = _interopRequireDefault(_isInvalid);
  9468. var _astFromValue = __webpack_require__(29);
  9469. var _printer = __webpack_require__(4);
  9470. var _definition = __webpack_require__(1);
  9471. var _scalars = __webpack_require__(7);
  9472. var _directives = __webpack_require__(5);
  9473. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  9474. /**
  9475. * Copyright (c) 2015, Facebook, Inc.
  9476. * All rights reserved.
  9477. *
  9478. * This source code is licensed under the BSD-style license found in the
  9479. * LICENSE file in the root directory of this source tree. An additional grant
  9480. * of patent rights can be found in the PATENTS file in the same directory.
  9481. */
  9482. function printSchema(schema) {
  9483. return printFilteredSchema(schema, function (n) {
  9484. return !isSpecDirective(n);
  9485. }, isDefinedType);
  9486. }
  9487. function printIntrospectionSchema(schema) {
  9488. return printFilteredSchema(schema, isSpecDirective, isIntrospectionType);
  9489. }
  9490. function isSpecDirective(directiveName) {
  9491. return directiveName === 'skip' || directiveName === 'include' || directiveName === 'deprecated';
  9492. }
  9493. function isDefinedType(typename) {
  9494. return !isIntrospectionType(typename) && !isBuiltInScalar(typename);
  9495. }
  9496. function isIntrospectionType(typename) {
  9497. return typename.indexOf('__') === 0;
  9498. }
  9499. function isBuiltInScalar(typename) {
  9500. return typename === 'String' || typename === 'Boolean' || typename === 'Int' || typename === 'Float' || typename === 'ID';
  9501. }
  9502. function printFilteredSchema(schema, directiveFilter, typeFilter) {
  9503. var directives = schema.getDirectives().filter(function (directive) {
  9504. return directiveFilter(directive.name);
  9505. });
  9506. var typeMap = schema.getTypeMap();
  9507. var types = Object.keys(typeMap).filter(typeFilter).sort(function (name1, name2) {
  9508. return name1.localeCompare(name2);
  9509. }).map(function (typeName) {
  9510. return typeMap[typeName];
  9511. });
  9512. return [printSchemaDefinition(schema)].concat(directives.map(printDirective), types.map(printType)).filter(Boolean).join('\n\n') + '\n';
  9513. }
  9514. function printSchemaDefinition(schema) {
  9515. if (isSchemaOfCommonNames(schema)) {
  9516. return;
  9517. }
  9518. var operationTypes = [];
  9519. var queryType = schema.getQueryType();
  9520. if (queryType) {
  9521. operationTypes.push(' query: ' + queryType.name);
  9522. }
  9523. var mutationType = schema.getMutationType();
  9524. if (mutationType) {
  9525. operationTypes.push(' mutation: ' + mutationType.name);
  9526. }
  9527. var subscriptionType = schema.getSubscriptionType();
  9528. if (subscriptionType) {
  9529. operationTypes.push(' subscription: ' + subscriptionType.name);
  9530. }
  9531. return 'schema {\n' + operationTypes.join('\n') + '\n}';
  9532. }
  9533. /**
  9534. * GraphQL schema define root types for each type of operation. These types are
  9535. * the same as any other type and can be named in any manner, however there is
  9536. * a common naming convention:
  9537. *
  9538. * schema {
  9539. * query: Query
  9540. * mutation: Mutation
  9541. * }
  9542. *
  9543. * When using this naming convention, the schema description can be omitted.
  9544. */
  9545. function isSchemaOfCommonNames(schema) {
  9546. var queryType = schema.getQueryType();
  9547. if (queryType && queryType.name !== 'Query') {
  9548. return false;
  9549. }
  9550. var mutationType = schema.getMutationType();
  9551. if (mutationType && mutationType.name !== 'Mutation') {
  9552. return false;
  9553. }
  9554. var subscriptionType = schema.getSubscriptionType();
  9555. if (subscriptionType && subscriptionType.name !== 'Subscription') {
  9556. return false;
  9557. }
  9558. return true;
  9559. }
  9560. function printType(type) {
  9561. if (type instanceof _definition.GraphQLScalarType) {
  9562. return printScalar(type);
  9563. } else if (type instanceof _definition.GraphQLObjectType) {
  9564. return printObject(type);
  9565. } else if (type instanceof _definition.GraphQLInterfaceType) {
  9566. return printInterface(type);
  9567. } else if (type instanceof _definition.GraphQLUnionType) {
  9568. return printUnion(type);
  9569. } else if (type instanceof _definition.GraphQLEnumType) {
  9570. return printEnum(type);
  9571. }
  9572. (0, _invariant2.default)(type instanceof _definition.GraphQLInputObjectType);
  9573. return printInputObject(type);
  9574. }
  9575. function printScalar(type) {
  9576. return printDescription(type) + ('scalar ' + type.name);
  9577. }
  9578. function printObject(type) {
  9579. var interfaces = type.getInterfaces();
  9580. var implementedInterfaces = interfaces.length ? ' implements ' + interfaces.map(function (i) {
  9581. return i.name;
  9582. }).join(', ') : '';
  9583. return printDescription(type) + ('type ' + type.name + implementedInterfaces + ' {\n') + printFields(type) + '\n' + '}';
  9584. }
  9585. function printInterface(type) {
  9586. return printDescription(type) + ('interface ' + type.name + ' {\n') + printFields(type) + '\n' + '}';
  9587. }
  9588. function printUnion(type) {
  9589. return printDescription(type) + ('union ' + type.name + ' = ' + type.getTypes().join(' | '));
  9590. }
  9591. function printEnum(type) {
  9592. return printDescription(type) + ('enum ' + type.name + ' {\n') + printEnumValues(type.getValues()) + '\n' + '}';
  9593. }
  9594. function printEnumValues(values) {
  9595. return values.map(function (value, i) {
  9596. return printDescription(value, ' ', !i) + ' ' + value.name + printDeprecated(value);
  9597. }).join('\n');
  9598. }
  9599. function printInputObject(type) {
  9600. var fieldMap = type.getFields();
  9601. var fields = Object.keys(fieldMap).map(function (fieldName) {
  9602. return fieldMap[fieldName];
  9603. });
  9604. return printDescription(type) + ('input ' + type.name + ' {\n') + fields.map(function (f, i) {
  9605. return printDescription(f, ' ', !i) + ' ' + printInputValue(f);
  9606. }).join('\n') + '\n' + '}';
  9607. }
  9608. function printFields(type) {
  9609. var fieldMap = type.getFields();
  9610. var fields = Object.keys(fieldMap).map(function (fieldName) {
  9611. return fieldMap[fieldName];
  9612. });
  9613. return fields.map(function (f, i) {
  9614. return printDescription(f, ' ', !i) + ' ' + f.name + printArgs(f.args, ' ') + ': ' + String(f.type) + printDeprecated(f);
  9615. }).join('\n');
  9616. }
  9617. function printArgs(args) {
  9618. var indentation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  9619. if (args.length === 0) {
  9620. return '';
  9621. }
  9622. // If every arg does not have a description, print them on one line.
  9623. if (args.every(function (arg) {
  9624. return !arg.description;
  9625. })) {
  9626. return '(' + args.map(printInputValue).join(', ') + ')';
  9627. }
  9628. return '(\n' + args.map(function (arg, i) {
  9629. return printDescription(arg, ' ' + indentation, !i) + ' ' + indentation + printInputValue(arg);
  9630. }).join('\n') + '\n' + indentation + ')';
  9631. }
  9632. function printInputValue(arg) {
  9633. var argDecl = arg.name + ': ' + String(arg.type);
  9634. if (!(0, _isInvalid2.default)(arg.defaultValue)) {
  9635. argDecl += ' = ' + (0, _printer.print)((0, _astFromValue.astFromValue)(arg.defaultValue, arg.type));
  9636. }
  9637. return argDecl;
  9638. }
  9639. function printDirective(directive) {
  9640. return printDescription(directive) + 'directive @' + directive.name + printArgs(directive.args) + ' on ' + directive.locations.join(' | ');
  9641. }
  9642. function printDeprecated(fieldOrEnumVal) {
  9643. var reason = fieldOrEnumVal.deprecationReason;
  9644. if ((0, _isNullish2.default)(reason)) {
  9645. return '';
  9646. }
  9647. if (reason === '' || reason === _directives.DEFAULT_DEPRECATION_REASON) {
  9648. return ' @deprecated';
  9649. }
  9650. return ' @deprecated(reason: ' + (0, _printer.print)((0, _astFromValue.astFromValue)(reason, _scalars.GraphQLString)) + ')';
  9651. }
  9652. function printDescription(def) {
  9653. var indentation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
  9654. var firstInBlock = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  9655. if (!def.description) {
  9656. return '';
  9657. }
  9658. var lines = def.description.split('\n');
  9659. var description = indentation && !firstInBlock ? '\n' : '';
  9660. for (var i = 0; i < lines.length; i++) {
  9661. if (lines[i] === '') {
  9662. description += indentation + '#\n';
  9663. } else {
  9664. // For > 120 character long lines, cut at space boundaries into sublines
  9665. // of ~80 chars.
  9666. var sublines = breakLine(lines[i], 120 - indentation.length);
  9667. for (var j = 0; j < sublines.length; j++) {
  9668. description += indentation + '# ' + sublines[j] + '\n';
  9669. }
  9670. }
  9671. }
  9672. return description;
  9673. }
  9674. function breakLine(line, len) {
  9675. if (line.length < len + 5) {
  9676. return [line];
  9677. }
  9678. var parts = line.split(new RegExp('((?: |^).{15,' + (len - 40) + '}(?= |$))'));
  9679. if (parts.length < 4) {
  9680. return [line];
  9681. }
  9682. var sublines = [parts[0] + parts[1] + parts[2]];
  9683. for (var i = 3; i < parts.length; i += 2) {
  9684. sublines.push(parts[i].slice(1) + parts[i + 1]);
  9685. }
  9686. return sublines;
  9687. }
  9688. /***/ }),
  9689. /* 54 */
  9690. /***/ (function(module, exports, __webpack_require__) {
  9691. "use strict";
  9692. Object.defineProperty(exports, "__esModule", {
  9693. value: true
  9694. });
  9695. exports.separateOperations = separateOperations;
  9696. var _visitor = __webpack_require__(15);
  9697. /**
  9698. * separateOperations accepts a single AST document which may contain many
  9699. * operations and fragments and returns a collection of AST documents each of
  9700. * which contains a single operation as well the fragment definitions it
  9701. * refers to.
  9702. */
  9703. function separateOperations(documentAST) {
  9704. var operations = [];
  9705. var depGraph = Object.create(null);
  9706. var fromName = void 0;
  9707. // Populate the list of operations and build a dependency graph.
  9708. (0, _visitor.visit)(documentAST, {
  9709. OperationDefinition: function OperationDefinition(node) {
  9710. operations.push(node);
  9711. fromName = opName(node);
  9712. },
  9713. FragmentDefinition: function FragmentDefinition(node) {
  9714. fromName = node.name.value;
  9715. },
  9716. FragmentSpread: function FragmentSpread(node) {
  9717. var toName = node.name.value;
  9718. (depGraph[fromName] || (depGraph[fromName] = Object.create(null)))[toName] = true;
  9719. }
  9720. });
  9721. // For each operation, produce a new synthesized AST which includes only what
  9722. // is necessary for completing that operation.
  9723. var separatedDocumentASTs = Object.create(null);
  9724. operations.forEach(function (operation) {
  9725. var operationName = opName(operation);
  9726. var dependencies = Object.create(null);
  9727. collectTransitiveDependencies(dependencies, depGraph, operationName);
  9728. separatedDocumentASTs[operationName] = {
  9729. kind: 'Document',
  9730. definitions: documentAST.definitions.filter(function (def) {
  9731. return def === operation || def.kind === 'FragmentDefinition' && dependencies[def.name.value];
  9732. })
  9733. };
  9734. });
  9735. return separatedDocumentASTs;
  9736. }
  9737. /**
  9738. * Copyright (c) 2015, Facebook, Inc.
  9739. * All rights reserved.
  9740. *
  9741. * This source code is licensed under the BSD-style license found in the
  9742. * LICENSE file in the root directory of this source tree. An additional grant
  9743. * of patent rights can be found in the PATENTS file in the same directory.
  9744. */
  9745. // Provides the empty string for anonymous operations.
  9746. function opName(operation) {
  9747. return operation.name ? operation.name.value : '';
  9748. }
  9749. // From a dependency graph, collects a list of transitive dependencies by
  9750. // recursing through a dependency graph.
  9751. function collectTransitiveDependencies(collected, depGraph, fromName) {
  9752. var immediateDeps = depGraph[fromName];
  9753. if (immediateDeps) {
  9754. Object.keys(immediateDeps).forEach(function (toName) {
  9755. if (!collected[toName]) {
  9756. collected[toName] = true;
  9757. collectTransitiveDependencies(collected, depGraph, toName);
  9758. }
  9759. });
  9760. }
  9761. }
  9762. /***/ }),
  9763. /* 55 */
  9764. /***/ (function(module, exports, __webpack_require__) {
  9765. "use strict";
  9766. Object.defineProperty(exports, "__esModule", {
  9767. value: true
  9768. });
  9769. var _validate = __webpack_require__(35);
  9770. Object.defineProperty(exports, 'validate', {
  9771. enumerable: true,
  9772. get: function get() {
  9773. return _validate.validate;
  9774. }
  9775. });
  9776. Object.defineProperty(exports, 'ValidationContext', {
  9777. enumerable: true,
  9778. get: function get() {
  9779. return _validate.ValidationContext;
  9780. }
  9781. });
  9782. var _specifiedRules = __webpack_require__(34);
  9783. Object.defineProperty(exports, 'specifiedRules', {
  9784. enumerable: true,
  9785. get: function get() {
  9786. return _specifiedRules.specifiedRules;
  9787. }
  9788. });
  9789. /***/ }),
  9790. /* 56 */
  9791. /***/ (function(module, exports, __webpack_require__) {
  9792. "use strict";
  9793. Object.defineProperty(exports, "__esModule", {
  9794. value: true
  9795. });
  9796. exports.badValueMessage = badValueMessage;
  9797. exports.ArgumentsOfCorrectType = ArgumentsOfCorrectType;
  9798. var _error = __webpack_require__(0);
  9799. var _printer = __webpack_require__(4);
  9800. var _isValidLiteralValue = __webpack_require__(18);
  9801. /**
  9802. * Copyright (c) 2015, Facebook, Inc.
  9803. * All rights reserved.
  9804. *
  9805. * This source code is licensed under the BSD-style license found in the
  9806. * LICENSE file in the root directory of this source tree. An additional grant
  9807. * of patent rights can be found in the PATENTS file in the same directory.
  9808. */
  9809. function badValueMessage(argName, type, value, verboseErrors) {
  9810. var message = verboseErrors ? '\n' + verboseErrors.join('\n') : '';
  9811. return 'Argument "' + argName + '" has invalid value ' + value + '.' + message;
  9812. }
  9813. /**
  9814. * Argument values of correct type
  9815. *
  9816. * A GraphQL document is only valid if all field argument literal values are
  9817. * of the type expected by their position.
  9818. */
  9819. function ArgumentsOfCorrectType(context) {
  9820. return {
  9821. Argument: function Argument(node) {
  9822. var argDef = context.getArgument();
  9823. if (argDef) {
  9824. var errors = (0, _isValidLiteralValue.isValidLiteralValue)(argDef.type, node.value);
  9825. if (errors && errors.length > 0) {
  9826. context.reportError(new _error.GraphQLError(badValueMessage(node.name.value, argDef.type, (0, _printer.print)(node.value), errors), [node.value]));
  9827. }
  9828. }
  9829. return false;
  9830. }
  9831. };
  9832. }
  9833. /***/ }),
  9834. /* 57 */
  9835. /***/ (function(module, exports, __webpack_require__) {
  9836. "use strict";
  9837. Object.defineProperty(exports, "__esModule", {
  9838. value: true
  9839. });
  9840. exports.defaultForNonNullArgMessage = defaultForNonNullArgMessage;
  9841. exports.badValueForDefaultArgMessage = badValueForDefaultArgMessage;
  9842. exports.DefaultValuesOfCorrectType = DefaultValuesOfCorrectType;
  9843. var _error = __webpack_require__(0);
  9844. var _printer = __webpack_require__(4);
  9845. var _definition = __webpack_require__(1);
  9846. var _isValidLiteralValue = __webpack_require__(18);
  9847. function defaultForNonNullArgMessage(varName, type, guessType) {
  9848. return 'Variable "$' + varName + '" of type "' + String(type) + '" is required and ' + 'will not use the default value. ' + ('Perhaps you meant to use type "' + String(guessType) + '".');
  9849. }
  9850. /**
  9851. * Copyright (c) 2015, Facebook, Inc.
  9852. * All rights reserved.
  9853. *
  9854. * This source code is licensed under the BSD-style license found in the
  9855. * LICENSE file in the root directory of this source tree. An additional grant
  9856. * of patent rights can be found in the PATENTS file in the same directory.
  9857. */
  9858. function badValueForDefaultArgMessage(varName, type, value, verboseErrors) {
  9859. var message = verboseErrors ? '\n' + verboseErrors.join('\n') : '';
  9860. return 'Variable "$' + varName + '" of type "' + String(type) + '" has invalid ' + ('default value ' + value + '.' + message);
  9861. }
  9862. /**
  9863. * Variable default values of correct type
  9864. *
  9865. * A GraphQL document is only valid if all variable default values are of the
  9866. * type expected by their definition.
  9867. */
  9868. function DefaultValuesOfCorrectType(context) {
  9869. return {
  9870. VariableDefinition: function VariableDefinition(node) {
  9871. var name = node.variable.name.value;
  9872. var defaultValue = node.defaultValue;
  9873. var type = context.getInputType();
  9874. if (type instanceof _definition.GraphQLNonNull && defaultValue) {
  9875. context.reportError(new _error.GraphQLError(defaultForNonNullArgMessage(name, type, type.ofType), [defaultValue]));
  9876. }
  9877. if (type && defaultValue) {
  9878. var errors = (0, _isValidLiteralValue.isValidLiteralValue)(type, defaultValue);
  9879. if (errors && errors.length > 0) {
  9880. context.reportError(new _error.GraphQLError(badValueForDefaultArgMessage(name, type, (0, _printer.print)(defaultValue), errors), [defaultValue]));
  9881. }
  9882. }
  9883. return false;
  9884. },
  9885. SelectionSet: function SelectionSet() {
  9886. return false;
  9887. },
  9888. FragmentDefinition: function FragmentDefinition() {
  9889. return false;
  9890. }
  9891. };
  9892. }
  9893. /***/ }),
  9894. /* 58 */
  9895. /***/ (function(module, exports, __webpack_require__) {
  9896. "use strict";
  9897. Object.defineProperty(exports, "__esModule", {
  9898. value: true
  9899. });
  9900. exports.undefinedFieldMessage = undefinedFieldMessage;
  9901. exports.FieldsOnCorrectType = FieldsOnCorrectType;
  9902. var _error = __webpack_require__(0);
  9903. var _suggestionList = __webpack_require__(23);
  9904. var _suggestionList2 = _interopRequireDefault(_suggestionList);
  9905. var _quotedOrList = __webpack_require__(22);
  9906. var _quotedOrList2 = _interopRequireDefault(_quotedOrList);
  9907. var _definition = __webpack_require__(1);
  9908. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  9909. function undefinedFieldMessage(fieldName, type, suggestedTypeNames, suggestedFieldNames) {
  9910. var message = 'Cannot query field "' + fieldName + '" on type "' + type + '".';
  9911. if (suggestedTypeNames.length !== 0) {
  9912. var suggestions = (0, _quotedOrList2.default)(suggestedTypeNames);
  9913. message += ' Did you mean to use an inline fragment on ' + suggestions + '?';
  9914. } else if (suggestedFieldNames.length !== 0) {
  9915. message += ' Did you mean ' + (0, _quotedOrList2.default)(suggestedFieldNames) + '?';
  9916. }
  9917. return message;
  9918. }
  9919. /**
  9920. * Fields on correct type
  9921. *
  9922. * A GraphQL document is only valid if all fields selected are defined by the
  9923. * parent type, or are an allowed meta field such as __typename.
  9924. */
  9925. /**
  9926. * Copyright (c) 2015, Facebook, Inc.
  9927. * All rights reserved.
  9928. *
  9929. * This source code is licensed under the BSD-style license found in the
  9930. * LICENSE file in the root directory of this source tree. An additional grant
  9931. * of patent rights can be found in the PATENTS file in the same directory.
  9932. */
  9933. function FieldsOnCorrectType(context) {
  9934. return {
  9935. Field: function Field(node) {
  9936. var type = context.getParentType();
  9937. if (type) {
  9938. var fieldDef = context.getFieldDef();
  9939. if (!fieldDef) {
  9940. // This field doesn't exist, lets look for suggestions.
  9941. var schema = context.getSchema();
  9942. var fieldName = node.name.value;
  9943. // First determine if there are any suggested types to condition on.
  9944. var suggestedTypeNames = getSuggestedTypeNames(schema, type, fieldName);
  9945. // If there are no suggested types, then perhaps this was a typo?
  9946. var suggestedFieldNames = suggestedTypeNames.length !== 0 ? [] : getSuggestedFieldNames(schema, type, fieldName);
  9947. // Report an error, including helpful suggestions.
  9948. context.reportError(new _error.GraphQLError(undefinedFieldMessage(fieldName, type.name, suggestedTypeNames, suggestedFieldNames), [node]));
  9949. }
  9950. }
  9951. }
  9952. };
  9953. }
  9954. /**
  9955. * Go through all of the implementations of type, as well as the interfaces
  9956. * that they implement. If any of those types include the provided field,
  9957. * suggest them, sorted by how often the type is referenced, starting
  9958. * with Interfaces.
  9959. */
  9960. function getSuggestedTypeNames(schema, type, fieldName) {
  9961. if (type instanceof _definition.GraphQLInterfaceType || type instanceof _definition.GraphQLUnionType) {
  9962. var _ret = function () {
  9963. var suggestedObjectTypes = [];
  9964. var interfaceUsageCount = Object.create(null);
  9965. schema.getPossibleTypes(type).forEach(function (possibleType) {
  9966. if (!possibleType.getFields()[fieldName]) {
  9967. return;
  9968. }
  9969. // This object type defines this field.
  9970. suggestedObjectTypes.push(possibleType.name);
  9971. possibleType.getInterfaces().forEach(function (possibleInterface) {
  9972. if (!possibleInterface.getFields()[fieldName]) {
  9973. return;
  9974. }
  9975. // This interface type defines this field.
  9976. interfaceUsageCount[possibleInterface.name] = (interfaceUsageCount[possibleInterface.name] || 0) + 1;
  9977. });
  9978. });
  9979. // Suggest interface types based on how common they are.
  9980. var suggestedInterfaceTypes = Object.keys(interfaceUsageCount).sort(function (a, b) {
  9981. return interfaceUsageCount[b] - interfaceUsageCount[a];
  9982. });
  9983. // Suggest both interface and object types.
  9984. return {
  9985. v: suggestedInterfaceTypes.concat(suggestedObjectTypes)
  9986. };
  9987. }();
  9988. if (typeof _ret === "object") return _ret.v;
  9989. }
  9990. // Otherwise, must be an Object type, which does not have possible fields.
  9991. return [];
  9992. }
  9993. /**
  9994. * For the field name provided, determine if there are any similar field names
  9995. * that may be the result of a typo.
  9996. */
  9997. function getSuggestedFieldNames(schema, type, fieldName) {
  9998. if (type instanceof _definition.GraphQLObjectType || type instanceof _definition.GraphQLInterfaceType) {
  9999. var possibleFieldNames = Object.keys(type.getFields());
  10000. return (0, _suggestionList2.default)(fieldName, possibleFieldNames);
  10001. }
  10002. // Otherwise, must be a Union type, which does not define fields.
  10003. return [];
  10004. }
  10005. /***/ }),
  10006. /* 59 */
  10007. /***/ (function(module, exports, __webpack_require__) {
  10008. "use strict";
  10009. Object.defineProperty(exports, "__esModule", {
  10010. value: true
  10011. });
  10012. exports.inlineFragmentOnNonCompositeErrorMessage = inlineFragmentOnNonCompositeErrorMessage;
  10013. exports.fragmentOnNonCompositeErrorMessage = fragmentOnNonCompositeErrorMessage;
  10014. exports.FragmentsOnCompositeTypes = FragmentsOnCompositeTypes;
  10015. var _error = __webpack_require__(0);
  10016. var _printer = __webpack_require__(4);
  10017. var _definition = __webpack_require__(1);
  10018. /**
  10019. * Copyright (c) 2015, Facebook, Inc.
  10020. * All rights reserved.
  10021. *
  10022. * This source code is licensed under the BSD-style license found in the
  10023. * LICENSE file in the root directory of this source tree. An additional grant
  10024. * of patent rights can be found in the PATENTS file in the same directory.
  10025. */
  10026. function inlineFragmentOnNonCompositeErrorMessage(type) {
  10027. return 'Fragment cannot condition on non composite type "' + String(type) + '".';
  10028. }
  10029. function fragmentOnNonCompositeErrorMessage(fragName, type) {
  10030. return 'Fragment "' + fragName + '" cannot condition on non composite ' + ('type "' + String(type) + '".');
  10031. }
  10032. /**
  10033. * Fragments on composite type
  10034. *
  10035. * Fragments use a type condition to determine if they apply, since fragments
  10036. * can only be spread into a composite type (object, interface, or union), the
  10037. * type condition must also be a composite type.
  10038. */
  10039. function FragmentsOnCompositeTypes(context) {
  10040. return {
  10041. InlineFragment: function InlineFragment(node) {
  10042. var type = context.getType();
  10043. if (node.typeCondition && type && !(0, _definition.isCompositeType)(type)) {
  10044. context.reportError(new _error.GraphQLError(inlineFragmentOnNonCompositeErrorMessage((0, _printer.print)(node.typeCondition)), [node.typeCondition]));
  10045. }
  10046. },
  10047. FragmentDefinition: function FragmentDefinition(node) {
  10048. var type = context.getType();
  10049. if (type && !(0, _definition.isCompositeType)(type)) {
  10050. context.reportError(new _error.GraphQLError(fragmentOnNonCompositeErrorMessage(node.name.value, (0, _printer.print)(node.typeCondition)), [node.typeCondition]));
  10051. }
  10052. }
  10053. };
  10054. }
  10055. /***/ }),
  10056. /* 60 */
  10057. /***/ (function(module, exports, __webpack_require__) {
  10058. "use strict";
  10059. Object.defineProperty(exports, "__esModule", {
  10060. value: true
  10061. });
  10062. exports.unknownArgMessage = unknownArgMessage;
  10063. exports.unknownDirectiveArgMessage = unknownDirectiveArgMessage;
  10064. exports.KnownArgumentNames = KnownArgumentNames;
  10065. var _error = __webpack_require__(0);
  10066. var _find = __webpack_require__(10);
  10067. var _find2 = _interopRequireDefault(_find);
  10068. var _invariant = __webpack_require__(3);
  10069. var _invariant2 = _interopRequireDefault(_invariant);
  10070. var _suggestionList = __webpack_require__(23);
  10071. var _suggestionList2 = _interopRequireDefault(_suggestionList);
  10072. var _quotedOrList = __webpack_require__(22);
  10073. var _quotedOrList2 = _interopRequireDefault(_quotedOrList);
  10074. var _kinds = __webpack_require__(2);
  10075. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  10076. function unknownArgMessage(argName, fieldName, type, suggestedArgs) {
  10077. var message = 'Unknown argument "' + argName + '" on field "' + fieldName + '" of ' + ('type "' + String(type) + '".');
  10078. if (suggestedArgs.length) {
  10079. message += ' Did you mean ' + (0, _quotedOrList2.default)(suggestedArgs) + '?';
  10080. }
  10081. return message;
  10082. }
  10083. /**
  10084. * Copyright (c) 2015, Facebook, Inc.
  10085. * All rights reserved.
  10086. *
  10087. * This source code is licensed under the BSD-style license found in the
  10088. * LICENSE file in the root directory of this source tree. An additional grant
  10089. * of patent rights can be found in the PATENTS file in the same directory.
  10090. */
  10091. function unknownDirectiveArgMessage(argName, directiveName, suggestedArgs) {
  10092. var message = 'Unknown argument "' + argName + '" on directive "@' + directiveName + '".';
  10093. if (suggestedArgs.length) {
  10094. message += ' Did you mean ' + (0, _quotedOrList2.default)(suggestedArgs) + '?';
  10095. }
  10096. return message;
  10097. }
  10098. /**
  10099. * Known argument names
  10100. *
  10101. * A GraphQL field is only valid if all supplied arguments are defined by
  10102. * that field.
  10103. */
  10104. function KnownArgumentNames(context) {
  10105. return {
  10106. Argument: function Argument(node, key, parent, path, ancestors) {
  10107. var argumentOf = ancestors[ancestors.length - 1];
  10108. if (argumentOf.kind === _kinds.FIELD) {
  10109. var fieldDef = context.getFieldDef();
  10110. if (fieldDef) {
  10111. var fieldArgDef = (0, _find2.default)(fieldDef.args, function (arg) {
  10112. return arg.name === node.name.value;
  10113. });
  10114. if (!fieldArgDef) {
  10115. var parentType = context.getParentType();
  10116. (0, _invariant2.default)(parentType);
  10117. context.reportError(new _error.GraphQLError(unknownArgMessage(node.name.value, fieldDef.name, parentType.name, (0, _suggestionList2.default)(node.name.value, fieldDef.args.map(function (arg) {
  10118. return arg.name;
  10119. }))), [node]));
  10120. }
  10121. }
  10122. } else if (argumentOf.kind === _kinds.DIRECTIVE) {
  10123. var directive = context.getDirective();
  10124. if (directive) {
  10125. var directiveArgDef = (0, _find2.default)(directive.args, function (arg) {
  10126. return arg.name === node.name.value;
  10127. });
  10128. if (!directiveArgDef) {
  10129. context.reportError(new _error.GraphQLError(unknownDirectiveArgMessage(node.name.value, directive.name, (0, _suggestionList2.default)(node.name.value, directive.args.map(function (arg) {
  10130. return arg.name;
  10131. }))), [node]));
  10132. }
  10133. }
  10134. }
  10135. }
  10136. };
  10137. }
  10138. /***/ }),
  10139. /* 61 */
  10140. /***/ (function(module, exports, __webpack_require__) {
  10141. "use strict";
  10142. Object.defineProperty(exports, "__esModule", {
  10143. value: true
  10144. });
  10145. exports.unknownDirectiveMessage = unknownDirectiveMessage;
  10146. exports.misplacedDirectiveMessage = misplacedDirectiveMessage;
  10147. exports.KnownDirectives = KnownDirectives;
  10148. var _error = __webpack_require__(0);
  10149. var _find = __webpack_require__(10);
  10150. var _find2 = _interopRequireDefault(_find);
  10151. var _kinds = __webpack_require__(2);
  10152. var _directives = __webpack_require__(5);
  10153. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  10154. function unknownDirectiveMessage(directiveName) {
  10155. return 'Unknown directive "' + directiveName + '".';
  10156. }
  10157. /**
  10158. * Copyright (c) 2015, Facebook, Inc.
  10159. * All rights reserved.
  10160. *
  10161. * This source code is licensed under the BSD-style license found in the
  10162. * LICENSE file in the root directory of this source tree. An additional grant
  10163. * of patent rights can be found in the PATENTS file in the same directory.
  10164. */
  10165. function misplacedDirectiveMessage(directiveName, location) {
  10166. return 'Directive "' + directiveName + '" may not be used on ' + location + '.';
  10167. }
  10168. /**
  10169. * Known directives
  10170. *
  10171. * A GraphQL document is only valid if all `@directives` are known by the
  10172. * schema and legally positioned.
  10173. */
  10174. function KnownDirectives(context) {
  10175. return {
  10176. Directive: function Directive(node, key, parent, path, ancestors) {
  10177. var directiveDef = (0, _find2.default)(context.getSchema().getDirectives(), function (def) {
  10178. return def.name === node.name.value;
  10179. });
  10180. if (!directiveDef) {
  10181. context.reportError(new _error.GraphQLError(unknownDirectiveMessage(node.name.value), [node]));
  10182. return;
  10183. }
  10184. var candidateLocation = getDirectiveLocationForASTPath(ancestors);
  10185. if (!candidateLocation) {
  10186. context.reportError(new _error.GraphQLError(misplacedDirectiveMessage(node.name.value, node.type), [node]));
  10187. } else if (directiveDef.locations.indexOf(candidateLocation) === -1) {
  10188. context.reportError(new _error.GraphQLError(misplacedDirectiveMessage(node.name.value, candidateLocation), [node]));
  10189. }
  10190. }
  10191. };
  10192. }
  10193. function getDirectiveLocationForASTPath(ancestors) {
  10194. var appliedTo = ancestors[ancestors.length - 1];
  10195. switch (appliedTo.kind) {
  10196. case _kinds.OPERATION_DEFINITION:
  10197. switch (appliedTo.operation) {
  10198. case 'query':
  10199. return _directives.DirectiveLocation.QUERY;
  10200. case 'mutation':
  10201. return _directives.DirectiveLocation.MUTATION;
  10202. case 'subscription':
  10203. return _directives.DirectiveLocation.SUBSCRIPTION;
  10204. }
  10205. break;
  10206. case _kinds.FIELD:
  10207. return _directives.DirectiveLocation.FIELD;
  10208. case _kinds.FRAGMENT_SPREAD:
  10209. return _directives.DirectiveLocation.FRAGMENT_SPREAD;
  10210. case _kinds.INLINE_FRAGMENT:
  10211. return _directives.DirectiveLocation.INLINE_FRAGMENT;
  10212. case _kinds.FRAGMENT_DEFINITION:
  10213. return _directives.DirectiveLocation.FRAGMENT_DEFINITION;
  10214. case _kinds.SCHEMA_DEFINITION:
  10215. return _directives.DirectiveLocation.SCHEMA;
  10216. case _kinds.SCALAR_TYPE_DEFINITION:
  10217. return _directives.DirectiveLocation.SCALAR;
  10218. case _kinds.OBJECT_TYPE_DEFINITION:
  10219. return _directives.DirectiveLocation.OBJECT;
  10220. case _kinds.FIELD_DEFINITION:
  10221. return _directives.DirectiveLocation.FIELD_DEFINITION;
  10222. case _kinds.INTERFACE_TYPE_DEFINITION:
  10223. return _directives.DirectiveLocation.INTERFACE;
  10224. case _kinds.UNION_TYPE_DEFINITION:
  10225. return _directives.DirectiveLocation.UNION;
  10226. case _kinds.ENUM_TYPE_DEFINITION:
  10227. return _directives.DirectiveLocation.ENUM;
  10228. case _kinds.ENUM_VALUE_DEFINITION:
  10229. return _directives.DirectiveLocation.ENUM_VALUE;
  10230. case _kinds.INPUT_OBJECT_TYPE_DEFINITION:
  10231. return _directives.DirectiveLocation.INPUT_OBJECT;
  10232. case _kinds.INPUT_VALUE_DEFINITION:
  10233. var parentNode = ancestors[ancestors.length - 3];
  10234. return parentNode.kind === _kinds.INPUT_OBJECT_TYPE_DEFINITION ? _directives.DirectiveLocation.INPUT_FIELD_DEFINITION : _directives.DirectiveLocation.ARGUMENT_DEFINITION;
  10235. }
  10236. }
  10237. /***/ }),
  10238. /* 62 */
  10239. /***/ (function(module, exports, __webpack_require__) {
  10240. "use strict";
  10241. Object.defineProperty(exports, "__esModule", {
  10242. value: true
  10243. });
  10244. exports.unknownFragmentMessage = unknownFragmentMessage;
  10245. exports.KnownFragmentNames = KnownFragmentNames;
  10246. var _error = __webpack_require__(0);
  10247. /**
  10248. * Copyright (c) 2015, Facebook, Inc.
  10249. * All rights reserved.
  10250. *
  10251. * This source code is licensed under the BSD-style license found in the
  10252. * LICENSE file in the root directory of this source tree. An additional grant
  10253. * of patent rights can be found in the PATENTS file in the same directory.
  10254. */
  10255. function unknownFragmentMessage(fragName) {
  10256. return 'Unknown fragment "' + fragName + '".';
  10257. }
  10258. /**
  10259. * Known fragment names
  10260. *
  10261. * A GraphQL document is only valid if all `...Fragment` fragment spreads refer
  10262. * to fragments defined in the same document.
  10263. */
  10264. function KnownFragmentNames(context) {
  10265. return {
  10266. FragmentSpread: function FragmentSpread(node) {
  10267. var fragmentName = node.name.value;
  10268. var fragment = context.getFragment(fragmentName);
  10269. if (!fragment) {
  10270. context.reportError(new _error.GraphQLError(unknownFragmentMessage(fragmentName), [node.name]));
  10271. }
  10272. }
  10273. };
  10274. }
  10275. /***/ }),
  10276. /* 63 */
  10277. /***/ (function(module, exports, __webpack_require__) {
  10278. "use strict";
  10279. Object.defineProperty(exports, "__esModule", {
  10280. value: true
  10281. });
  10282. exports.unknownTypeMessage = unknownTypeMessage;
  10283. exports.KnownTypeNames = KnownTypeNames;
  10284. var _error = __webpack_require__(0);
  10285. var _suggestionList = __webpack_require__(23);
  10286. var _suggestionList2 = _interopRequireDefault(_suggestionList);
  10287. var _quotedOrList = __webpack_require__(22);
  10288. var _quotedOrList2 = _interopRequireDefault(_quotedOrList);
  10289. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  10290. /**
  10291. * Copyright (c) 2015, Facebook, Inc.
  10292. * All rights reserved.
  10293. *
  10294. * This source code is licensed under the BSD-style license found in the
  10295. * LICENSE file in the root directory of this source tree. An additional grant
  10296. * of patent rights can be found in the PATENTS file in the same directory.
  10297. */
  10298. function unknownTypeMessage(type, suggestedTypes) {
  10299. var message = 'Unknown type "' + String(type) + '".';
  10300. if (suggestedTypes.length) {
  10301. message += ' Did you mean ' + (0, _quotedOrList2.default)(suggestedTypes) + '?';
  10302. }
  10303. return message;
  10304. }
  10305. /**
  10306. * Known type names
  10307. *
  10308. * A GraphQL document is only valid if referenced types (specifically
  10309. * variable definitions and fragment conditions) are defined by the type schema.
  10310. */
  10311. function KnownTypeNames(context) {
  10312. return {
  10313. // TODO: when validating IDL, re-enable these. Experimental version does not
  10314. // add unreferenced types, resulting in false-positive errors. Squelched
  10315. // errors for now.
  10316. ObjectTypeDefinition: function ObjectTypeDefinition() {
  10317. return false;
  10318. },
  10319. InterfaceTypeDefinition: function InterfaceTypeDefinition() {
  10320. return false;
  10321. },
  10322. UnionTypeDefinition: function UnionTypeDefinition() {
  10323. return false;
  10324. },
  10325. InputObjectTypeDefinition: function InputObjectTypeDefinition() {
  10326. return false;
  10327. },
  10328. NamedType: function NamedType(node) {
  10329. var schema = context.getSchema();
  10330. var typeName = node.name.value;
  10331. var type = schema.getType(typeName);
  10332. if (!type) {
  10333. context.reportError(new _error.GraphQLError(unknownTypeMessage(typeName, (0, _suggestionList2.default)(typeName, Object.keys(schema.getTypeMap()))), [node]));
  10334. }
  10335. }
  10336. };
  10337. }
  10338. /***/ }),
  10339. /* 64 */
  10340. /***/ (function(module, exports, __webpack_require__) {
  10341. "use strict";
  10342. Object.defineProperty(exports, "__esModule", {
  10343. value: true
  10344. });
  10345. exports.anonOperationNotAloneMessage = anonOperationNotAloneMessage;
  10346. exports.LoneAnonymousOperation = LoneAnonymousOperation;
  10347. var _error = __webpack_require__(0);
  10348. var _kinds = __webpack_require__(2);
  10349. function anonOperationNotAloneMessage() {
  10350. return 'This anonymous operation must be the only defined operation.';
  10351. }
  10352. /**
  10353. * Lone anonymous operation
  10354. *
  10355. * A GraphQL document is only valid if when it contains an anonymous operation
  10356. * (the query short-hand) that it contains only that one operation definition.
  10357. */
  10358. /**
  10359. * Copyright (c) 2015, Facebook, Inc.
  10360. * All rights reserved.
  10361. *
  10362. * This source code is licensed under the BSD-style license found in the
  10363. * LICENSE file in the root directory of this source tree. An additional grant
  10364. * of patent rights can be found in the PATENTS file in the same directory.
  10365. */
  10366. function LoneAnonymousOperation(context) {
  10367. var operationCount = 0;
  10368. return {
  10369. Document: function Document(node) {
  10370. operationCount = node.definitions.filter(function (definition) {
  10371. return definition.kind === _kinds.OPERATION_DEFINITION;
  10372. }).length;
  10373. },
  10374. OperationDefinition: function OperationDefinition(node) {
  10375. if (!node.name && operationCount > 1) {
  10376. context.reportError(new _error.GraphQLError(anonOperationNotAloneMessage(), [node]));
  10377. }
  10378. }
  10379. };
  10380. }
  10381. /***/ }),
  10382. /* 65 */
  10383. /***/ (function(module, exports, __webpack_require__) {
  10384. "use strict";
  10385. Object.defineProperty(exports, "__esModule", {
  10386. value: true
  10387. });
  10388. exports.cycleErrorMessage = cycleErrorMessage;
  10389. exports.NoFragmentCycles = NoFragmentCycles;
  10390. var _error = __webpack_require__(0);
  10391. /**
  10392. * Copyright (c) 2015, Facebook, Inc.
  10393. * All rights reserved.
  10394. *
  10395. * This source code is licensed under the BSD-style license found in the
  10396. * LICENSE file in the root directory of this source tree. An additional grant
  10397. * of patent rights can be found in the PATENTS file in the same directory.
  10398. */
  10399. function cycleErrorMessage(fragName, spreadNames) {
  10400. var via = spreadNames.length ? ' via ' + spreadNames.join(', ') : '';
  10401. return 'Cannot spread fragment "' + fragName + '" within itself' + via + '.';
  10402. }
  10403. function NoFragmentCycles(context) {
  10404. // Tracks already visited fragments to maintain O(N) and to ensure that cycles
  10405. // are not redundantly reported.
  10406. var visitedFrags = Object.create(null);
  10407. // Array of AST nodes used to produce meaningful errors
  10408. var spreadPath = [];
  10409. // Position in the spread path
  10410. var spreadPathIndexByName = Object.create(null);
  10411. return {
  10412. OperationDefinition: function OperationDefinition() {
  10413. return false;
  10414. },
  10415. FragmentDefinition: function FragmentDefinition(node) {
  10416. if (!visitedFrags[node.name.value]) {
  10417. detectCycleRecursive(node);
  10418. }
  10419. return false;
  10420. }
  10421. };
  10422. // This does a straight-forward DFS to find cycles.
  10423. // It does not terminate when a cycle was found but continues to explore
  10424. // the graph to find all possible cycles.
  10425. function detectCycleRecursive(fragment) {
  10426. var fragmentName = fragment.name.value;
  10427. visitedFrags[fragmentName] = true;
  10428. var spreadNodes = context.getFragmentSpreads(fragment.selectionSet);
  10429. if (spreadNodes.length === 0) {
  10430. return;
  10431. }
  10432. spreadPathIndexByName[fragmentName] = spreadPath.length;
  10433. for (var i = 0; i < spreadNodes.length; i++) {
  10434. var spreadNode = spreadNodes[i];
  10435. var spreadName = spreadNode.name.value;
  10436. var cycleIndex = spreadPathIndexByName[spreadName];
  10437. if (cycleIndex === undefined) {
  10438. spreadPath.push(spreadNode);
  10439. if (!visitedFrags[spreadName]) {
  10440. var spreadFragment = context.getFragment(spreadName);
  10441. if (spreadFragment) {
  10442. detectCycleRecursive(spreadFragment);
  10443. }
  10444. }
  10445. spreadPath.pop();
  10446. } else {
  10447. var cyclePath = spreadPath.slice(cycleIndex);
  10448. context.reportError(new _error.GraphQLError(cycleErrorMessage(spreadName, cyclePath.map(function (s) {
  10449. return s.name.value;
  10450. })), cyclePath.concat(spreadNode)));
  10451. }
  10452. }
  10453. spreadPathIndexByName[fragmentName] = undefined;
  10454. }
  10455. }
  10456. /***/ }),
  10457. /* 66 */
  10458. /***/ (function(module, exports, __webpack_require__) {
  10459. "use strict";
  10460. Object.defineProperty(exports, "__esModule", {
  10461. value: true
  10462. });
  10463. exports.undefinedVarMessage = undefinedVarMessage;
  10464. exports.NoUndefinedVariables = NoUndefinedVariables;
  10465. var _error = __webpack_require__(0);
  10466. /**
  10467. * Copyright (c) 2015, Facebook, Inc.
  10468. * All rights reserved.
  10469. *
  10470. * This source code is licensed under the BSD-style license found in the
  10471. * LICENSE file in the root directory of this source tree. An additional grant
  10472. * of patent rights can be found in the PATENTS file in the same directory.
  10473. */
  10474. function undefinedVarMessage(varName, opName) {
  10475. return opName ? 'Variable "$' + varName + '" is not defined by operation "' + opName + '".' : 'Variable "$' + varName + '" is not defined.';
  10476. }
  10477. /**
  10478. * No undefined variables
  10479. *
  10480. * A GraphQL operation is only valid if all variables encountered, both directly
  10481. * and via fragment spreads, are defined by that operation.
  10482. */
  10483. function NoUndefinedVariables(context) {
  10484. var variableNameDefined = Object.create(null);
  10485. return {
  10486. OperationDefinition: {
  10487. enter: function enter() {
  10488. variableNameDefined = Object.create(null);
  10489. },
  10490. leave: function leave(operation) {
  10491. var usages = context.getRecursiveVariableUsages(operation);
  10492. usages.forEach(function (_ref) {
  10493. var node = _ref.node;
  10494. var varName = node.name.value;
  10495. if (variableNameDefined[varName] !== true) {
  10496. context.reportError(new _error.GraphQLError(undefinedVarMessage(varName, operation.name && operation.name.value), [node, operation]));
  10497. }
  10498. });
  10499. }
  10500. },
  10501. VariableDefinition: function VariableDefinition(node) {
  10502. variableNameDefined[node.variable.name.value] = true;
  10503. }
  10504. };
  10505. }
  10506. /***/ }),
  10507. /* 67 */
  10508. /***/ (function(module, exports, __webpack_require__) {
  10509. "use strict";
  10510. Object.defineProperty(exports, "__esModule", {
  10511. value: true
  10512. });
  10513. exports.unusedFragMessage = unusedFragMessage;
  10514. exports.NoUnusedFragments = NoUnusedFragments;
  10515. var _error = __webpack_require__(0);
  10516. /**
  10517. * Copyright (c) 2015, Facebook, Inc.
  10518. * All rights reserved.
  10519. *
  10520. * This source code is licensed under the BSD-style license found in the
  10521. * LICENSE file in the root directory of this source tree. An additional grant
  10522. * of patent rights can be found in the PATENTS file in the same directory.
  10523. */
  10524. function unusedFragMessage(fragName) {
  10525. return 'Fragment "' + fragName + '" is never used.';
  10526. }
  10527. /**
  10528. * No unused fragments
  10529. *
  10530. * A GraphQL document is only valid if all fragment definitions are spread
  10531. * within operations, or spread within other fragments spread within operations.
  10532. */
  10533. function NoUnusedFragments(context) {
  10534. var operationDefs = [];
  10535. var fragmentDefs = [];
  10536. return {
  10537. OperationDefinition: function OperationDefinition(node) {
  10538. operationDefs.push(node);
  10539. return false;
  10540. },
  10541. FragmentDefinition: function FragmentDefinition(node) {
  10542. fragmentDefs.push(node);
  10543. return false;
  10544. },
  10545. Document: {
  10546. leave: function leave() {
  10547. var fragmentNameUsed = Object.create(null);
  10548. operationDefs.forEach(function (operation) {
  10549. context.getRecursivelyReferencedFragments(operation).forEach(function (fragment) {
  10550. fragmentNameUsed[fragment.name.value] = true;
  10551. });
  10552. });
  10553. fragmentDefs.forEach(function (fragmentDef) {
  10554. var fragName = fragmentDef.name.value;
  10555. if (fragmentNameUsed[fragName] !== true) {
  10556. context.reportError(new _error.GraphQLError(unusedFragMessage(fragName), [fragmentDef]));
  10557. }
  10558. });
  10559. }
  10560. }
  10561. };
  10562. }
  10563. /***/ }),
  10564. /* 68 */
  10565. /***/ (function(module, exports, __webpack_require__) {
  10566. "use strict";
  10567. Object.defineProperty(exports, "__esModule", {
  10568. value: true
  10569. });
  10570. exports.unusedVariableMessage = unusedVariableMessage;
  10571. exports.NoUnusedVariables = NoUnusedVariables;
  10572. var _error = __webpack_require__(0);
  10573. /**
  10574. * Copyright (c) 2015, Facebook, Inc.
  10575. * All rights reserved.
  10576. *
  10577. * This source code is licensed under the BSD-style license found in the
  10578. * LICENSE file in the root directory of this source tree. An additional grant
  10579. * of patent rights can be found in the PATENTS file in the same directory.
  10580. */
  10581. function unusedVariableMessage(varName, opName) {
  10582. return opName ? 'Variable "$' + varName + '" is never used in operation "' + opName + '".' : 'Variable "$' + varName + '" is never used.';
  10583. }
  10584. /**
  10585. * No unused variables
  10586. *
  10587. * A GraphQL operation is only valid if all variables defined by an operation
  10588. * are used, either directly or within a spread fragment.
  10589. */
  10590. function NoUnusedVariables(context) {
  10591. var variableDefs = [];
  10592. return {
  10593. OperationDefinition: {
  10594. enter: function enter() {
  10595. variableDefs = [];
  10596. },
  10597. leave: function leave(operation) {
  10598. var variableNameUsed = Object.create(null);
  10599. var usages = context.getRecursiveVariableUsages(operation);
  10600. var opName = operation.name ? operation.name.value : null;
  10601. usages.forEach(function (_ref) {
  10602. var node = _ref.node;
  10603. variableNameUsed[node.name.value] = true;
  10604. });
  10605. variableDefs.forEach(function (variableDef) {
  10606. var variableName = variableDef.variable.name.value;
  10607. if (variableNameUsed[variableName] !== true) {
  10608. context.reportError(new _error.GraphQLError(unusedVariableMessage(variableName, opName), [variableDef]));
  10609. }
  10610. });
  10611. }
  10612. },
  10613. VariableDefinition: function VariableDefinition(def) {
  10614. variableDefs.push(def);
  10615. }
  10616. };
  10617. }
  10618. /***/ }),
  10619. /* 69 */
  10620. /***/ (function(module, exports, __webpack_require__) {
  10621. "use strict";
  10622. Object.defineProperty(exports, "__esModule", {
  10623. value: true
  10624. });
  10625. exports.fieldsConflictMessage = fieldsConflictMessage;
  10626. exports.OverlappingFieldsCanBeMerged = OverlappingFieldsCanBeMerged;
  10627. var _error = __webpack_require__(0);
  10628. var _find = __webpack_require__(10);
  10629. var _find2 = _interopRequireDefault(_find);
  10630. var _kinds = __webpack_require__(2);
  10631. var _printer = __webpack_require__(4);
  10632. var _definition = __webpack_require__(1);
  10633. var _typeFromAST = __webpack_require__(9);
  10634. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  10635. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10636. /**
  10637. * Copyright (c) 2015, Facebook, Inc.
  10638. * All rights reserved.
  10639. *
  10640. * This source code is licensed under the BSD-style license found in the
  10641. * LICENSE file in the root directory of this source tree. An additional grant
  10642. * of patent rights can be found in the PATENTS file in the same directory.
  10643. */
  10644. function fieldsConflictMessage(responseName, reason) {
  10645. return 'Fields "' + responseName + '" conflict because ' + reasonMessage(reason) + '. Use different aliases on the fields to fetch both if this was ' + 'intentional.';
  10646. }
  10647. function reasonMessage(reason) {
  10648. if (Array.isArray(reason)) {
  10649. return reason.map(function (_ref) {
  10650. var responseName = _ref[0],
  10651. subreason = _ref[1];
  10652. return 'subfields "' + responseName + '" conflict because ' + reasonMessage(subreason);
  10653. }).join(' and ');
  10654. }
  10655. return reason;
  10656. }
  10657. /**
  10658. * Overlapping fields can be merged
  10659. *
  10660. * A selection set is only valid if all fields (including spreading any
  10661. * fragments) either correspond to distinct response names or can be merged
  10662. * without ambiguity.
  10663. */
  10664. function OverlappingFieldsCanBeMerged(context) {
  10665. // A memoization for when two fragments are compared "between" each other for
  10666. // conflicts. Two fragments may be compared many times, so memoizing this can
  10667. // dramatically improve the performance of this validator.
  10668. var comparedFragments = new PairSet();
  10669. // A cache for the "field map" and list of fragment names found in any given
  10670. // selection set. Selection sets may be asked for this information multiple
  10671. // times, so this improves the performance of this validator.
  10672. var cachedFieldsAndFragmentNames = new Map();
  10673. return {
  10674. SelectionSet: function SelectionSet(selectionSet) {
  10675. var conflicts = findConflictsWithinSelectionSet(context, cachedFieldsAndFragmentNames, comparedFragments, context.getParentType(), selectionSet);
  10676. conflicts.forEach(function (_ref2) {
  10677. var _ref2$ = _ref2[0],
  10678. responseName = _ref2$[0],
  10679. reason = _ref2$[1],
  10680. fields1 = _ref2[1],
  10681. fields2 = _ref2[2];
  10682. return context.reportError(new _error.GraphQLError(fieldsConflictMessage(responseName, reason), fields1.concat(fields2)));
  10683. });
  10684. }
  10685. };
  10686. }
  10687. // Field name and reason.
  10688. // Reason is a string, or a nested list of conflicts.
  10689. // Tuple defining a field node in a context.
  10690. // Map of array of those.
  10691. /**
  10692. * Algorithm:
  10693. *
  10694. * Conflicts occur when two fields exist in a query which will produce the same
  10695. * response name, but represent differing values, thus creating a conflict.
  10696. * The algorithm below finds all conflicts via making a series of comparisons
  10697. * between fields. In order to compare as few fields as possible, this makes
  10698. * a series of comparisons "within" sets of fields and "between" sets of fields.
  10699. *
  10700. * Given any selection set, a collection produces both a set of fields by
  10701. * also including all inline fragments, as well as a list of fragments
  10702. * referenced by fragment spreads.
  10703. *
  10704. * A) Each selection set represented in the document first compares "within" its
  10705. * collected set of fields, finding any conflicts between every pair of
  10706. * overlapping fields.
  10707. * Note: This is the *only time* that a the fields "within" a set are compared
  10708. * to each other. After this only fields "between" sets are compared.
  10709. *
  10710. * B) Also, if any fragment is referenced in a selection set, then a
  10711. * comparison is made "between" the original set of fields and the
  10712. * referenced fragment.
  10713. *
  10714. * C) Also, if multiple fragments are referenced, then comparisons
  10715. * are made "between" each referenced fragment.
  10716. *
  10717. * D) When comparing "between" a set of fields and a referenced fragment, first
  10718. * a comparison is made between each field in the original set of fields and
  10719. * each field in the the referenced set of fields.
  10720. *
  10721. * E) Also, if any fragment is referenced in the referenced selection set,
  10722. * then a comparison is made "between" the original set of fields and the
  10723. * referenced fragment (recursively referring to step D).
  10724. *
  10725. * F) When comparing "between" two fragments, first a comparison is made between
  10726. * each field in the first referenced set of fields and each field in the the
  10727. * second referenced set of fields.
  10728. *
  10729. * G) Also, any fragments referenced by the first must be compared to the
  10730. * second, and any fragments referenced by the second must be compared to the
  10731. * first (recursively referring to step F).
  10732. *
  10733. * H) When comparing two fields, if both have selection sets, then a comparison
  10734. * is made "between" both selection sets, first comparing the set of fields in
  10735. * the first selection set with the set of fields in the second.
  10736. *
  10737. * I) Also, if any fragment is referenced in either selection set, then a
  10738. * comparison is made "between" the other set of fields and the
  10739. * referenced fragment.
  10740. *
  10741. * J) Also, if two fragments are referenced in both selection sets, then a
  10742. * comparison is made "between" the two fragments.
  10743. *
  10744. */
  10745. // Find all conflicts found "within" a selection set, including those found
  10746. // via spreading in fragments. Called when visiting each SelectionSet in the
  10747. // GraphQL Document.
  10748. function findConflictsWithinSelectionSet(context, cachedFieldsAndFragmentNames, comparedFragments, parentType, selectionSet) {
  10749. var conflicts = [];
  10750. var _getFieldsAndFragment = getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, parentType, selectionSet),
  10751. fieldMap = _getFieldsAndFragment[0],
  10752. fragmentNames = _getFieldsAndFragment[1];
  10753. // (A) Find find all conflicts "within" the fields of this selection set.
  10754. // Note: this is the *only place* `collectConflictsWithin` is called.
  10755. collectConflictsWithin(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, fieldMap);
  10756. // (B) Then collect conflicts between these fields and those represented by
  10757. // each spread fragment name found.
  10758. for (var i = 0; i < fragmentNames.length; i++) {
  10759. collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, false, fieldMap, fragmentNames[i]);
  10760. // (C) Then compare this fragment with all other fragments found in this
  10761. // selection set to collect conflicts between fragments spread together.
  10762. // This compares each item in the list of fragment names to every other item
  10763. // in that same list (except for itself).
  10764. for (var j = i + 1; j < fragmentNames.length; j++) {
  10765. collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, false, fragmentNames[i], fragmentNames[j]);
  10766. }
  10767. }
  10768. return conflicts;
  10769. }
  10770. // Collect all conflicts found between a set of fields and a fragment reference
  10771. // including via spreading in any nested fragments.
  10772. function collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fieldMap, fragmentName) {
  10773. var fragment = context.getFragment(fragmentName);
  10774. if (!fragment) {
  10775. return;
  10776. }
  10777. var _getReferencedFieldsA = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment),
  10778. fieldMap2 = _getReferencedFieldsA[0],
  10779. fragmentNames2 = _getReferencedFieldsA[1];
  10780. // (D) First collect any conflicts between the provided collection of fields
  10781. // and the collection of fields represented by the given fragment.
  10782. collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fieldMap, fieldMap2);
  10783. // (E) Then collect any conflicts between the provided collection of fields
  10784. // and any fragment names found in the given fragment.
  10785. for (var i = 0; i < fragmentNames2.length; i++) {
  10786. collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fieldMap, fragmentNames2[i]);
  10787. }
  10788. }
  10789. // Collect all conflicts found between two fragments, including via spreading in
  10790. // any nested fragments.
  10791. function collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fragmentName1, fragmentName2) {
  10792. var fragment1 = context.getFragment(fragmentName1);
  10793. var fragment2 = context.getFragment(fragmentName2);
  10794. if (!fragment1 || !fragment2) {
  10795. return;
  10796. }
  10797. // No need to compare a fragment to itself.
  10798. if (fragment1 === fragment2) {
  10799. return;
  10800. }
  10801. // Memoize so two fragments are not compared for conflicts more than once.
  10802. if (comparedFragments.has(fragmentName1, fragmentName2, areMutuallyExclusive)) {
  10803. return;
  10804. }
  10805. comparedFragments.add(fragmentName1, fragmentName2, areMutuallyExclusive);
  10806. var _getReferencedFieldsA2 = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment1),
  10807. fieldMap1 = _getReferencedFieldsA2[0],
  10808. fragmentNames1 = _getReferencedFieldsA2[1];
  10809. var _getReferencedFieldsA3 = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment2),
  10810. fieldMap2 = _getReferencedFieldsA3[0],
  10811. fragmentNames2 = _getReferencedFieldsA3[1];
  10812. // (F) First, collect all conflicts between these two collections of fields
  10813. // (not including any nested fragments).
  10814. collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fieldMap1, fieldMap2);
  10815. // (G) Then collect conflicts between the first fragment and any nested
  10816. // fragments spread in the second fragment.
  10817. for (var j = 0; j < fragmentNames2.length; j++) {
  10818. collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fragmentName1, fragmentNames2[j]);
  10819. }
  10820. // (G) Then collect conflicts between the second fragment and any nested
  10821. // fragments spread in the first fragment.
  10822. for (var i = 0; i < fragmentNames1.length; i++) {
  10823. collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fragmentNames1[i], fragmentName2);
  10824. }
  10825. }
  10826. // Find all conflicts found between two selection sets, including those found
  10827. // via spreading in fragments. Called when determining if conflicts exist
  10828. // between the sub-fields of two overlapping fields.
  10829. function findConflictsBetweenSubSelectionSets(context, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, parentType1, selectionSet1, parentType2, selectionSet2) {
  10830. var conflicts = [];
  10831. var _getFieldsAndFragment2 = getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, parentType1, selectionSet1),
  10832. fieldMap1 = _getFieldsAndFragment2[0],
  10833. fragmentNames1 = _getFieldsAndFragment2[1];
  10834. var _getFieldsAndFragment3 = getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, parentType2, selectionSet2),
  10835. fieldMap2 = _getFieldsAndFragment3[0],
  10836. fragmentNames2 = _getFieldsAndFragment3[1];
  10837. // (H) First, collect all conflicts between these two collections of field.
  10838. collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fieldMap1, fieldMap2);
  10839. // (I) Then collect conflicts between the first collection of fields and
  10840. // those referenced by each fragment name associated with the second.
  10841. for (var j = 0; j < fragmentNames2.length; j++) {
  10842. collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fieldMap1, fragmentNames2[j]);
  10843. }
  10844. // (I) Then collect conflicts between the second collection of fields and
  10845. // those referenced by each fragment name associated with the first.
  10846. for (var i = 0; i < fragmentNames1.length; i++) {
  10847. collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fieldMap2, fragmentNames1[i]);
  10848. }
  10849. // (J) Also collect conflicts between any fragment names by the first and
  10850. // fragment names by the second. This compares each item in the first set of
  10851. // names to each item in the second set of names.
  10852. for (var _i = 0; _i < fragmentNames1.length; _i++) {
  10853. for (var _j = 0; _j < fragmentNames2.length; _j++) {
  10854. collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fragmentNames1[_i], fragmentNames2[_j]);
  10855. }
  10856. }
  10857. return conflicts;
  10858. }
  10859. // Collect all Conflicts "within" one collection of fields.
  10860. function collectConflictsWithin(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, fieldMap) {
  10861. // A field map is a keyed collection, where each key represents a response
  10862. // name and the value at that key is a list of all fields which provide that
  10863. // response name. For every response name, if there are multiple fields, they
  10864. // must be compared to find a potential conflict.
  10865. Object.keys(fieldMap).forEach(function (responseName) {
  10866. var fields = fieldMap[responseName];
  10867. // This compares every field in the list to every other field in this list
  10868. // (except to itself). If the list only has one item, nothing needs to
  10869. // be compared.
  10870. if (fields.length > 1) {
  10871. for (var i = 0; i < fields.length; i++) {
  10872. for (var j = i + 1; j < fields.length; j++) {
  10873. var conflict = findConflict(context, cachedFieldsAndFragmentNames, comparedFragments, false, // within one collection is never mutually exclusive
  10874. responseName, fields[i], fields[j]);
  10875. if (conflict) {
  10876. conflicts.push(conflict);
  10877. }
  10878. }
  10879. }
  10880. }
  10881. });
  10882. }
  10883. // Collect all Conflicts between two collections of fields. This is similar to,
  10884. // but different from the `collectConflictsWithin` function above. This check
  10885. // assumes that `collectConflictsWithin` has already been called on each
  10886. // provided collection of fields. This is true because this validator traverses
  10887. // each individual selection set.
  10888. function collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, parentFieldsAreMutuallyExclusive, fieldMap1, fieldMap2) {
  10889. // A field map is a keyed collection, where each key represents a response
  10890. // name and the value at that key is a list of all fields which provide that
  10891. // response name. For any response name which appears in both provided field
  10892. // maps, each field from the first field map must be compared to every field
  10893. // in the second field map to find potential conflicts.
  10894. Object.keys(fieldMap1).forEach(function (responseName) {
  10895. var fields2 = fieldMap2[responseName];
  10896. if (fields2) {
  10897. var fields1 = fieldMap1[responseName];
  10898. for (var i = 0; i < fields1.length; i++) {
  10899. for (var j = 0; j < fields2.length; j++) {
  10900. var conflict = findConflict(context, cachedFieldsAndFragmentNames, comparedFragments, parentFieldsAreMutuallyExclusive, responseName, fields1[i], fields2[j]);
  10901. if (conflict) {
  10902. conflicts.push(conflict);
  10903. }
  10904. }
  10905. }
  10906. }
  10907. });
  10908. }
  10909. // Determines if there is a conflict between two particular fields, including
  10910. // comparing their sub-fields.
  10911. function findConflict(context, cachedFieldsAndFragmentNames, comparedFragments, parentFieldsAreMutuallyExclusive, responseName, field1, field2) {
  10912. var parentType1 = field1[0],
  10913. node1 = field1[1],
  10914. def1 = field1[2];
  10915. var parentType2 = field2[0],
  10916. node2 = field2[1],
  10917. def2 = field2[2];
  10918. // If it is known that two fields could not possibly apply at the same
  10919. // time, due to the parent types, then it is safe to permit them to diverge
  10920. // in aliased field or arguments used as they will not present any ambiguity
  10921. // by differing.
  10922. // It is known that two parent types could never overlap if they are
  10923. // different Object types. Interface or Union types might overlap - if not
  10924. // in the current state of the schema, then perhaps in some future version,
  10925. // thus may not safely diverge.
  10926. var areMutuallyExclusive = parentFieldsAreMutuallyExclusive || parentType1 !== parentType2 && parentType1 instanceof _definition.GraphQLObjectType && parentType2 instanceof _definition.GraphQLObjectType;
  10927. // The return type for each field.
  10928. var type1 = def1 && def1.type;
  10929. var type2 = def2 && def2.type;
  10930. if (!areMutuallyExclusive) {
  10931. // Two aliases must refer to the same field.
  10932. var name1 = node1.name.value;
  10933. var name2 = node2.name.value;
  10934. if (name1 !== name2) {
  10935. return [[responseName, name1 + ' and ' + name2 + ' are different fields'], [node1], [node2]];
  10936. }
  10937. // Two field calls must have the same arguments.
  10938. if (!sameArguments(node1.arguments || [], node2.arguments || [])) {
  10939. return [[responseName, 'they have differing arguments'], [node1], [node2]];
  10940. }
  10941. }
  10942. if (type1 && type2 && doTypesConflict(type1, type2)) {
  10943. return [[responseName, 'they return conflicting types ' + String(type1) + ' and ' + String(type2)], [node1], [node2]];
  10944. }
  10945. // Collect and compare sub-fields. Use the same "visited fragment names" list
  10946. // for both collections so fields in a fragment reference are never
  10947. // compared to themselves.
  10948. var selectionSet1 = node1.selectionSet;
  10949. var selectionSet2 = node2.selectionSet;
  10950. if (selectionSet1 && selectionSet2) {
  10951. var conflicts = findConflictsBetweenSubSelectionSets(context, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, (0, _definition.getNamedType)(type1), selectionSet1, (0, _definition.getNamedType)(type2), selectionSet2);
  10952. return subfieldConflicts(conflicts, responseName, node1, node2);
  10953. }
  10954. }
  10955. function sameArguments(arguments1, arguments2) {
  10956. if (arguments1.length !== arguments2.length) {
  10957. return false;
  10958. }
  10959. return arguments1.every(function (argument1) {
  10960. var argument2 = (0, _find2.default)(arguments2, function (argument) {
  10961. return argument.name.value === argument1.name.value;
  10962. });
  10963. if (!argument2) {
  10964. return false;
  10965. }
  10966. return sameValue(argument1.value, argument2.value);
  10967. });
  10968. }
  10969. function sameValue(value1, value2) {
  10970. return !value1 && !value2 || (0, _printer.print)(value1) === (0, _printer.print)(value2);
  10971. }
  10972. // Two types conflict if both types could not apply to a value simultaneously.
  10973. // Composite types are ignored as their individual field types will be compared
  10974. // later recursively. However List and Non-Null types must match.
  10975. function doTypesConflict(type1, type2) {
  10976. if (type1 instanceof _definition.GraphQLList) {
  10977. return type2 instanceof _definition.GraphQLList ? doTypesConflict(type1.ofType, type2.ofType) : true;
  10978. }
  10979. if (type2 instanceof _definition.GraphQLList) {
  10980. return type1 instanceof _definition.GraphQLList ? doTypesConflict(type1.ofType, type2.ofType) : true;
  10981. }
  10982. if (type1 instanceof _definition.GraphQLNonNull) {
  10983. return type2 instanceof _definition.GraphQLNonNull ? doTypesConflict(type1.ofType, type2.ofType) : true;
  10984. }
  10985. if (type2 instanceof _definition.GraphQLNonNull) {
  10986. return type1 instanceof _definition.GraphQLNonNull ? doTypesConflict(type1.ofType, type2.ofType) : true;
  10987. }
  10988. if ((0, _definition.isLeafType)(type1) || (0, _definition.isLeafType)(type2)) {
  10989. return type1 !== type2;
  10990. }
  10991. return false;
  10992. }
  10993. // Given a selection set, return the collection of fields (a mapping of response
  10994. // name to field nodes and definitions) as well as a list of fragment names
  10995. // referenced via fragment spreads.
  10996. function getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, parentType, selectionSet) {
  10997. var cached = cachedFieldsAndFragmentNames.get(selectionSet);
  10998. if (!cached) {
  10999. var nodeAndDefs = {};
  11000. var fragmentNames = {};
  11001. _collectFieldsAndFragmentNames(context, parentType, selectionSet, nodeAndDefs, fragmentNames);
  11002. cached = [nodeAndDefs, Object.keys(fragmentNames)];
  11003. cachedFieldsAndFragmentNames.set(selectionSet, cached);
  11004. }
  11005. return cached;
  11006. }
  11007. // Given a reference to a fragment, return the represented collection of fields
  11008. // as well as a list of nested fragment names referenced via fragment spreads.
  11009. function getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment) {
  11010. // Short-circuit building a type from the node if possible.
  11011. var cached = cachedFieldsAndFragmentNames.get(fragment.selectionSet);
  11012. if (cached) {
  11013. return cached;
  11014. }
  11015. var fragmentType = (0, _typeFromAST.typeFromAST)(context.getSchema(), fragment.typeCondition);
  11016. return getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragmentType, fragment.selectionSet);
  11017. }
  11018. function _collectFieldsAndFragmentNames(context, parentType, selectionSet, nodeAndDefs, fragmentNames) {
  11019. for (var i = 0; i < selectionSet.selections.length; i++) {
  11020. var selection = selectionSet.selections[i];
  11021. switch (selection.kind) {
  11022. case _kinds.FIELD:
  11023. var fieldName = selection.name.value;
  11024. var fieldDef = void 0;
  11025. if (parentType instanceof _definition.GraphQLObjectType || parentType instanceof _definition.GraphQLInterfaceType) {
  11026. fieldDef = parentType.getFields()[fieldName];
  11027. }
  11028. var responseName = selection.alias ? selection.alias.value : fieldName;
  11029. if (!nodeAndDefs[responseName]) {
  11030. nodeAndDefs[responseName] = [];
  11031. }
  11032. nodeAndDefs[responseName].push([parentType, selection, fieldDef]);
  11033. break;
  11034. case _kinds.FRAGMENT_SPREAD:
  11035. fragmentNames[selection.name.value] = true;
  11036. break;
  11037. case _kinds.INLINE_FRAGMENT:
  11038. var typeCondition = selection.typeCondition;
  11039. var inlineFragmentType = typeCondition ? (0, _typeFromAST.typeFromAST)(context.getSchema(), typeCondition) : parentType;
  11040. _collectFieldsAndFragmentNames(context, inlineFragmentType, selection.selectionSet, nodeAndDefs, fragmentNames);
  11041. break;
  11042. }
  11043. }
  11044. }
  11045. // Given a series of Conflicts which occurred between two sub-fields, generate
  11046. // a single Conflict.
  11047. function subfieldConflicts(conflicts, responseName, node1, node2) {
  11048. if (conflicts.length > 0) {
  11049. return [[responseName, conflicts.map(function (_ref3) {
  11050. var reason = _ref3[0];
  11051. return reason;
  11052. })], conflicts.reduce(function (allFields, _ref4) {
  11053. var fields1 = _ref4[1];
  11054. return allFields.concat(fields1);
  11055. }, [node1]), conflicts.reduce(function (allFields, _ref5) {
  11056. var fields2 = _ref5[2];
  11057. return allFields.concat(fields2);
  11058. }, [node2])];
  11059. }
  11060. }
  11061. /**
  11062. * A way to keep track of pairs of things when the ordering of the pair does
  11063. * not matter. We do this by maintaining a sort of double adjacency sets.
  11064. */
  11065. var PairSet = function () {
  11066. function PairSet() {
  11067. _classCallCheck(this, PairSet);
  11068. this._data = Object.create(null);
  11069. }
  11070. PairSet.prototype.has = function has(a, b, areMutuallyExclusive) {
  11071. var first = this._data[a];
  11072. var result = first && first[b];
  11073. if (result === undefined) {
  11074. return false;
  11075. }
  11076. // areMutuallyExclusive being false is a superset of being true,
  11077. // hence if we want to know if this PairSet "has" these two with no
  11078. // exclusivity, we have to ensure it was added as such.
  11079. if (areMutuallyExclusive === false) {
  11080. return result === false;
  11081. }
  11082. return true;
  11083. };
  11084. PairSet.prototype.add = function add(a, b, areMutuallyExclusive) {
  11085. _pairSetAdd(this._data, a, b, areMutuallyExclusive);
  11086. _pairSetAdd(this._data, b, a, areMutuallyExclusive);
  11087. };
  11088. return PairSet;
  11089. }();
  11090. function _pairSetAdd(data, a, b, areMutuallyExclusive) {
  11091. var map = data[a];
  11092. if (!map) {
  11093. map = Object.create(null);
  11094. data[a] = map;
  11095. }
  11096. map[b] = areMutuallyExclusive;
  11097. }
  11098. /***/ }),
  11099. /* 70 */
  11100. /***/ (function(module, exports, __webpack_require__) {
  11101. "use strict";
  11102. Object.defineProperty(exports, "__esModule", {
  11103. value: true
  11104. });
  11105. exports.typeIncompatibleSpreadMessage = typeIncompatibleSpreadMessage;
  11106. exports.typeIncompatibleAnonSpreadMessage = typeIncompatibleAnonSpreadMessage;
  11107. exports.PossibleFragmentSpreads = PossibleFragmentSpreads;
  11108. var _error = __webpack_require__(0);
  11109. var _typeComparators = __webpack_require__(19);
  11110. var _typeFromAST = __webpack_require__(9);
  11111. /**
  11112. * Copyright (c) 2015, Facebook, Inc.
  11113. * All rights reserved.
  11114. *
  11115. * This source code is licensed under the BSD-style license found in the
  11116. * LICENSE file in the root directory of this source tree. An additional grant
  11117. * of patent rights can be found in the PATENTS file in the same directory.
  11118. */
  11119. function typeIncompatibleSpreadMessage(fragName, parentType, fragType) {
  11120. return 'Fragment "' + fragName + '" cannot be spread here as objects of ' + ('type "' + String(parentType) + '" can never be of type "' + String(fragType) + '".');
  11121. }
  11122. function typeIncompatibleAnonSpreadMessage(parentType, fragType) {
  11123. return 'Fragment cannot be spread here as objects of ' + ('type "' + String(parentType) + '" can never be of type "' + String(fragType) + '".');
  11124. }
  11125. /**
  11126. * Possible fragment spread
  11127. *
  11128. * A fragment spread is only valid if the type condition could ever possibly
  11129. * be true: if there is a non-empty intersection of the possible parent types,
  11130. * and possible types which pass the type condition.
  11131. */
  11132. function PossibleFragmentSpreads(context) {
  11133. return {
  11134. InlineFragment: function InlineFragment(node) {
  11135. var fragType = context.getType();
  11136. var parentType = context.getParentType();
  11137. if (fragType && parentType && !(0, _typeComparators.doTypesOverlap)(context.getSchema(), fragType, parentType)) {
  11138. context.reportError(new _error.GraphQLError(typeIncompatibleAnonSpreadMessage(parentType, fragType), [node]));
  11139. }
  11140. },
  11141. FragmentSpread: function FragmentSpread(node) {
  11142. var fragName = node.name.value;
  11143. var fragType = getFragmentType(context, fragName);
  11144. var parentType = context.getParentType();
  11145. if (fragType && parentType && !(0, _typeComparators.doTypesOverlap)(context.getSchema(), fragType, parentType)) {
  11146. context.reportError(new _error.GraphQLError(typeIncompatibleSpreadMessage(fragName, parentType, fragType), [node]));
  11147. }
  11148. }
  11149. };
  11150. }
  11151. function getFragmentType(context, name) {
  11152. var frag = context.getFragment(name);
  11153. return frag && (0, _typeFromAST.typeFromAST)(context.getSchema(), frag.typeCondition);
  11154. }
  11155. /***/ }),
  11156. /* 71 */
  11157. /***/ (function(module, exports, __webpack_require__) {
  11158. "use strict";
  11159. Object.defineProperty(exports, "__esModule", {
  11160. value: true
  11161. });
  11162. exports.missingFieldArgMessage = missingFieldArgMessage;
  11163. exports.missingDirectiveArgMessage = missingDirectiveArgMessage;
  11164. exports.ProvidedNonNullArguments = ProvidedNonNullArguments;
  11165. var _error = __webpack_require__(0);
  11166. var _keyMap = __webpack_require__(12);
  11167. var _keyMap2 = _interopRequireDefault(_keyMap);
  11168. var _definition = __webpack_require__(1);
  11169. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
  11170. /**
  11171. * Copyright (c) 2015, Facebook, Inc.
  11172. * All rights reserved.
  11173. *
  11174. * This source code is licensed under the BSD-style license found in the
  11175. * LICENSE file in the root directory of this source tree. An additional grant
  11176. * of patent rights can be found in the PATENTS file in the same directory.
  11177. */
  11178. function missingFieldArgMessage(fieldName, argName, type) {
  11179. return 'Field "' + fieldName + '" argument "' + argName + '" of type ' + ('"' + String(type) + '" is required but not provided.');
  11180. }
  11181. function missingDirectiveArgMessage(directiveName, argName, type) {
  11182. return 'Directive "@' + directiveName + '" argument "' + argName + '" of type ' + ('"' + String(type) + '" is required but not provided.');
  11183. }
  11184. /**
  11185. * Provided required arguments
  11186. *
  11187. * A field or directive is only valid if all required (non-null) field arguments
  11188. * have been provided.
  11189. */
  11190. function ProvidedNonNullArguments(context) {
  11191. return {
  11192. Field: {
  11193. // Validate on leave to allow for deeper errors to appear first.
  11194. leave: function leave(node) {
  11195. var fieldDef = context.getFieldDef();
  11196. if (!fieldDef) {
  11197. return false;
  11198. }
  11199. var argNodes = node.arguments || [];
  11200. var argNodeMap = (0, _keyMap2.default)(argNodes, function (arg) {
  11201. return arg.name.value;
  11202. });
  11203. fieldDef.args.forEach(function (argDef) {
  11204. var argNode = argNodeMap[argDef.name];
  11205. if (!argNode && argDef.type instanceof _definition.GraphQLNonNull) {
  11206. context.reportError(new _error.GraphQLError(missingFieldArgMessage(node.name.value, argDef.name, argDef.type), [node]));
  11207. }
  11208. });
  11209. }
  11210. },
  11211. Directive: {
  11212. // Validate on leave to allow for deeper errors to appear first.
  11213. leave: function leave(node) {
  11214. var directiveDef = context.getDirective();
  11215. if (!directiveDef) {
  11216. return false;
  11217. }
  11218. var argNodes = node.arguments || [];
  11219. var argNodeMap = (0, _keyMap2.default)(argNodes, function (arg) {
  11220. return arg.name.value;
  11221. });
  11222. directiveDef.args.forEach(function (argDef) {
  11223. var argNode = argNodeMap[argDef.name];
  11224. if (!argNode && argDef.type instanceof _definition.GraphQLNonNull) {
  11225. context.reportError(new _error.GraphQLError(missingDirectiveArgMessage(node.name.value, argDef.name, argDef.type), [node]));
  11226. }
  11227. });
  11228. }
  11229. }
  11230. };
  11231. }
  11232. /***/ }),
  11233. /* 72 */
  11234. /***/ (function(module, exports, __webpack_require__) {
  11235. "use strict";
  11236. Object.defineProperty(exports, "__esModule", {
  11237. value: true
  11238. });
  11239. exports.noSubselectionAllowedMessage = noSubselectionAllowedMessage;
  11240. exports.requiredSubselectionMessage = requiredSubselectionMessage;
  11241. exports.ScalarLeafs = ScalarLeafs;
  11242. var _error = __webpack_require__(0);
  11243. var _definition = __webpack_require__(1);
  11244. function noSubselectionAllowedMessage(fieldName, type) {
  11245. return 'Field "' + fieldName + '" must not have a selection since ' + ('type "' + String(type) + '" has no subfields.');
  11246. }
  11247. /**
  11248. * Copyright (c) 2015, Facebook, Inc.
  11249. * All rights reserved.
  11250. *
  11251. * This source code is licensed under the BSD-style license found in the
  11252. * LICENSE file in the root directory of this source tree. An additional grant
  11253. * of patent rights can be found in the PATENTS file in the same directory.
  11254. */
  11255. function requiredSubselectionMessage(fieldName, type) {
  11256. return 'Field "' + fieldName + '" of type "' + String(type) + '" must have a ' + ('selection of subfields. Did you mean "' + fieldName + ' { ... }"?');
  11257. }
  11258. /**
  11259. * Scalar leafs
  11260. *
  11261. * A GraphQL document is valid only if all leaf fields (fields without
  11262. * sub selections) are of scalar or enum types.
  11263. */
  11264. function ScalarLeafs(context) {
  11265. return {
  11266. Field: function Field(node) {
  11267. var type = context.getType();
  11268. if (type) {
  11269. if ((0, _definition.isLeafType)(type)) {
  11270. if (node.selectionSet) {
  11271. context.reportError(new _error.GraphQLError(noSubselectionAllowedMessage(node.name.value, type), [node.selectionSet]));
  11272. }
  11273. } else if (!node.selectionSet) {
  11274. context.reportError(new _error.GraphQLError(requiredSubselectionMessage(node.name.value, type), [node]));
  11275. }
  11276. }
  11277. }
  11278. };
  11279. }
  11280. /***/ }),
  11281. /* 73 */
  11282. /***/ (function(module, exports, __webpack_require__) {
  11283. "use strict";
  11284. Object.defineProperty(exports, "__esModule", {
  11285. value: true
  11286. });
  11287. exports.duplicateArgMessage = duplicateArgMessage;
  11288. exports.UniqueArgumentNames = UniqueArgumentNames;
  11289. var _error = __webpack_require__(0);
  11290. /**
  11291. * Copyright (c) 2015, Facebook, Inc.
  11292. * All rights reserved.
  11293. *
  11294. * This source code is licensed under the BSD-style license found in the
  11295. * LICENSE file in the root directory of this source tree. An additional grant
  11296. * of patent rights can be found in the PATENTS file in the same directory.
  11297. */
  11298. function duplicateArgMessage(argName) {
  11299. return 'There can be only one argument named "' + argName + '".';
  11300. }
  11301. /**
  11302. * Unique argument names
  11303. *
  11304. * A GraphQL field or directive is only valid if all supplied arguments are
  11305. * uniquely named.
  11306. */
  11307. function UniqueArgumentNames(context) {
  11308. var knownArgNames = Object.create(null);
  11309. return {
  11310. Field: function Field() {
  11311. knownArgNames = Object.create(null);
  11312. },
  11313. Directive: function Directive() {
  11314. knownArgNames = Object.create(null);
  11315. },
  11316. Argument: function Argument(node) {
  11317. var argName = node.name.value;
  11318. if (knownArgNames[argName]) {
  11319. context.reportError(new _error.GraphQLError(duplicateArgMessage(argName), [knownArgNames[argName], node.name]));
  11320. } else {
  11321. knownArgNames[argName] = node.name;
  11322. }
  11323. return false;
  11324. }
  11325. };
  11326. }
  11327. /***/ }),
  11328. /* 74 */
  11329. /***/ (function(module, exports, __webpack_require__) {
  11330. "use strict";
  11331. Object.defineProperty(exports, "__esModule", {
  11332. value: true
  11333. });
  11334. exports.duplicateDirectiveMessage = duplicateDirectiveMessage;
  11335. exports.UniqueDirectivesPerLocation = UniqueDirectivesPerLocation;
  11336. var _error = __webpack_require__(0);
  11337. /**
  11338. * Copyright (c) 2015, Facebook, Inc.
  11339. * All rights reserved.
  11340. *
  11341. * This source code is licensed under the BSD-style license found in the
  11342. * LICENSE file in the root directory of this source tree. An additional grant
  11343. * of patent rights can be found in the PATENTS file in the same directory.
  11344. */
  11345. function duplicateDirectiveMessage(directiveName) {
  11346. return 'The directive "' + directiveName + '" can only be used once at ' + 'this location.';
  11347. }
  11348. /**
  11349. * Unique directive names per location
  11350. *
  11351. * A GraphQL document is only valid if all directives at a given location
  11352. * are uniquely named.
  11353. */
  11354. function UniqueDirectivesPerLocation(context) {
  11355. return {
  11356. // Many different AST nodes may contain directives. Rather than listing
  11357. // them all, just listen for entering any node, and check to see if it
  11358. // defines any directives.
  11359. enter: function enter(node) {
  11360. if (node.directives) {
  11361. (function () {
  11362. var knownDirectives = Object.create(null);
  11363. node.directives.forEach(function (directive) {
  11364. var directiveName = directive.name.value;
  11365. if (knownDirectives[directiveName]) {
  11366. context.reportError(new _error.GraphQLError(duplicateDirectiveMessage(directiveName), [knownDirectives[directiveName], directive]));
  11367. } else {
  11368. knownDirectives[directiveName] = directive;
  11369. }
  11370. });
  11371. })();
  11372. }
  11373. }
  11374. };
  11375. }
  11376. /***/ }),
  11377. /* 75 */
  11378. /***/ (function(module, exports, __webpack_require__) {
  11379. "use strict";
  11380. Object.defineProperty(exports, "__esModule", {
  11381. value: true
  11382. });
  11383. exports.duplicateFragmentNameMessage = duplicateFragmentNameMessage;
  11384. exports.UniqueFragmentNames = UniqueFragmentNames;
  11385. var _error = __webpack_require__(0);
  11386. /**
  11387. * Copyright (c) 2015, Facebook, Inc.
  11388. * All rights reserved.
  11389. *
  11390. * This source code is licensed under the BSD-style license found in the
  11391. * LICENSE file in the root directory of this source tree. An additional grant
  11392. * of patent rights can be found in the PATENTS file in the same directory.
  11393. */
  11394. function duplicateFragmentNameMessage(fragName) {
  11395. return 'There can only be one fragment named "' + fragName + '".';
  11396. }
  11397. /**
  11398. * Unique fragment names
  11399. *
  11400. * A GraphQL document is only valid if all defined fragments have unique names.
  11401. */
  11402. function UniqueFragmentNames(context) {
  11403. var knownFragmentNames = Object.create(null);
  11404. return {
  11405. OperationDefinition: function OperationDefinition() {
  11406. return false;
  11407. },
  11408. FragmentDefinition: function FragmentDefinition(node) {
  11409. var fragmentName = node.name.value;
  11410. if (knownFragmentNames[fragmentName]) {
  11411. context.reportError(new _error.GraphQLError(duplicateFragmentNameMessage(fragmentName), [knownFragmentNames[fragmentName], node.name]));
  11412. } else {
  11413. knownFragmentNames[fragmentName] = node.name;
  11414. }
  11415. return false;
  11416. }
  11417. };
  11418. }
  11419. /***/ }),
  11420. /* 76 */
  11421. /***/ (function(module, exports, __webpack_require__) {
  11422. "use strict";
  11423. Object.defineProperty(exports, "__esModule", {
  11424. value: true
  11425. });
  11426. exports.duplicateInputFieldMessage = duplicateInputFieldMessage;
  11427. exports.UniqueInputFieldNames = UniqueInputFieldNames;
  11428. var _error = __webpack_require__(0);
  11429. /**
  11430. * Copyright (c) 2015, Facebook, Inc.
  11431. * All rights reserved.
  11432. *
  11433. * This source code is licensed under the BSD-style license found in the
  11434. * LICENSE file in the root directory of this source tree. An additional grant
  11435. * of patent rights can be found in the PATENTS file in the same directory.
  11436. */
  11437. function duplicateInputFieldMessage(fieldName) {
  11438. return 'There can be only one input field named "' + fieldName + '".';
  11439. }
  11440. /**
  11441. * Unique input field names
  11442. *
  11443. * A GraphQL input object value is only valid if all supplied fields are
  11444. * uniquely named.
  11445. */
  11446. function UniqueInputFieldNames(context) {
  11447. var knownNameStack = [];
  11448. var knownNames = Object.create(null);
  11449. return {
  11450. ObjectValue: {
  11451. enter: function enter() {
  11452. knownNameStack.push(knownNames);
  11453. knownNames = Object.create(null);
  11454. },
  11455. leave: function leave() {
  11456. knownNames = knownNameStack.pop();
  11457. }
  11458. },
  11459. ObjectField: function ObjectField(node) {
  11460. var fieldName = node.name.value;
  11461. if (knownNames[fieldName]) {
  11462. context.reportError(new _error.GraphQLError(duplicateInputFieldMessage(fieldName), [knownNames[fieldName], node.name]));
  11463. } else {
  11464. knownNames[fieldName] = node.name;
  11465. }
  11466. return false;
  11467. }
  11468. };
  11469. }
  11470. /***/ }),
  11471. /* 77 */
  11472. /***/ (function(module, exports, __webpack_require__) {
  11473. "use strict";
  11474. Object.defineProperty(exports, "__esModule", {
  11475. value: true
  11476. });
  11477. exports.duplicateOperationNameMessage = duplicateOperationNameMessage;
  11478. exports.UniqueOperationNames = UniqueOperationNames;
  11479. var _error = __webpack_require__(0);
  11480. /**
  11481. * Copyright (c) 2015, Facebook, Inc.
  11482. * All rights reserved.
  11483. *
  11484. * This source code is licensed under the BSD-style license found in the
  11485. * LICENSE file in the root directory of this source tree. An additional grant
  11486. * of patent rights can be found in the PATENTS file in the same directory.
  11487. */
  11488. function duplicateOperationNameMessage(operationName) {
  11489. return 'There can only be one operation named "' + operationName + '".';
  11490. }
  11491. /**
  11492. * Unique operation names
  11493. *
  11494. * A GraphQL document is only valid if all defined operations have unique names.
  11495. */
  11496. function UniqueOperationNames(context) {
  11497. var knownOperationNames = Object.create(null);
  11498. return {
  11499. OperationDefinition: function OperationDefinition(node) {
  11500. var operationName = node.name;
  11501. if (operationName) {
  11502. if (knownOperationNames[operationName.value]) {
  11503. context.reportError(new _error.GraphQLError(duplicateOperationNameMessage(operationName.value), [knownOperationNames[operationName.value], operationName]));
  11504. } else {
  11505. knownOperationNames[operationName.value] = operationName;
  11506. }
  11507. }
  11508. return false;
  11509. },
  11510. FragmentDefinition: function FragmentDefinition() {
  11511. return false;
  11512. }
  11513. };
  11514. }
  11515. /***/ }),
  11516. /* 78 */
  11517. /***/ (function(module, exports, __webpack_require__) {
  11518. "use strict";
  11519. Object.defineProperty(exports, "__esModule", {
  11520. value: true
  11521. });
  11522. exports.duplicateVariableMessage = duplicateVariableMessage;
  11523. exports.UniqueVariableNames = UniqueVariableNames;
  11524. var _error = __webpack_require__(0);
  11525. function duplicateVariableMessage(variableName) {
  11526. return 'There can be only one variable named "' + variableName + '".';
  11527. }
  11528. /**
  11529. * Unique variable names
  11530. *
  11531. * A GraphQL operation is only valid if all its variables are uniquely named.
  11532. */
  11533. /**
  11534. * Copyright (c) 2015, Facebook, Inc.
  11535. * All rights reserved.
  11536. *
  11537. * This source code is licensed under the BSD-style license found in the
  11538. * LICENSE file in the root directory of this source tree. An additional grant
  11539. * of patent rights can be found in the PATENTS file in the same directory.
  11540. */
  11541. function UniqueVariableNames(context) {
  11542. var knownVariableNames = Object.create(null);
  11543. return {
  11544. OperationDefinition: function OperationDefinition() {
  11545. knownVariableNames = Object.create(null);
  11546. },
  11547. VariableDefinition: function VariableDefinition(node) {
  11548. var variableName = node.variable.name.value;
  11549. if (knownVariableNames[variableName]) {
  11550. context.reportError(new _error.GraphQLError(duplicateVariableMessage(variableName), [knownVariableNames[variableName], node.variable.name]));
  11551. } else {
  11552. knownVariableNames[variableName] = node.variable.name;
  11553. }
  11554. }
  11555. };
  11556. }
  11557. /***/ }),
  11558. /* 79 */
  11559. /***/ (function(module, exports, __webpack_require__) {
  11560. "use strict";
  11561. Object.defineProperty(exports, "__esModule", {
  11562. value: true
  11563. });
  11564. exports.nonInputTypeOnVarMessage = nonInputTypeOnVarMessage;
  11565. exports.VariablesAreInputTypes = VariablesAreInputTypes;
  11566. var _error = __webpack_require__(0);
  11567. var _printer = __webpack_require__(4);
  11568. var _definition = __webpack_require__(1);
  11569. var _typeFromAST = __webpack_require__(9);
  11570. function nonInputTypeOnVarMessage(variableName, typeName) {
  11571. return 'Variable "$' + variableName + '" cannot be non-input type "' + typeName + '".';
  11572. }
  11573. /**
  11574. * Variables are input types
  11575. *
  11576. * A GraphQL operation is only valid if all the variables it defines are of
  11577. * input types (scalar, enum, or input object).
  11578. */
  11579. /**
  11580. * Copyright (c) 2015, Facebook, Inc.
  11581. * All rights reserved.
  11582. *
  11583. * This source code is licensed under the BSD-style license found in the
  11584. * LICENSE file in the root directory of this source tree. An additional grant
  11585. * of patent rights can be found in the PATENTS file in the same directory.
  11586. */
  11587. function VariablesAreInputTypes(context) {
  11588. return {
  11589. VariableDefinition: function VariableDefinition(node) {
  11590. var type = (0, _typeFromAST.typeFromAST)(context.getSchema(), node.type);
  11591. // If the variable type is not an input type, return an error.
  11592. if (type && !(0, _definition.isInputType)(type)) {
  11593. var variableName = node.variable.name.value;
  11594. context.reportError(new _error.GraphQLError(nonInputTypeOnVarMessage(variableName, (0, _printer.print)(node.type)), [node.type]));
  11595. }
  11596. }
  11597. };
  11598. }
  11599. /***/ }),
  11600. /* 80 */
  11601. /***/ (function(module, exports, __webpack_require__) {
  11602. "use strict";
  11603. Object.defineProperty(exports, "__esModule", {
  11604. value: true
  11605. });
  11606. exports.badVarPosMessage = badVarPosMessage;
  11607. exports.VariablesInAllowedPosition = VariablesInAllowedPosition;
  11608. var _error = __webpack_require__(0);
  11609. var _definition = __webpack_require__(1);
  11610. var _typeComparators = __webpack_require__(19);
  11611. var _typeFromAST = __webpack_require__(9);
  11612. function badVarPosMessage(varName, varType, expectedType) {
  11613. return 'Variable "$' + varName + '" of type "' + String(varType) + '" used in ' + ('position expecting type "' + String(expectedType) + '".');
  11614. }
  11615. /**
  11616. * Variables passed to field arguments conform to type
  11617. */
  11618. /**
  11619. * Copyright (c) 2015, Facebook, Inc.
  11620. * All rights reserved.
  11621. *
  11622. * This source code is licensed under the BSD-style license found in the
  11623. * LICENSE file in the root directory of this source tree. An additional grant
  11624. * of patent rights can be found in the PATENTS file in the same directory.
  11625. */
  11626. function VariablesInAllowedPosition(context) {
  11627. var varDefMap = Object.create(null);
  11628. return {
  11629. OperationDefinition: {
  11630. enter: function enter() {
  11631. varDefMap = Object.create(null);
  11632. },
  11633. leave: function leave(operation) {
  11634. var usages = context.getRecursiveVariableUsages(operation);
  11635. usages.forEach(function (_ref) {
  11636. var node = _ref.node,
  11637. type = _ref.type;
  11638. var varName = node.name.value;
  11639. var varDef = varDefMap[varName];
  11640. if (varDef && type) {
  11641. // A var type is allowed if it is the same or more strict (e.g. is
  11642. // a subtype of) than the expected type. It can be more strict if
  11643. // the variable type is non-null when the expected type is nullable.
  11644. // If both are list types, the variable item type can be more strict
  11645. // than the expected item type (contravariant).
  11646. var schema = context.getSchema();
  11647. var varType = (0, _typeFromAST.typeFromAST)(schema, varDef.type);
  11648. if (varType && !(0, _typeComparators.isTypeSubTypeOf)(schema, effectiveType(varType, varDef), type)) {
  11649. context.reportError(new _error.GraphQLError(badVarPosMessage(varName, varType, type), [varDef, node]));
  11650. }
  11651. }
  11652. });
  11653. }
  11654. },
  11655. VariableDefinition: function VariableDefinition(node) {
  11656. varDefMap[node.variable.name.value] = node;
  11657. }
  11658. };
  11659. }
  11660. // If a variable definition has a default value, it's effectively non-null.
  11661. function effectiveType(varType, varDef) {
  11662. return !varDef.defaultValue || varType instanceof _definition.GraphQLNonNull ? varType : new _definition.GraphQLNonNull(varType);
  11663. }
  11664. /***/ })
  11665. /******/ ]);