123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515 |
- var GraphiQLSubscriptionsFetcher =
- /******/ (function(modules) { // webpackBootstrap
- /******/ // The module cache
- /******/ var installedModules = {};
- /******/
- /******/ // The require function
- /******/ function __webpack_require__(moduleId) {
- /******/
- /******/ // Check if module is in cache
- /******/ if(installedModules[moduleId])
- /******/ return installedModules[moduleId].exports;
- /******/
- /******/ // Create a new module (and put it into the cache)
- /******/ var module = installedModules[moduleId] = {
- /******/ i: moduleId,
- /******/ l: false,
- /******/ exports: {}
- /******/ };
- /******/
- /******/ // Execute the module function
- /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
- /******/
- /******/ // Flag the module as loaded
- /******/ module.l = true;
- /******/
- /******/ // Return the exports of the module
- /******/ return module.exports;
- /******/ }
- /******/
- /******/
- /******/ // expose the modules object (__webpack_modules__)
- /******/ __webpack_require__.m = modules;
- /******/
- /******/ // expose the module cache
- /******/ __webpack_require__.c = installedModules;
- /******/
- /******/ // identity function for calling harmony imports with the correct context
- /******/ __webpack_require__.i = function(value) { return value; };
- /******/
- /******/ // define getter function for harmony exports
- /******/ __webpack_require__.d = function(exports, name, getter) {
- /******/ if(!__webpack_require__.o(exports, name)) {
- /******/ Object.defineProperty(exports, name, {
- /******/ configurable: false,
- /******/ enumerable: true,
- /******/ get: getter
- /******/ });
- /******/ }
- /******/ };
- /******/
- /******/ // getDefaultExport function for compatibility with non-harmony modules
- /******/ __webpack_require__.n = function(module) {
- /******/ var getter = module && module.__esModule ?
- /******/ function getDefault() { return module['default']; } :
- /******/ function getModuleExports() { return module; };
- /******/ __webpack_require__.d(getter, 'a', getter);
- /******/ return getter;
- /******/ };
- /******/
- /******/ // Object.prototype.hasOwnProperty.call
- /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
- /******/
- /******/ // __webpack_public_path__
- /******/ __webpack_require__.p = "";
- /******/
- /******/ // Load entry module and return exports
- /******/ return __webpack_require__(__webpack_require__.s = 37);
- /******/ })
- /************************************************************************/
- /******/ ([
- /* 0 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- var _GraphQLError = __webpack_require__(13);
- Object.defineProperty(exports, 'GraphQLError', {
- enumerable: true,
- get: function get() {
- return _GraphQLError.GraphQLError;
- }
- });
- var _syntaxError = __webpack_require__(40);
- Object.defineProperty(exports, 'syntaxError', {
- enumerable: true,
- get: function get() {
- return _syntaxError.syntaxError;
- }
- });
- var _locatedError = __webpack_require__(39);
- Object.defineProperty(exports, 'locatedError', {
- enumerable: true,
- get: function get() {
- return _locatedError.locatedError;
- }
- });
- var _formatError = __webpack_require__(38);
- Object.defineProperty(exports, 'formatError', {
- enumerable: true,
- get: function get() {
- return _formatError.formatError;
- }
- });
- /***/ }),
- /* 1 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.GraphQLNonNull = exports.GraphQLList = exports.GraphQLInputObjectType = exports.GraphQLEnumType = exports.GraphQLUnionType = exports.GraphQLInterfaceType = exports.GraphQLObjectType = exports.GraphQLScalarType = undefined;
- 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; };
- exports.isType = isType;
- exports.assertType = assertType;
- exports.isInputType = isInputType;
- exports.assertInputType = assertInputType;
- exports.isOutputType = isOutputType;
- exports.assertOutputType = assertOutputType;
- exports.isLeafType = isLeafType;
- exports.assertLeafType = assertLeafType;
- exports.isCompositeType = isCompositeType;
- exports.assertCompositeType = assertCompositeType;
- exports.isAbstractType = isAbstractType;
- exports.assertAbstractType = assertAbstractType;
- exports.getNullableType = getNullableType;
- exports.isNamedType = isNamedType;
- exports.assertNamedType = assertNamedType;
- exports.getNamedType = getNamedType;
- var _invariant = __webpack_require__(3);
- var _invariant2 = _interopRequireDefault(_invariant);
- var _isNullish = __webpack_require__(6);
- var _isNullish2 = _interopRequireDefault(_isNullish);
- var _kinds = __webpack_require__(2);
- var _assertValidName = __webpack_require__(28);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- // Predicates & Assertions
- /**
- * These are all of the possible kinds of types.
- */
- function isType(type) {
- 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;
- }
- function assertType(type) {
- (0, _invariant2.default)(isType(type), 'Expected ' + String(type) + ' to be a GraphQL type.');
- return type;
- }
- /**
- * These types may be used as input types for arguments and directives.
- */
- function isInputType(type) {
- var namedType = getNamedType(type);
- return namedType instanceof GraphQLScalarType || namedType instanceof GraphQLEnumType || namedType instanceof GraphQLInputObjectType;
- }
- function assertInputType(type) {
- (0, _invariant2.default)(isInputType(type), 'Expected ' + String(type) + ' to be a GraphQL input type.');
- return type;
- }
- /**
- * These types may be used as output types as the result of fields.
- */
- function isOutputType(type) {
- var namedType = getNamedType(type);
- return namedType instanceof GraphQLScalarType || namedType instanceof GraphQLObjectType || namedType instanceof GraphQLInterfaceType || namedType instanceof GraphQLUnionType || namedType instanceof GraphQLEnumType;
- }
- function assertOutputType(type) {
- (0, _invariant2.default)(isOutputType(type), 'Expected ' + String(type) + ' to be a GraphQL output type.');
- return type;
- }
- /**
- * These types may describe types which may be leaf values.
- */
- function isLeafType(type) {
- var namedType = getNamedType(type);
- return namedType instanceof GraphQLScalarType || namedType instanceof GraphQLEnumType;
- }
- function assertLeafType(type) {
- (0, _invariant2.default)(isLeafType(type), 'Expected ' + String(type) + ' to be a GraphQL leaf type.');
- return type;
- }
- /**
- * These types may describe the parent context of a selection set.
- */
- function isCompositeType(type) {
- return type instanceof GraphQLObjectType || type instanceof GraphQLInterfaceType || type instanceof GraphQLUnionType;
- }
- function assertCompositeType(type) {
- (0, _invariant2.default)(isCompositeType(type), 'Expected ' + String(type) + ' to be a GraphQL composite type.');
- return type;
- }
- /**
- * These types may describe the parent context of a selection set.
- */
- function isAbstractType(type) {
- return type instanceof GraphQLInterfaceType || type instanceof GraphQLUnionType;
- }
- function assertAbstractType(type) {
- (0, _invariant2.default)(isAbstractType(type), 'Expected ' + String(type) + ' to be a GraphQL abstract type.');
- return type;
- }
- /**
- * These types can all accept null as a value.
- */
- function getNullableType(type) {
- return type instanceof GraphQLNonNull ? type.ofType : type;
- }
- /**
- * These named types do not include modifiers like List or NonNull.
- */
- function isNamedType(type) {
- return type instanceof GraphQLScalarType || type instanceof GraphQLObjectType || type instanceof GraphQLInterfaceType || type instanceof GraphQLUnionType || type instanceof GraphQLEnumType || type instanceof GraphQLInputObjectType;
- }
- function assertNamedType(type) {
- (0, _invariant2.default)(isNamedType(type), 'Expected ' + String(type) + ' to be a GraphQL named type.');
- return type;
- }
- function getNamedType(type) {
- var unmodifiedType = type;
- while (unmodifiedType instanceof GraphQLList || unmodifiedType instanceof GraphQLNonNull) {
- unmodifiedType = unmodifiedType.ofType;
- }
- return unmodifiedType;
- }
- /**
- * Used while defining GraphQL types to allow for circular references in
- * otherwise immutable type definitions.
- */
- function resolveThunk(thunk) {
- return typeof thunk === 'function' ? thunk() : thunk;
- }
- /**
- * Scalar Type Definition
- *
- * The leaf values of any request and input values to arguments are
- * Scalars (or Enums) and are defined with a name and a series of functions
- * used to parse input from ast or variables and to ensure validity.
- *
- * Example:
- *
- * const OddType = new GraphQLScalarType({
- * name: 'Odd',
- * serialize(value) {
- * return value % 2 === 1 ? value : null;
- * }
- * });
- *
- */
- var GraphQLScalarType = exports.GraphQLScalarType = function () {
- function GraphQLScalarType(config) {
- _classCallCheck(this, GraphQLScalarType);
- (0, _assertValidName.assertValidName)(config.name);
- this.name = config.name;
- this.description = config.description;
- (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.');
- if (config.parseValue || config.parseLiteral) {
- (0, _invariant2.default)(typeof config.parseValue === 'function' && typeof config.parseLiteral === 'function', this.name + ' must provide both "parseValue" and "parseLiteral" ' + 'functions.');
- }
- this._scalarConfig = config;
- }
- // Serializes an internal value to include in a response.
- GraphQLScalarType.prototype.serialize = function serialize(value) {
- var serializer = this._scalarConfig.serialize;
- return serializer(value);
- };
- // Parses an externally provided value to use as an input.
- GraphQLScalarType.prototype.parseValue = function parseValue(value) {
- var parser = this._scalarConfig.parseValue;
- return parser ? parser(value) : null;
- };
- // Parses an externally provided literal value to use as an input.
- GraphQLScalarType.prototype.parseLiteral = function parseLiteral(valueNode) {
- var parser = this._scalarConfig.parseLiteral;
- return parser ? parser(valueNode) : null;
- };
- GraphQLScalarType.prototype.toString = function toString() {
- return this.name;
- };
- return GraphQLScalarType;
- }();
- // Also provide toJSON and inspect aliases for toString.
- GraphQLScalarType.prototype.toJSON = GraphQLScalarType.prototype.inspect = GraphQLScalarType.prototype.toString;
- /**
- * Object Type Definition
- *
- * Almost all of the GraphQL types you define will be object types. Object types
- * have a name, but most importantly describe their fields.
- *
- * Example:
- *
- * const AddressType = new GraphQLObjectType({
- * name: 'Address',
- * fields: {
- * street: { type: GraphQLString },
- * number: { type: GraphQLInt },
- * formatted: {
- * type: GraphQLString,
- * resolve(obj) {
- * return obj.number + ' ' + obj.street
- * }
- * }
- * }
- * });
- *
- * When two types need to refer to each other, or a type needs to refer to
- * itself in a field, you can use a function expression (aka a closure or a
- * thunk) to supply the fields lazily.
- *
- * Example:
- *
- * const PersonType = new GraphQLObjectType({
- * name: 'Person',
- * fields: () => ({
- * name: { type: GraphQLString },
- * bestFriend: { type: PersonType },
- * })
- * });
- *
- */
- var GraphQLObjectType = exports.GraphQLObjectType = function () {
- function GraphQLObjectType(config) {
- _classCallCheck(this, GraphQLObjectType);
- (0, _assertValidName.assertValidName)(config.name, config.isIntrospection);
- this.name = config.name;
- this.description = config.description;
- if (config.isTypeOf) {
- (0, _invariant2.default)(typeof config.isTypeOf === 'function', this.name + ' must provide "isTypeOf" as a function.');
- }
- this.isTypeOf = config.isTypeOf;
- this._typeConfig = config;
- }
- GraphQLObjectType.prototype.getFields = function getFields() {
- return this._fields || (this._fields = defineFieldMap(this, this._typeConfig.fields));
- };
- GraphQLObjectType.prototype.getInterfaces = function getInterfaces() {
- return this._interfaces || (this._interfaces = defineInterfaces(this, this._typeConfig.interfaces));
- };
- GraphQLObjectType.prototype.toString = function toString() {
- return this.name;
- };
- return GraphQLObjectType;
- }();
- // Also provide toJSON and inspect aliases for toString.
- GraphQLObjectType.prototype.toJSON = GraphQLObjectType.prototype.inspect = GraphQLObjectType.prototype.toString;
- function defineInterfaces(type, interfacesThunk) {
- var interfaces = resolveThunk(interfacesThunk);
- if (!interfaces) {
- return [];
- }
- (0, _invariant2.default)(Array.isArray(interfaces), type.name + ' interfaces must be an Array or a function which returns ' + 'an Array.');
- interfaces.forEach(function (iface) {
- (0, _invariant2.default)(iface instanceof GraphQLInterfaceType, type.name + ' may only implement Interface types, it cannot ' + ('implement: ' + String(iface) + '.'));
- if (typeof iface.resolveType !== 'function') {
- (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.');
- }
- });
- return interfaces;
- }
- function defineFieldMap(type, fieldsThunk) {
- var fieldMap = resolveThunk(fieldsThunk);
- (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.');
- var fieldNames = Object.keys(fieldMap);
- (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.');
- var resultFieldMap = {};
- fieldNames.forEach(function (fieldName) {
- (0, _assertValidName.assertValidName)(fieldName);
- var fieldConfig = fieldMap[fieldName];
- (0, _invariant2.default)(!fieldConfig.hasOwnProperty('isDeprecated'), type.name + '.' + fieldName + ' should provide "deprecationReason" instead ' + 'of "isDeprecated".');
- var field = _extends({}, fieldConfig, {
- isDeprecated: Boolean(fieldConfig.deprecationReason),
- name: fieldName
- });
- (0, _invariant2.default)(isOutputType(field.type), type.name + '.' + fieldName + ' field type must be Output Type but ' + ('got: ' + String(field.type) + '.'));
- (0, _invariant2.default)(isValidResolver(field.resolve), type.name + '.' + fieldName + ' field resolver must be a function if ' + ('provided, but got: ' + String(field.resolve) + '.'));
- var argsConfig = fieldConfig.args;
- if (!argsConfig) {
- field.args = [];
- } else {
- (0, _invariant2.default)(isPlainObj(argsConfig), type.name + '.' + fieldName + ' args must be an object with argument ' + 'names as keys.');
- field.args = Object.keys(argsConfig).map(function (argName) {
- (0, _assertValidName.assertValidName)(argName);
- var arg = argsConfig[argName];
- (0, _invariant2.default)(isInputType(arg.type), type.name + '.' + fieldName + '(' + argName + ':) argument type must be ' + ('Input Type but got: ' + String(arg.type) + '.'));
- return {
- name: argName,
- description: arg.description === undefined ? null : arg.description,
- type: arg.type,
- defaultValue: arg.defaultValue
- };
- });
- }
- resultFieldMap[fieldName] = field;
- });
- return resultFieldMap;
- }
- function isPlainObj(obj) {
- return obj && typeof obj === 'object' && !Array.isArray(obj);
- }
- // If a resolver is defined, it must be a function.
- function isValidResolver(resolver) {
- return resolver == null || typeof resolver === 'function';
- }
- /**
- * Interface Type Definition
- *
- * When a field can return one of a heterogeneous set of types, a Interface type
- * is used to describe what types are possible, what fields are in common across
- * all types, as well as a function to determine which type is actually used
- * when the field is resolved.
- *
- * Example:
- *
- * const EntityType = new GraphQLInterfaceType({
- * name: 'Entity',
- * fields: {
- * name: { type: GraphQLString }
- * }
- * });
- *
- */
- var GraphQLInterfaceType = exports.GraphQLInterfaceType = function () {
- function GraphQLInterfaceType(config) {
- _classCallCheck(this, GraphQLInterfaceType);
- (0, _assertValidName.assertValidName)(config.name);
- this.name = config.name;
- this.description = config.description;
- if (config.resolveType) {
- (0, _invariant2.default)(typeof config.resolveType === 'function', this.name + ' must provide "resolveType" as a function.');
- }
- this.resolveType = config.resolveType;
- this._typeConfig = config;
- }
- GraphQLInterfaceType.prototype.getFields = function getFields() {
- return this._fields || (this._fields = defineFieldMap(this, this._typeConfig.fields));
- };
- GraphQLInterfaceType.prototype.toString = function toString() {
- return this.name;
- };
- return GraphQLInterfaceType;
- }();
- // Also provide toJSON and inspect aliases for toString.
- GraphQLInterfaceType.prototype.toJSON = GraphQLInterfaceType.prototype.inspect = GraphQLInterfaceType.prototype.toString;
- /**
- * Union Type Definition
- *
- * When a field can return one of a heterogeneous set of types, a Union type
- * is used to describe what types are possible as well as providing a function
- * to determine which type is actually used when the field is resolved.
- *
- * Example:
- *
- * const PetType = new GraphQLUnionType({
- * name: 'Pet',
- * types: [ DogType, CatType ],
- * resolveType(value) {
- * if (value instanceof Dog) {
- * return DogType;
- * }
- * if (value instanceof Cat) {
- * return CatType;
- * }
- * }
- * });
- *
- */
- var GraphQLUnionType = exports.GraphQLUnionType = function () {
- function GraphQLUnionType(config) {
- _classCallCheck(this, GraphQLUnionType);
- (0, _assertValidName.assertValidName)(config.name);
- this.name = config.name;
- this.description = config.description;
- if (config.resolveType) {
- (0, _invariant2.default)(typeof config.resolveType === 'function', this.name + ' must provide "resolveType" as a function.');
- }
- this.resolveType = config.resolveType;
- this._typeConfig = config;
- }
- GraphQLUnionType.prototype.getTypes = function getTypes() {
- return this._types || (this._types = defineTypes(this, this._typeConfig.types));
- };
- GraphQLUnionType.prototype.toString = function toString() {
- return this.name;
- };
- return GraphQLUnionType;
- }();
- // Also provide toJSON and inspect aliases for toString.
- GraphQLUnionType.prototype.toJSON = GraphQLUnionType.prototype.inspect = GraphQLUnionType.prototype.toString;
- function defineTypes(unionType, typesThunk) {
- var types = resolveThunk(typesThunk);
- (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 + '.'));
- types.forEach(function (objType) {
- (0, _invariant2.default)(objType instanceof GraphQLObjectType, unionType.name + ' may only contain Object types, it cannot contain: ' + (String(objType) + '.'));
- if (typeof unionType.resolveType !== 'function') {
- (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.');
- }
- });
- return types;
- }
- /**
- * Enum Type Definition
- *
- * Some leaf values of requests and input values are Enums. GraphQL serializes
- * Enum values as strings, however internally Enums can be represented by any
- * kind of type, often integers.
- *
- * Example:
- *
- * const RGBType = new GraphQLEnumType({
- * name: 'RGB',
- * values: {
- * RED: { value: 0 },
- * GREEN: { value: 1 },
- * BLUE: { value: 2 }
- * }
- * });
- *
- * Note: If a value is not provided in a definition, the name of the enum value
- * will be used as its internal value.
- */
- var GraphQLEnumType /* <T> */ = exports.GraphQLEnumType = function () {
- function GraphQLEnumType(config /* <T> */) {
- _classCallCheck(this, GraphQLEnumType);
- this.name = config.name;
- (0, _assertValidName.assertValidName)(config.name, config.isIntrospection);
- this.description = config.description;
- this._values = defineEnumValues(this, config.values);
- this._enumConfig = config;
- }
- GraphQLEnumType.prototype.getValues = function getValues() {
- return this._values;
- };
- GraphQLEnumType.prototype.getValue = function getValue(name) {
- return this._getNameLookup()[name];
- };
- GraphQLEnumType.prototype.serialize = function serialize(value /* T */) {
- var enumValue = this._getValueLookup().get(value);
- return enumValue ? enumValue.name : null;
- };
- GraphQLEnumType.prototype.parseValue = function parseValue(value) /* T */{
- if (typeof value === 'string') {
- var enumValue = this._getNameLookup()[value];
- if (enumValue) {
- return enumValue.value;
- }
- }
- };
- GraphQLEnumType.prototype.parseLiteral = function parseLiteral(valueNode) /* T */{
- if (valueNode.kind === _kinds.ENUM) {
- var enumValue = this._getNameLookup()[valueNode.value];
- if (enumValue) {
- return enumValue.value;
- }
- }
- };
- GraphQLEnumType.prototype._getValueLookup = function _getValueLookup() {
- var _this = this;
- if (!this._valueLookup) {
- (function () {
- var lookup = new Map();
- _this.getValues().forEach(function (value) {
- lookup.set(value.value, value);
- });
- _this._valueLookup = lookup;
- })();
- }
- return this._valueLookup;
- };
- GraphQLEnumType.prototype._getNameLookup = function _getNameLookup() {
- var _this2 = this;
- if (!this._nameLookup) {
- (function () {
- var lookup = Object.create(null);
- _this2.getValues().forEach(function (value) {
- lookup[value.name] = value;
- });
- _this2._nameLookup = lookup;
- })();
- }
- return this._nameLookup;
- };
- GraphQLEnumType.prototype.toString = function toString() {
- return this.name;
- };
- return GraphQLEnumType;
- }();
- // Also provide toJSON and inspect aliases for toString.
- GraphQLEnumType.prototype.toJSON = GraphQLEnumType.prototype.inspect = GraphQLEnumType.prototype.toString;
- function defineEnumValues(type, valueMap /* <T> */
- ) {
- (0, _invariant2.default)(isPlainObj(valueMap), type.name + ' values must be an object with value names as keys.');
- var valueNames = Object.keys(valueMap);
- (0, _invariant2.default)(valueNames.length > 0, type.name + ' values must be an object with value names as keys.');
- return valueNames.map(function (valueName) {
- (0, _assertValidName.assertValidName)(valueName);
- var value = valueMap[valueName];
- (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) + '.'));
- (0, _invariant2.default)(!value.hasOwnProperty('isDeprecated'), type.name + '.' + valueName + ' should provide "deprecationReason" instead ' + 'of "isDeprecated".');
- return {
- name: valueName,
- description: value.description,
- isDeprecated: Boolean(value.deprecationReason),
- deprecationReason: value.deprecationReason,
- value: (0, _isNullish2.default)(value.value) ? valueName : value.value
- };
- });
- } /* <T> */
- /**
- * Input Object Type Definition
- *
- * An input object defines a structured collection of fields which may be
- * supplied to a field argument.
- *
- * Using `NonNull` will ensure that a value must be provided by the query
- *
- * Example:
- *
- * const GeoPoint = new GraphQLInputObjectType({
- * name: 'GeoPoint',
- * fields: {
- * lat: { type: new GraphQLNonNull(GraphQLFloat) },
- * lon: { type: new GraphQLNonNull(GraphQLFloat) },
- * alt: { type: GraphQLFloat, defaultValue: 0 },
- * }
- * });
- *
- */
- var GraphQLInputObjectType = exports.GraphQLInputObjectType = function () {
- function GraphQLInputObjectType(config) {
- _classCallCheck(this, GraphQLInputObjectType);
- (0, _assertValidName.assertValidName)(config.name);
- this.name = config.name;
- this.description = config.description;
- this._typeConfig = config;
- }
- GraphQLInputObjectType.prototype.getFields = function getFields() {
- return this._fields || (this._fields = this._defineFieldMap());
- };
- GraphQLInputObjectType.prototype._defineFieldMap = function _defineFieldMap() {
- var _this3 = this;
- var fieldMap = resolveThunk(this._typeConfig.fields);
- (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.');
- var fieldNames = Object.keys(fieldMap);
- (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.');
- var resultFieldMap = {};
- fieldNames.forEach(function (fieldName) {
- (0, _assertValidName.assertValidName)(fieldName);
- var field = _extends({}, fieldMap[fieldName], {
- name: fieldName
- });
- (0, _invariant2.default)(isInputType(field.type), _this3.name + '.' + fieldName + ' field type must be Input Type but ' + ('got: ' + String(field.type) + '.'));
- (0, _invariant2.default)(field.resolve == null, _this3.name + '.' + fieldName + ' field type has a resolve property, but ' + 'Input Types cannot define resolvers.');
- resultFieldMap[fieldName] = field;
- });
- return resultFieldMap;
- };
- GraphQLInputObjectType.prototype.toString = function toString() {
- return this.name;
- };
- return GraphQLInputObjectType;
- }();
- // Also provide toJSON and inspect aliases for toString.
- GraphQLInputObjectType.prototype.toJSON = GraphQLInputObjectType.prototype.inspect = GraphQLInputObjectType.prototype.toString;
- /**
- * List Modifier
- *
- * A list is a kind of type marker, a wrapping type which points to another
- * type. Lists are often created within the context of defining the fields of
- * an object type.
- *
- * Example:
- *
- * const PersonType = new GraphQLObjectType({
- * name: 'Person',
- * fields: () => ({
- * parents: { type: new GraphQLList(Person) },
- * children: { type: new GraphQLList(Person) },
- * })
- * })
- *
- */
- var GraphQLList = exports.GraphQLList = function () {
- function GraphQLList(type) {
- _classCallCheck(this, GraphQLList);
- (0, _invariant2.default)(isType(type), 'Can only create List of a GraphQLType but got: ' + String(type) + '.');
- this.ofType = type;
- }
- GraphQLList.prototype.toString = function toString() {
- return '[' + String(this.ofType) + ']';
- };
- return GraphQLList;
- }();
- // Also provide toJSON and inspect aliases for toString.
- GraphQLList.prototype.toJSON = GraphQLList.prototype.inspect = GraphQLList.prototype.toString;
- /**
- * Non-Null Modifier
- *
- * A non-null is a kind of type marker, a wrapping type which points to another
- * type. Non-null types enforce that their values are never null and can ensure
- * an error is raised if this ever occurs during a request. It is useful for
- * fields which you can make a strong guarantee on non-nullability, for example
- * usually the id field of a database row will never be null.
- *
- * Example:
- *
- * const RowType = new GraphQLObjectType({
- * name: 'Row',
- * fields: () => ({
- * id: { type: new GraphQLNonNull(GraphQLString) },
- * })
- * })
- *
- * Note: the enforcement of non-nullability occurs within the executor.
- */
- var GraphQLNonNull = exports.GraphQLNonNull = function () {
- function GraphQLNonNull(type) {
- _classCallCheck(this, GraphQLNonNull);
- (0, _invariant2.default)(isType(type) && !(type instanceof GraphQLNonNull), 'Can only create NonNull of a Nullable GraphQLType but got: ' + (String(type) + '.'));
- this.ofType = type;
- }
- GraphQLNonNull.prototype.toString = function toString() {
- return this.ofType.toString() + '!';
- };
- return GraphQLNonNull;
- }();
- // Also provide toJSON and inspect aliases for toString.
- GraphQLNonNull.prototype.toJSON = GraphQLNonNull.prototype.inspect = GraphQLNonNull.prototype.toString;
- /***/ }),
- /* 2 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- // Name
- var NAME = exports.NAME = 'Name';
- // Document
- var DOCUMENT = exports.DOCUMENT = 'Document';
- var OPERATION_DEFINITION = exports.OPERATION_DEFINITION = 'OperationDefinition';
- var VARIABLE_DEFINITION = exports.VARIABLE_DEFINITION = 'VariableDefinition';
- var VARIABLE = exports.VARIABLE = 'Variable';
- var SELECTION_SET = exports.SELECTION_SET = 'SelectionSet';
- var FIELD = exports.FIELD = 'Field';
- var ARGUMENT = exports.ARGUMENT = 'Argument';
- // Fragments
- var FRAGMENT_SPREAD = exports.FRAGMENT_SPREAD = 'FragmentSpread';
- var INLINE_FRAGMENT = exports.INLINE_FRAGMENT = 'InlineFragment';
- var FRAGMENT_DEFINITION = exports.FRAGMENT_DEFINITION = 'FragmentDefinition';
- // Values
- var INT = exports.INT = 'IntValue';
- var FLOAT = exports.FLOAT = 'FloatValue';
- var STRING = exports.STRING = 'StringValue';
- var BOOLEAN = exports.BOOLEAN = 'BooleanValue';
- var NULL = exports.NULL = 'NullValue';
- var ENUM = exports.ENUM = 'EnumValue';
- var LIST = exports.LIST = 'ListValue';
- var OBJECT = exports.OBJECT = 'ObjectValue';
- var OBJECT_FIELD = exports.OBJECT_FIELD = 'ObjectField';
- // Directives
- var DIRECTIVE = exports.DIRECTIVE = 'Directive';
- // Types
- var NAMED_TYPE = exports.NAMED_TYPE = 'NamedType';
- var LIST_TYPE = exports.LIST_TYPE = 'ListType';
- var NON_NULL_TYPE = exports.NON_NULL_TYPE = 'NonNullType';
- // Type System Definitions
- var SCHEMA_DEFINITION = exports.SCHEMA_DEFINITION = 'SchemaDefinition';
- var OPERATION_TYPE_DEFINITION = exports.OPERATION_TYPE_DEFINITION = 'OperationTypeDefinition';
- // Type Definitions
- var SCALAR_TYPE_DEFINITION = exports.SCALAR_TYPE_DEFINITION = 'ScalarTypeDefinition';
- var OBJECT_TYPE_DEFINITION = exports.OBJECT_TYPE_DEFINITION = 'ObjectTypeDefinition';
- var FIELD_DEFINITION = exports.FIELD_DEFINITION = 'FieldDefinition';
- var INPUT_VALUE_DEFINITION = exports.INPUT_VALUE_DEFINITION = 'InputValueDefinition';
- var INTERFACE_TYPE_DEFINITION = exports.INTERFACE_TYPE_DEFINITION = 'InterfaceTypeDefinition';
- var UNION_TYPE_DEFINITION = exports.UNION_TYPE_DEFINITION = 'UnionTypeDefinition';
- var ENUM_TYPE_DEFINITION = exports.ENUM_TYPE_DEFINITION = 'EnumTypeDefinition';
- var ENUM_VALUE_DEFINITION = exports.ENUM_VALUE_DEFINITION = 'EnumValueDefinition';
- var INPUT_OBJECT_TYPE_DEFINITION = exports.INPUT_OBJECT_TYPE_DEFINITION = 'InputObjectTypeDefinition';
- // Type Extensions
- var TYPE_EXTENSION_DEFINITION = exports.TYPE_EXTENSION_DEFINITION = 'TypeExtensionDefinition';
- // Directive Definitions
- var DIRECTIVE_DEFINITION = exports.DIRECTIVE_DEFINITION = 'DirectiveDefinition';
- /***/ }),
- /* 3 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = invariant;
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function invariant(condition, message) {
- if (!condition) {
- throw new Error(message);
- }
- }
- /***/ }),
- /* 4 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.print = print;
- var _visitor = __webpack_require__(15);
- /**
- * Converts an AST into a string, using one set of reasonable
- * formatting rules.
- */
- function print(ast) {
- return (0, _visitor.visit)(ast, { leave: printDocASTReducer });
- } /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- var printDocASTReducer = {
- Name: function Name(node) {
- return node.value;
- },
- Variable: function Variable(node) {
- return '$' + node.name;
- },
- // Document
- Document: function Document(node) {
- return join(node.definitions, '\n\n') + '\n';
- },
- OperationDefinition: function OperationDefinition(node) {
- var op = node.operation;
- var name = node.name;
- var varDefs = wrap('(', join(node.variableDefinitions, ', '), ')');
- var directives = join(node.directives, ' ');
- var selectionSet = node.selectionSet;
- // Anonymous queries with no directives or variable definitions can use
- // the query short form.
- return !name && !directives && !varDefs && op === 'query' ? selectionSet : join([op, join([name, varDefs]), directives, selectionSet], ' ');
- },
- VariableDefinition: function VariableDefinition(_ref) {
- var variable = _ref.variable,
- type = _ref.type,
- defaultValue = _ref.defaultValue;
- return variable + ': ' + type + wrap(' = ', defaultValue);
- },
- SelectionSet: function SelectionSet(_ref2) {
- var selections = _ref2.selections;
- return block(selections);
- },
- Field: function Field(_ref3) {
- var alias = _ref3.alias,
- name = _ref3.name,
- args = _ref3.arguments,
- directives = _ref3.directives,
- selectionSet = _ref3.selectionSet;
- return join([wrap('', alias, ': ') + name + wrap('(', join(args, ', '), ')'), join(directives, ' '), selectionSet], ' ');
- },
- Argument: function Argument(_ref4) {
- var name = _ref4.name,
- value = _ref4.value;
- return name + ': ' + value;
- },
- // Fragments
- FragmentSpread: function FragmentSpread(_ref5) {
- var name = _ref5.name,
- directives = _ref5.directives;
- return '...' + name + wrap(' ', join(directives, ' '));
- },
- InlineFragment: function InlineFragment(_ref6) {
- var typeCondition = _ref6.typeCondition,
- directives = _ref6.directives,
- selectionSet = _ref6.selectionSet;
- return join(['...', wrap('on ', typeCondition), join(directives, ' '), selectionSet], ' ');
- },
- FragmentDefinition: function FragmentDefinition(_ref7) {
- var name = _ref7.name,
- typeCondition = _ref7.typeCondition,
- directives = _ref7.directives,
- selectionSet = _ref7.selectionSet;
- return 'fragment ' + name + ' on ' + typeCondition + ' ' + wrap('', join(directives, ' '), ' ') + selectionSet;
- },
- // Value
- IntValue: function IntValue(_ref8) {
- var value = _ref8.value;
- return value;
- },
- FloatValue: function FloatValue(_ref9) {
- var value = _ref9.value;
- return value;
- },
- StringValue: function StringValue(_ref10) {
- var value = _ref10.value;
- return JSON.stringify(value);
- },
- BooleanValue: function BooleanValue(_ref11) {
- var value = _ref11.value;
- return JSON.stringify(value);
- },
- NullValue: function NullValue() {
- return 'null';
- },
- EnumValue: function EnumValue(_ref12) {
- var value = _ref12.value;
- return value;
- },
- ListValue: function ListValue(_ref13) {
- var values = _ref13.values;
- return '[' + join(values, ', ') + ']';
- },
- ObjectValue: function ObjectValue(_ref14) {
- var fields = _ref14.fields;
- return '{' + join(fields, ', ') + '}';
- },
- ObjectField: function ObjectField(_ref15) {
- var name = _ref15.name,
- value = _ref15.value;
- return name + ': ' + value;
- },
- // Directive
- Directive: function Directive(_ref16) {
- var name = _ref16.name,
- args = _ref16.arguments;
- return '@' + name + wrap('(', join(args, ', '), ')');
- },
- // Type
- NamedType: function NamedType(_ref17) {
- var name = _ref17.name;
- return name;
- },
- ListType: function ListType(_ref18) {
- var type = _ref18.type;
- return '[' + type + ']';
- },
- NonNullType: function NonNullType(_ref19) {
- var type = _ref19.type;
- return type + '!';
- },
- // Type System Definitions
- SchemaDefinition: function SchemaDefinition(_ref20) {
- var directives = _ref20.directives,
- operationTypes = _ref20.operationTypes;
- return join(['schema', join(directives, ' '), block(operationTypes)], ' ');
- },
- OperationTypeDefinition: function OperationTypeDefinition(_ref21) {
- var operation = _ref21.operation,
- type = _ref21.type;
- return operation + ': ' + type;
- },
- ScalarTypeDefinition: function ScalarTypeDefinition(_ref22) {
- var name = _ref22.name,
- directives = _ref22.directives;
- return join(['scalar', name, join(directives, ' ')], ' ');
- },
- ObjectTypeDefinition: function ObjectTypeDefinition(_ref23) {
- var name = _ref23.name,
- interfaces = _ref23.interfaces,
- directives = _ref23.directives,
- fields = _ref23.fields;
- return join(['type', name, wrap('implements ', join(interfaces, ', ')), join(directives, ' '), block(fields)], ' ');
- },
- FieldDefinition: function FieldDefinition(_ref24) {
- var name = _ref24.name,
- args = _ref24.arguments,
- type = _ref24.type,
- directives = _ref24.directives;
- return name + wrap('(', join(args, ', '), ')') + ': ' + type + wrap(' ', join(directives, ' '));
- },
- InputValueDefinition: function InputValueDefinition(_ref25) {
- var name = _ref25.name,
- type = _ref25.type,
- defaultValue = _ref25.defaultValue,
- directives = _ref25.directives;
- return join([name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], ' ');
- },
- InterfaceTypeDefinition: function InterfaceTypeDefinition(_ref26) {
- var name = _ref26.name,
- directives = _ref26.directives,
- fields = _ref26.fields;
- return join(['interface', name, join(directives, ' '), block(fields)], ' ');
- },
- UnionTypeDefinition: function UnionTypeDefinition(_ref27) {
- var name = _ref27.name,
- directives = _ref27.directives,
- types = _ref27.types;
- return join(['union', name, join(directives, ' '), '= ' + join(types, ' | ')], ' ');
- },
- EnumTypeDefinition: function EnumTypeDefinition(_ref28) {
- var name = _ref28.name,
- directives = _ref28.directives,
- values = _ref28.values;
- return join(['enum', name, join(directives, ' '), block(values)], ' ');
- },
- EnumValueDefinition: function EnumValueDefinition(_ref29) {
- var name = _ref29.name,
- directives = _ref29.directives;
- return join([name, join(directives, ' ')], ' ');
- },
- InputObjectTypeDefinition: function InputObjectTypeDefinition(_ref30) {
- var name = _ref30.name,
- directives = _ref30.directives,
- fields = _ref30.fields;
- return join(['input', name, join(directives, ' '), block(fields)], ' ');
- },
- TypeExtensionDefinition: function TypeExtensionDefinition(_ref31) {
- var definition = _ref31.definition;
- return 'extend ' + definition;
- },
- DirectiveDefinition: function DirectiveDefinition(_ref32) {
- var name = _ref32.name,
- args = _ref32.arguments,
- locations = _ref32.locations;
- return 'directive @' + name + wrap('(', join(args, ', '), ')') + ' on ' + join(locations, ' | ');
- }
- };
- /**
- * Given maybeArray, print an empty string if it is null or empty, otherwise
- * print all items together separated by separator if provided
- */
- function join(maybeArray, separator) {
- return maybeArray ? maybeArray.filter(function (x) {
- return x;
- }).join(separator || '') : '';
- }
- /**
- * Given array, print each item on its own line, wrapped in an
- * indented "{ }" block.
- */
- function block(array) {
- return array && array.length !== 0 ? indent('{\n' + join(array, '\n')) + '\n}' : '{}';
- }
- /**
- * If maybeString is not null or empty, then wrap with start and end, otherwise
- * print an empty string.
- */
- function wrap(start, maybeString, end) {
- return maybeString ? start + maybeString + (end || '') : '';
- }
- function indent(maybeString) {
- return maybeString && maybeString.replace(/\n/g, '\n ');
- }
- /***/ }),
- /* 5 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.specifiedDirectives = exports.GraphQLDeprecatedDirective = exports.DEFAULT_DEPRECATION_REASON = exports.GraphQLSkipDirective = exports.GraphQLIncludeDirective = exports.GraphQLDirective = exports.DirectiveLocation = undefined;
- var _definition = __webpack_require__(1);
- var _scalars = __webpack_require__(7);
- var _invariant = __webpack_require__(3);
- var _invariant2 = _interopRequireDefault(_invariant);
- var _assertValidName = __webpack_require__(28);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- var DirectiveLocation = exports.DirectiveLocation = {
- // Operations
- QUERY: 'QUERY',
- MUTATION: 'MUTATION',
- SUBSCRIPTION: 'SUBSCRIPTION',
- FIELD: 'FIELD',
- FRAGMENT_DEFINITION: 'FRAGMENT_DEFINITION',
- FRAGMENT_SPREAD: 'FRAGMENT_SPREAD',
- INLINE_FRAGMENT: 'INLINE_FRAGMENT',
- // Schema Definitions
- SCHEMA: 'SCHEMA',
- SCALAR: 'SCALAR',
- OBJECT: 'OBJECT',
- FIELD_DEFINITION: 'FIELD_DEFINITION',
- ARGUMENT_DEFINITION: 'ARGUMENT_DEFINITION',
- INTERFACE: 'INTERFACE',
- UNION: 'UNION',
- ENUM: 'ENUM',
- ENUM_VALUE: 'ENUM_VALUE',
- INPUT_OBJECT: 'INPUT_OBJECT',
- INPUT_FIELD_DEFINITION: 'INPUT_FIELD_DEFINITION'
- };
- // eslint-disable-line
- /**
- * Directives are used by the GraphQL runtime as a way of modifying execution
- * behavior. Type system creators will usually not create these directly.
- */
- var GraphQLDirective = exports.GraphQLDirective = function GraphQLDirective(config) {
- _classCallCheck(this, GraphQLDirective);
- (0, _invariant2.default)(config.name, 'Directive must be named.');
- (0, _assertValidName.assertValidName)(config.name);
- (0, _invariant2.default)(Array.isArray(config.locations), 'Must provide locations for directive.');
- this.name = config.name;
- this.description = config.description;
- this.locations = config.locations;
- var args = config.args;
- if (!args) {
- this.args = [];
- } else {
- (0, _invariant2.default)(!Array.isArray(args), '@' + config.name + ' args must be an object with argument names as keys.');
- this.args = Object.keys(args).map(function (argName) {
- (0, _assertValidName.assertValidName)(argName);
- var arg = args[argName];
- (0, _invariant2.default)((0, _definition.isInputType)(arg.type), '@' + config.name + '(' + argName + ':) argument type must be ' + ('Input Type but got: ' + String(arg.type) + '.'));
- return {
- name: argName,
- description: arg.description === undefined ? null : arg.description,
- type: arg.type,
- defaultValue: arg.defaultValue
- };
- });
- }
- };
- /**
- * Used to conditionally include fields or fragments.
- */
- var GraphQLIncludeDirective = exports.GraphQLIncludeDirective = new GraphQLDirective({
- name: 'include',
- description: 'Directs the executor to include this field or fragment only when ' + 'the `if` argument is true.',
- locations: [DirectiveLocation.FIELD, DirectiveLocation.FRAGMENT_SPREAD, DirectiveLocation.INLINE_FRAGMENT],
- args: {
- 'if': {
- type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean),
- description: 'Included when true.'
- }
- }
- });
- /**
- * Used to conditionally skip (exclude) fields or fragments.
- */
- var GraphQLSkipDirective = exports.GraphQLSkipDirective = new GraphQLDirective({
- name: 'skip',
- description: 'Directs the executor to skip this field or fragment when the `if` ' + 'argument is true.',
- locations: [DirectiveLocation.FIELD, DirectiveLocation.FRAGMENT_SPREAD, DirectiveLocation.INLINE_FRAGMENT],
- args: {
- 'if': {
- type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean),
- description: 'Skipped when true.'
- }
- }
- });
- /**
- * Constant string used for default reason for a deprecation.
- */
- var DEFAULT_DEPRECATION_REASON = exports.DEFAULT_DEPRECATION_REASON = 'No longer supported';
- /**
- * Used to declare element of a GraphQL schema as deprecated.
- */
- var GraphQLDeprecatedDirective = exports.GraphQLDeprecatedDirective = new GraphQLDirective({
- name: 'deprecated',
- description: 'Marks an element of a GraphQL schema as no longer supported.',
- locations: [DirectiveLocation.FIELD_DEFINITION, DirectiveLocation.ENUM_VALUE],
- args: {
- reason: {
- type: _scalars.GraphQLString,
- 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/).',
- defaultValue: DEFAULT_DEPRECATION_REASON
- }
- }
- });
- /**
- * The full list of specified directives.
- */
- var specifiedDirectives = exports.specifiedDirectives = [GraphQLIncludeDirective, GraphQLSkipDirective, GraphQLDeprecatedDirective];
- /***/ }),
- /* 6 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = isNullish;
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- /**
- * Returns true if a value is null, undefined, or NaN.
- */
- function isNullish(value) {
- return value === null || value === undefined || value !== value;
- }
- /***/ }),
- /* 7 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.GraphQLID = exports.GraphQLBoolean = exports.GraphQLString = exports.GraphQLFloat = exports.GraphQLInt = undefined;
- var _definition = __webpack_require__(1);
- var _kinds = __webpack_require__(2);
- var Kind = _interopRequireWildcard(_kinds);
- 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; } }
- // As per the GraphQL Spec, Integers are only treated as valid when a valid
- // 32-bit signed integer, providing the broadest support across platforms.
- //
- // n.b. JavaScript's integers are safe between -(2^53 - 1) and 2^53 - 1 because
- // they are internally represented as IEEE 754 doubles.
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- var MAX_INT = 2147483647;
- var MIN_INT = -2147483648;
- function coerceInt(value) {
- if (value === '') {
- throw new TypeError('Int cannot represent non 32-bit signed integer value: (empty string)');
- }
- var num = Number(value);
- if (num === num && num <= MAX_INT && num >= MIN_INT) {
- return (num < 0 ? Math.ceil : Math.floor)(num);
- }
- throw new TypeError('Int cannot represent non 32-bit signed integer value: ' + String(value));
- }
- var GraphQLInt = exports.GraphQLInt = new _definition.GraphQLScalarType({
- name: 'Int',
- description: 'The `Int` scalar type represents non-fractional signed whole numeric ' + 'values. Int can represent values between -(2^31) and 2^31 - 1. ',
- serialize: coerceInt,
- parseValue: coerceInt,
- parseLiteral: function parseLiteral(ast) {
- if (ast.kind === Kind.INT) {
- var num = parseInt(ast.value, 10);
- if (num <= MAX_INT && num >= MIN_INT) {
- return num;
- }
- }
- return null;
- }
- });
- function coerceFloat(value) {
- if (value === '') {
- throw new TypeError('Float cannot represent non numeric value: (empty string)');
- }
- var num = Number(value);
- if (num === num) {
- return num;
- }
- throw new TypeError('Float cannot represent non numeric value: ' + String(value));
- }
- var GraphQLFloat = exports.GraphQLFloat = new _definition.GraphQLScalarType({
- name: 'Float',
- description: 'The `Float` scalar type represents signed double-precision fractional ' + 'values as specified by ' + '[IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point). ',
- serialize: coerceFloat,
- parseValue: coerceFloat,
- parseLiteral: function parseLiteral(ast) {
- return ast.kind === Kind.FLOAT || ast.kind === Kind.INT ? parseFloat(ast.value) : null;
- }
- });
- var GraphQLString = exports.GraphQLString = new _definition.GraphQLScalarType({
- name: 'String',
- 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.',
- serialize: String,
- parseValue: String,
- parseLiteral: function parseLiteral(ast) {
- return ast.kind === Kind.STRING ? ast.value : null;
- }
- });
- var GraphQLBoolean = exports.GraphQLBoolean = new _definition.GraphQLScalarType({
- name: 'Boolean',
- description: 'The `Boolean` scalar type represents `true` or `false`.',
- serialize: Boolean,
- parseValue: Boolean,
- parseLiteral: function parseLiteral(ast) {
- return ast.kind === Kind.BOOLEAN ? ast.value : null;
- }
- });
- var GraphQLID = exports.GraphQLID = new _definition.GraphQLScalarType({
- name: 'ID',
- 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.',
- serialize: String,
- parseValue: String,
- parseLiteral: function parseLiteral(ast) {
- return ast.kind === Kind.STRING || ast.kind === Kind.INT ? ast.value : null;
- }
- });
- /***/ }),
- /* 8 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.GraphQLSchema = undefined;
- var _definition = __webpack_require__(1);
- var _directives = __webpack_require__(5);
- var _introspection = __webpack_require__(11);
- var _find = __webpack_require__(10);
- var _find2 = _interopRequireDefault(_find);
- var _invariant = __webpack_require__(3);
- var _invariant2 = _interopRequireDefault(_invariant);
- var _typeComparators = __webpack_require__(19);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- /**
- * Schema Definition
- *
- * A Schema is created by supplying the root types of each type of operation,
- * query and mutation (optional). A schema definition is then supplied to the
- * validator and executor.
- *
- * Example:
- *
- * const MyAppSchema = new GraphQLSchema({
- * query: MyAppQueryRootType,
- * mutation: MyAppMutationRootType,
- * })
- *
- * Note: If an array of `directives` are provided to GraphQLSchema, that will be
- * the exact list of directives represented and allowed. If `directives` is not
- * provided then a default set of the specified directives (e.g. @include and
- * @skip) will be used. If you wish to provide *additional* directives to these
- * specified directives, you must explicitly declare them. Example:
- *
- * const MyAppSchema = new GraphQLSchema({
- * ...
- * directives: specifiedDirectives.concat([ myCustomDirective ]),
- * })
- *
- */
- var GraphQLSchema = exports.GraphQLSchema = function () {
- function GraphQLSchema(config) {
- var _this = this;
- _classCallCheck(this, GraphQLSchema);
- (0, _invariant2.default)(typeof config === 'object', 'Must provide configuration object.');
- (0, _invariant2.default)(config.query instanceof _definition.GraphQLObjectType, 'Schema query must be Object Type but got: ' + String(config.query) + '.');
- this._queryType = config.query;
- (0, _invariant2.default)(!config.mutation || config.mutation instanceof _definition.GraphQLObjectType, 'Schema mutation must be Object Type if provided but got: ' + String(config.mutation) + '.');
- this._mutationType = config.mutation;
- (0, _invariant2.default)(!config.subscription || config.subscription instanceof _definition.GraphQLObjectType, 'Schema subscription must be Object Type if provided but got: ' + String(config.subscription) + '.');
- this._subscriptionType = config.subscription;
- (0, _invariant2.default)(!config.types || Array.isArray(config.types), 'Schema types must be Array if provided but got: ' + String(config.types) + '.');
- (0, _invariant2.default)(!config.directives || Array.isArray(config.directives) && config.directives.every(function (directive) {
- return directive instanceof _directives.GraphQLDirective;
- }), 'Schema directives must be Array<GraphQLDirective> if provided but got: ' + String(config.directives) + '.');
- // Provide specified directives (e.g. @include and @skip) by default.
- this._directives = config.directives || _directives.specifiedDirectives;
- // Build type map now to detect any errors within this schema.
- var initialTypes = [this.getQueryType(), this.getMutationType(), this.getSubscriptionType(), _introspection.__Schema];
- var types = config.types;
- if (types) {
- initialTypes = initialTypes.concat(types);
- }
- this._typeMap = initialTypes.reduce(typeMapReducer, Object.create(null));
- // Keep track of all implementations by interface name.
- this._implementations = Object.create(null);
- Object.keys(this._typeMap).forEach(function (typeName) {
- var type = _this._typeMap[typeName];
- if (type instanceof _definition.GraphQLObjectType) {
- type.getInterfaces().forEach(function (iface) {
- var impls = _this._implementations[iface.name];
- if (impls) {
- impls.push(type);
- } else {
- _this._implementations[iface.name] = [type];
- }
- });
- }
- });
- // Enforce correct interface implementations.
- Object.keys(this._typeMap).forEach(function (typeName) {
- var type = _this._typeMap[typeName];
- if (type instanceof _definition.GraphQLObjectType) {
- type.getInterfaces().forEach(function (iface) {
- return assertObjectImplementsInterface(_this, type, iface);
- });
- }
- });
- }
- GraphQLSchema.prototype.getQueryType = function getQueryType() {
- return this._queryType;
- };
- GraphQLSchema.prototype.getMutationType = function getMutationType() {
- return this._mutationType;
- };
- GraphQLSchema.prototype.getSubscriptionType = function getSubscriptionType() {
- return this._subscriptionType;
- };
- GraphQLSchema.prototype.getTypeMap = function getTypeMap() {
- return this._typeMap;
- };
- GraphQLSchema.prototype.getType = function getType(name) {
- return this.getTypeMap()[name];
- };
- GraphQLSchema.prototype.getPossibleTypes = function getPossibleTypes(abstractType) {
- if (abstractType instanceof _definition.GraphQLUnionType) {
- return abstractType.getTypes();
- }
- (0, _invariant2.default)(abstractType instanceof _definition.GraphQLInterfaceType);
- return this._implementations[abstractType.name];
- };
- GraphQLSchema.prototype.isPossibleType = function isPossibleType(abstractType, possibleType) {
- var possibleTypeMap = this._possibleTypeMap;
- if (!possibleTypeMap) {
- this._possibleTypeMap = possibleTypeMap = Object.create(null);
- }
- if (!possibleTypeMap[abstractType.name]) {
- var possibleTypes = this.getPossibleTypes(abstractType);
- (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.');
- possibleTypeMap[abstractType.name] = possibleTypes.reduce(function (map, type) {
- return map[type.name] = true, map;
- }, Object.create(null));
- }
- return Boolean(possibleTypeMap[abstractType.name][possibleType.name]);
- };
- GraphQLSchema.prototype.getDirectives = function getDirectives() {
- return this._directives;
- };
- GraphQLSchema.prototype.getDirective = function getDirective(name) {
- return (0, _find2.default)(this.getDirectives(), function (directive) {
- return directive.name === name;
- });
- };
- return GraphQLSchema;
- }();
- function typeMapReducer(map, type) {
- if (!type) {
- return map;
- }
- if (type instanceof _definition.GraphQLList || type instanceof _definition.GraphQLNonNull) {
- return typeMapReducer(map, type.ofType);
- }
- if (map[type.name]) {
- (0, _invariant2.default)(map[type.name] === type, 'Schema must contain unique named types but contains multiple ' + ('types named "' + type.name + '".'));
- return map;
- }
- map[type.name] = type;
- var reducedMap = map;
- if (type instanceof _definition.GraphQLUnionType) {
- reducedMap = type.getTypes().reduce(typeMapReducer, reducedMap);
- }
- if (type instanceof _definition.GraphQLObjectType) {
- reducedMap = type.getInterfaces().reduce(typeMapReducer, reducedMap);
- }
- if (type instanceof _definition.GraphQLObjectType || type instanceof _definition.GraphQLInterfaceType) {
- (function () {
- var fieldMap = type.getFields();
- Object.keys(fieldMap).forEach(function (fieldName) {
- var field = fieldMap[fieldName];
- if (field.args) {
- var fieldArgTypes = field.args.map(function (arg) {
- return arg.type;
- });
- reducedMap = fieldArgTypes.reduce(typeMapReducer, reducedMap);
- }
- reducedMap = typeMapReducer(reducedMap, field.type);
- });
- })();
- }
- if (type instanceof _definition.GraphQLInputObjectType) {
- (function () {
- var fieldMap = type.getFields();
- Object.keys(fieldMap).forEach(function (fieldName) {
- var field = fieldMap[fieldName];
- reducedMap = typeMapReducer(reducedMap, field.type);
- });
- })();
- }
- return reducedMap;
- }
- function assertObjectImplementsInterface(schema, object, iface) {
- var objectFieldMap = object.getFields();
- var ifaceFieldMap = iface.getFields();
- // Assert each interface field is implemented.
- Object.keys(ifaceFieldMap).forEach(function (fieldName) {
- var objectField = objectFieldMap[fieldName];
- var ifaceField = ifaceFieldMap[fieldName];
- // Assert interface field exists on object.
- (0, _invariant2.default)(objectField, '"' + iface.name + '" expects field "' + fieldName + '" but "' + object.name + '" ' + 'does not provide it.');
- // Assert interface field type is satisfied by object field type, by being
- // a valid subtype. (covariant)
- (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) + '".'));
- // Assert each interface field arg is implemented.
- ifaceField.args.forEach(function (ifaceArg) {
- var argName = ifaceArg.name;
- var objectArg = (0, _find2.default)(objectField.args, function (arg) {
- return arg.name === argName;
- });
- // Assert interface field arg exists on object field.
- (0, _invariant2.default)(objectArg, iface.name + '.' + fieldName + ' expects argument "' + argName + '" but ' + (object.name + '.' + fieldName + ' does not provide it.'));
- // Assert interface field arg type matches object field arg type.
- // (invariant)
- (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) + '".'));
- });
- // Assert additional arguments must not be required.
- objectField.args.forEach(function (objectArg) {
- var argName = objectArg.name;
- var ifaceArg = (0, _find2.default)(ifaceField.args, function (arg) {
- return arg.name === argName;
- });
- if (!ifaceArg) {
- (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 + '.'));
- }
- });
- });
- }
- /***/ }),
- /* 9 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.typeFromAST = typeFromAST;
- var _invariant = __webpack_require__(3);
- var _invariant2 = _interopRequireDefault(_invariant);
- var _kinds = __webpack_require__(2);
- var _definition = __webpack_require__(1);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- function typeFromAST(schema, typeNode) {
- var innerType = void 0;
- if (typeNode.kind === _kinds.LIST_TYPE) {
- innerType = typeFromAST(schema, typeNode.type);
- return innerType && new _definition.GraphQLList(innerType);
- }
- if (typeNode.kind === _kinds.NON_NULL_TYPE) {
- innerType = typeFromAST(schema, typeNode.type);
- return innerType && new _definition.GraphQLNonNull(innerType);
- }
- (0, _invariant2.default)(typeNode.kind === _kinds.NAMED_TYPE, 'Must be a named type.');
- return schema.getType(typeNode.name.value);
- }
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- /***/ }),
- /* 10 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = find;
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function find(list, predicate) {
- for (var i = 0; i < list.length; i++) {
- if (predicate(list[i])) {
- return list[i];
- }
- }
- }
- /***/ }),
- /* 11 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- 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;
- var _isInvalid = __webpack_require__(14);
- var _isInvalid2 = _interopRequireDefault(_isInvalid);
- var _astFromValue = __webpack_require__(29);
- var _printer = __webpack_require__(4);
- var _definition = __webpack_require__(1);
- var _scalars = __webpack_require__(7);
- var _directives = __webpack_require__(5);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- var __Schema = exports.__Schema = new _definition.GraphQLObjectType({
- name: '__Schema',
- isIntrospection: true,
- 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.',
- fields: function fields() {
- return {
- types: {
- description: 'A list of all types supported by this server.',
- type: new _definition.GraphQLNonNull(new _definition.GraphQLList(new _definition.GraphQLNonNull(__Type))),
- resolve: function resolve(schema) {
- var typeMap = schema.getTypeMap();
- return Object.keys(typeMap).map(function (key) {
- return typeMap[key];
- });
- }
- },
- queryType: {
- description: 'The type that query operations will be rooted at.',
- type: new _definition.GraphQLNonNull(__Type),
- resolve: function resolve(schema) {
- return schema.getQueryType();
- }
- },
- mutationType: {
- description: 'If this server supports mutation, the type that ' + 'mutation operations will be rooted at.',
- type: __Type,
- resolve: function resolve(schema) {
- return schema.getMutationType();
- }
- },
- subscriptionType: {
- description: 'If this server support subscription, the type that ' + 'subscription operations will be rooted at.',
- type: __Type,
- resolve: function resolve(schema) {
- return schema.getSubscriptionType();
- }
- },
- directives: {
- description: 'A list of all directives supported by this server.',
- type: new _definition.GraphQLNonNull(new _definition.GraphQLList(new _definition.GraphQLNonNull(__Directive))),
- resolve: function resolve(schema) {
- return schema.getDirectives();
- }
- }
- };
- }
- });
- var __Directive = exports.__Directive = new _definition.GraphQLObjectType({
- name: '__Directive',
- isIntrospection: true,
- 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.',
- fields: function fields() {
- return {
- name: { type: new _definition.GraphQLNonNull(_scalars.GraphQLString) },
- description: { type: _scalars.GraphQLString },
- locations: {
- type: new _definition.GraphQLNonNull(new _definition.GraphQLList(new _definition.GraphQLNonNull(__DirectiveLocation)))
- },
- args: {
- type: new _definition.GraphQLNonNull(new _definition.GraphQLList(new _definition.GraphQLNonNull(__InputValue))),
- resolve: function resolve(directive) {
- return directive.args || [];
- }
- },
- // NOTE: the following three fields are deprecated and are no longer part
- // of the GraphQL specification.
- onOperation: {
- deprecationReason: 'Use `locations`.',
- type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean),
- resolve: function resolve(d) {
- return d.locations.indexOf(_directives.DirectiveLocation.QUERY) !== -1 || d.locations.indexOf(_directives.DirectiveLocation.MUTATION) !== -1 || d.locations.indexOf(_directives.DirectiveLocation.SUBSCRIPTION) !== -1;
- }
- },
- onFragment: {
- deprecationReason: 'Use `locations`.',
- type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean),
- resolve: function resolve(d) {
- 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;
- }
- },
- onField: {
- deprecationReason: 'Use `locations`.',
- type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean),
- resolve: function resolve(d) {
- return d.locations.indexOf(_directives.DirectiveLocation.FIELD) !== -1;
- }
- }
- };
- }
- });
- var __DirectiveLocation = exports.__DirectiveLocation = new _definition.GraphQLEnumType({
- name: '__DirectiveLocation',
- isIntrospection: true,
- description: 'A Directive can be adjacent to many parts of the GraphQL language, a ' + '__DirectiveLocation describes one such possible adjacencies.',
- values: {
- QUERY: {
- value: _directives.DirectiveLocation.QUERY,
- description: 'Location adjacent to a query operation.'
- },
- MUTATION: {
- value: _directives.DirectiveLocation.MUTATION,
- description: 'Location adjacent to a mutation operation.'
- },
- SUBSCRIPTION: {
- value: _directives.DirectiveLocation.SUBSCRIPTION,
- description: 'Location adjacent to a subscription operation.'
- },
- FIELD: {
- value: _directives.DirectiveLocation.FIELD,
- description: 'Location adjacent to a field.'
- },
- FRAGMENT_DEFINITION: {
- value: _directives.DirectiveLocation.FRAGMENT_DEFINITION,
- description: 'Location adjacent to a fragment definition.'
- },
- FRAGMENT_SPREAD: {
- value: _directives.DirectiveLocation.FRAGMENT_SPREAD,
- description: 'Location adjacent to a fragment spread.'
- },
- INLINE_FRAGMENT: {
- value: _directives.DirectiveLocation.INLINE_FRAGMENT,
- description: 'Location adjacent to an inline fragment.'
- },
- SCHEMA: {
- value: _directives.DirectiveLocation.SCHEMA,
- description: 'Location adjacent to a schema definition.'
- },
- SCALAR: {
- value: _directives.DirectiveLocation.SCALAR,
- description: 'Location adjacent to a scalar definition.'
- },
- OBJECT: {
- value: _directives.DirectiveLocation.OBJECT,
- description: 'Location adjacent to an object type definition.'
- },
- FIELD_DEFINITION: {
- value: _directives.DirectiveLocation.FIELD_DEFINITION,
- description: 'Location adjacent to a field definition.'
- },
- ARGUMENT_DEFINITION: {
- value: _directives.DirectiveLocation.ARGUMENT_DEFINITION,
- description: 'Location adjacent to an argument definition.'
- },
- INTERFACE: {
- value: _directives.DirectiveLocation.INTERFACE,
- description: 'Location adjacent to an interface definition.'
- },
- UNION: {
- value: _directives.DirectiveLocation.UNION,
- description: 'Location adjacent to a union definition.'
- },
- ENUM: {
- value: _directives.DirectiveLocation.ENUM,
- description: 'Location adjacent to an enum definition.'
- },
- ENUM_VALUE: {
- value: _directives.DirectiveLocation.ENUM_VALUE,
- description: 'Location adjacent to an enum value definition.'
- },
- INPUT_OBJECT: {
- value: _directives.DirectiveLocation.INPUT_OBJECT,
- description: 'Location adjacent to an input object type definition.'
- },
- INPUT_FIELD_DEFINITION: {
- value: _directives.DirectiveLocation.INPUT_FIELD_DEFINITION,
- description: 'Location adjacent to an input object field definition.'
- }
- }
- });
- var __Type = exports.__Type = new _definition.GraphQLObjectType({
- name: '__Type',
- isIntrospection: true,
- 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.',
- fields: function fields() {
- return {
- kind: {
- type: new _definition.GraphQLNonNull(__TypeKind),
- resolve: function resolve(type) {
- if (type instanceof _definition.GraphQLScalarType) {
- return TypeKind.SCALAR;
- } else if (type instanceof _definition.GraphQLObjectType) {
- return TypeKind.OBJECT;
- } else if (type instanceof _definition.GraphQLInterfaceType) {
- return TypeKind.INTERFACE;
- } else if (type instanceof _definition.GraphQLUnionType) {
- return TypeKind.UNION;
- } else if (type instanceof _definition.GraphQLEnumType) {
- return TypeKind.ENUM;
- } else if (type instanceof _definition.GraphQLInputObjectType) {
- return TypeKind.INPUT_OBJECT;
- } else if (type instanceof _definition.GraphQLList) {
- return TypeKind.LIST;
- } else if (type instanceof _definition.GraphQLNonNull) {
- return TypeKind.NON_NULL;
- }
- throw new Error('Unknown kind of type: ' + type);
- }
- },
- name: { type: _scalars.GraphQLString },
- description: { type: _scalars.GraphQLString },
- fields: {
- type: new _definition.GraphQLList(new _definition.GraphQLNonNull(__Field)),
- args: {
- includeDeprecated: { type: _scalars.GraphQLBoolean, defaultValue: false }
- },
- resolve: function resolve(type, _ref) {
- var includeDeprecated = _ref.includeDeprecated;
- if (type instanceof _definition.GraphQLObjectType || type instanceof _definition.GraphQLInterfaceType) {
- var _ret = function () {
- var fieldMap = type.getFields();
- var fields = Object.keys(fieldMap).map(function (fieldName) {
- return fieldMap[fieldName];
- });
- if (!includeDeprecated) {
- fields = fields.filter(function (field) {
- return !field.deprecationReason;
- });
- }
- return {
- v: fields
- };
- }();
- if (typeof _ret === "object") return _ret.v;
- }
- return null;
- }
- },
- interfaces: {
- type: new _definition.GraphQLList(new _definition.GraphQLNonNull(__Type)),
- resolve: function resolve(type) {
- if (type instanceof _definition.GraphQLObjectType) {
- return type.getInterfaces();
- }
- }
- },
- possibleTypes: {
- type: new _definition.GraphQLList(new _definition.GraphQLNonNull(__Type)),
- resolve: function resolve(type, args, context, _ref2) {
- var schema = _ref2.schema;
- if (type instanceof _definition.GraphQLInterfaceType || type instanceof _definition.GraphQLUnionType) {
- return schema.getPossibleTypes(type);
- }
- }
- },
- enumValues: {
- type: new _definition.GraphQLList(new _definition.GraphQLNonNull(__EnumValue)),
- args: {
- includeDeprecated: { type: _scalars.GraphQLBoolean, defaultValue: false }
- },
- resolve: function resolve(type, _ref3) {
- var includeDeprecated = _ref3.includeDeprecated;
- if (type instanceof _definition.GraphQLEnumType) {
- var values = type.getValues();
- if (!includeDeprecated) {
- values = values.filter(function (value) {
- return !value.deprecationReason;
- });
- }
- return values;
- }
- }
- },
- inputFields: {
- type: new _definition.GraphQLList(new _definition.GraphQLNonNull(__InputValue)),
- resolve: function resolve(type) {
- if (type instanceof _definition.GraphQLInputObjectType) {
- var _ret2 = function () {
- var fieldMap = type.getFields();
- return {
- v: Object.keys(fieldMap).map(function (fieldName) {
- return fieldMap[fieldName];
- })
- };
- }();
- if (typeof _ret2 === "object") return _ret2.v;
- }
- }
- },
- ofType: { type: __Type }
- };
- }
- });
- var __Field = exports.__Field = new _definition.GraphQLObjectType({
- name: '__Field',
- isIntrospection: true,
- 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.',
- fields: function fields() {
- return {
- name: { type: new _definition.GraphQLNonNull(_scalars.GraphQLString) },
- description: { type: _scalars.GraphQLString },
- args: {
- type: new _definition.GraphQLNonNull(new _definition.GraphQLList(new _definition.GraphQLNonNull(__InputValue))),
- resolve: function resolve(field) {
- return field.args || [];
- }
- },
- type: { type: new _definition.GraphQLNonNull(__Type) },
- isDeprecated: { type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean) },
- deprecationReason: {
- type: _scalars.GraphQLString
- }
- };
- }
- });
- var __InputValue = exports.__InputValue = new _definition.GraphQLObjectType({
- name: '__InputValue',
- isIntrospection: true,
- 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.',
- fields: function fields() {
- return {
- name: { type: new _definition.GraphQLNonNull(_scalars.GraphQLString) },
- description: { type: _scalars.GraphQLString },
- type: { type: new _definition.GraphQLNonNull(__Type) },
- defaultValue: {
- type: _scalars.GraphQLString,
- description: 'A GraphQL-formatted string representing the default value for this ' + 'input value.',
- resolve: function resolve(inputVal) {
- return (0, _isInvalid2.default)(inputVal.defaultValue) ? null : (0, _printer.print)((0, _astFromValue.astFromValue)(inputVal.defaultValue, inputVal.type));
- }
- }
- };
- }
- });
- var __EnumValue = exports.__EnumValue = new _definition.GraphQLObjectType({
- name: '__EnumValue',
- isIntrospection: true,
- 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.',
- fields: function fields() {
- return {
- name: { type: new _definition.GraphQLNonNull(_scalars.GraphQLString) },
- description: { type: _scalars.GraphQLString },
- isDeprecated: { type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean) },
- deprecationReason: {
- type: _scalars.GraphQLString
- }
- };
- }
- });
- var TypeKind = exports.TypeKind = {
- SCALAR: 'SCALAR',
- OBJECT: 'OBJECT',
- INTERFACE: 'INTERFACE',
- UNION: 'UNION',
- ENUM: 'ENUM',
- INPUT_OBJECT: 'INPUT_OBJECT',
- LIST: 'LIST',
- NON_NULL: 'NON_NULL'
- };
- var __TypeKind = exports.__TypeKind = new _definition.GraphQLEnumType({
- name: '__TypeKind',
- isIntrospection: true,
- description: 'An enum describing what kind of type a given `__Type` is.',
- values: {
- SCALAR: {
- value: TypeKind.SCALAR,
- description: 'Indicates this type is a scalar.'
- },
- OBJECT: {
- value: TypeKind.OBJECT,
- description: 'Indicates this type is an object. ' + '`fields` and `interfaces` are valid fields.'
- },
- INTERFACE: {
- value: TypeKind.INTERFACE,
- description: 'Indicates this type is an interface. ' + '`fields` and `possibleTypes` are valid fields.'
- },
- UNION: {
- value: TypeKind.UNION,
- description: 'Indicates this type is a union. ' + '`possibleTypes` is a valid field.'
- },
- ENUM: {
- value: TypeKind.ENUM,
- description: 'Indicates this type is an enum. ' + '`enumValues` is a valid field.'
- },
- INPUT_OBJECT: {
- value: TypeKind.INPUT_OBJECT,
- description: 'Indicates this type is an input object. ' + '`inputFields` is a valid field.'
- },
- LIST: {
- value: TypeKind.LIST,
- description: 'Indicates this type is a list. ' + '`ofType` is a valid field.'
- },
- NON_NULL: {
- value: TypeKind.NON_NULL,
- description: 'Indicates this type is a non-null. ' + '`ofType` is a valid field.'
- }
- }
- });
- /**
- * Note that these are GraphQLField and not GraphQLFieldConfig,
- * so the format for args is different.
- */
- var SchemaMetaFieldDef = exports.SchemaMetaFieldDef = {
- name: '__schema',
- type: new _definition.GraphQLNonNull(__Schema),
- description: 'Access the current type schema of this server.',
- args: [],
- resolve: function resolve(source, args, context, _ref4) {
- var schema = _ref4.schema;
- return schema;
- }
- };
- var TypeMetaFieldDef = exports.TypeMetaFieldDef = {
- name: '__type',
- type: __Type,
- description: 'Request the type information of a single type.',
- args: [{ name: 'name', type: new _definition.GraphQLNonNull(_scalars.GraphQLString) }],
- resolve: function resolve(source, _ref5, context, _ref6) {
- var name = _ref5.name;
- var schema = _ref6.schema;
- return schema.getType(name);
- }
- };
- var TypeNameMetaFieldDef = exports.TypeNameMetaFieldDef = {
- name: '__typename',
- type: new _definition.GraphQLNonNull(_scalars.GraphQLString),
- description: 'The name of the current Object type at runtime.',
- args: [],
- resolve: function resolve(source, args, context, _ref7) {
- var parentType = _ref7.parentType;
- return parentType.name;
- }
- };
- /***/ }),
- /* 12 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = keyMap;
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- /**
- * Creates a keyed JS object from an array, given a function to produce the keys
- * for each value in the array.
- *
- * This provides a convenient lookup for the array items if the key function
- * produces unique results.
- *
- * const phoneBook = [
- * { name: 'Jon', num: '555-1234' },
- * { name: 'Jenny', num: '867-5309' }
- * ]
- *
- * // { Jon: { name: 'Jon', num: '555-1234' },
- * // Jenny: { name: 'Jenny', num: '867-5309' } }
- * const entriesByName = keyMap(
- * phoneBook,
- * entry => entry.name
- * )
- *
- * // { name: 'Jenny', num: '857-6309' }
- * const jennyEntry = entriesByName['Jenny']
- *
- */
- function keyMap(list, keyFn) {
- return list.reduce(function (map, item) {
- return map[keyFn(item)] = item, map;
- }, {});
- }
- /***/ }),
- /* 13 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.GraphQLError = GraphQLError;
- var _location = __webpack_require__(25);
- /**
- * A GraphQLError describes an Error found during the parse, validate, or
- * execute phases of performing a GraphQL operation. In addition to a message
- * and stack trace, it also includes information about the locations in a
- * GraphQL document and/or execution result that correspond to the Error.
- */
- function GraphQLError( // eslint-disable-line no-redeclare
- message, nodes, source, positions, path, originalError) {
- // Include (non-enumerable) stack trace.
- if (originalError && originalError.stack) {
- Object.defineProperty(this, 'stack', {
- value: originalError.stack,
- writable: true,
- configurable: true
- });
- } else if (Error.captureStackTrace) {
- Error.captureStackTrace(this, GraphQLError);
- } else {
- Object.defineProperty(this, 'stack', {
- value: Error().stack,
- writable: true,
- configurable: true
- });
- }
- // Compute locations in the source for the given nodes/positions.
- var _source = source;
- if (!_source && nodes && nodes.length > 0) {
- var node = nodes[0];
- _source = node && node.loc && node.loc.source;
- }
- var _positions = positions;
- if (!_positions && nodes) {
- _positions = nodes.filter(function (node) {
- return Boolean(node.loc);
- }).map(function (node) {
- return node.loc.start;
- });
- }
- if (_positions && _positions.length === 0) {
- _positions = undefined;
- }
- var _locations = void 0;
- var _source2 = _source; // seems here Flow need a const to resolve type.
- if (_source2 && _positions) {
- _locations = _positions.map(function (pos) {
- return (0, _location.getLocation)(_source2, pos);
- });
- }
- Object.defineProperties(this, {
- message: {
- value: message,
- // By being enumerable, JSON.stringify will include `message` in the
- // resulting output. This ensures that the simplist possible GraphQL
- // service adheres to the spec.
- enumerable: true,
- writable: true
- },
- locations: {
- // Coercing falsey values to undefined ensures they will not be included
- // in JSON.stringify() when not provided.
- value: _locations || undefined,
- // By being enumerable, JSON.stringify will include `locations` in the
- // resulting output. This ensures that the simplist possible GraphQL
- // service adheres to the spec.
- enumerable: true
- },
- path: {
- // Coercing falsey values to undefined ensures they will not be included
- // in JSON.stringify() when not provided.
- value: path || undefined,
- // By being enumerable, JSON.stringify will include `path` in the
- // resulting output. This ensures that the simplist possible GraphQL
- // service adheres to the spec.
- enumerable: true
- },
- nodes: {
- value: nodes || undefined
- },
- source: {
- value: _source || undefined
- },
- positions: {
- value: _positions || undefined
- },
- originalError: {
- value: originalError
- }
- });
- }
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- GraphQLError.prototype = Object.create(Error.prototype, {
- constructor: { value: GraphQLError },
- name: { value: 'GraphQLError' }
- });
- /***/ }),
- /* 14 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = isInvalid;
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- /**
- * Returns true if a value is undefined, or NaN.
- */
- function isInvalid(value) {
- return value === undefined || value !== value;
- }
- /***/ }),
- /* 15 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.visit = visit;
- exports.visitInParallel = visitInParallel;
- exports.visitWithTypeInfo = visitWithTypeInfo;
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- var QueryDocumentKeys = exports.QueryDocumentKeys = {
- Name: [],
- Document: ['definitions'],
- OperationDefinition: ['name', 'variableDefinitions', 'directives', 'selectionSet'],
- VariableDefinition: ['variable', 'type', 'defaultValue'],
- Variable: ['name'],
- SelectionSet: ['selections'],
- Field: ['alias', 'name', 'arguments', 'directives', 'selectionSet'],
- Argument: ['name', 'value'],
- FragmentSpread: ['name', 'directives'],
- InlineFragment: ['typeCondition', 'directives', 'selectionSet'],
- FragmentDefinition: ['name', 'typeCondition', 'directives', 'selectionSet'],
- IntValue: [],
- FloatValue: [],
- StringValue: [],
- BooleanValue: [],
- NullValue: [],
- EnumValue: [],
- ListValue: ['values'],
- ObjectValue: ['fields'],
- ObjectField: ['name', 'value'],
- Directive: ['name', 'arguments'],
- NamedType: ['name'],
- ListType: ['type'],
- NonNullType: ['type'],
- SchemaDefinition: ['directives', 'operationTypes'],
- OperationTypeDefinition: ['type'],
- ScalarTypeDefinition: ['name', 'directives'],
- ObjectTypeDefinition: ['name', 'interfaces', 'directives', 'fields'],
- FieldDefinition: ['name', 'arguments', 'type', 'directives'],
- InputValueDefinition: ['name', 'type', 'defaultValue', 'directives'],
- InterfaceTypeDefinition: ['name', 'directives', 'fields'],
- UnionTypeDefinition: ['name', 'directives', 'types'],
- EnumTypeDefinition: ['name', 'directives', 'values'],
- EnumValueDefinition: ['name', 'directives'],
- InputObjectTypeDefinition: ['name', 'directives', 'fields'],
- TypeExtensionDefinition: ['definition'],
- DirectiveDefinition: ['name', 'arguments', 'locations']
- };
- var BREAK = exports.BREAK = {};
- /**
- * visit() will walk through an AST using a depth first traversal, calling
- * the visitor's enter function at each node in the traversal, and calling the
- * leave function after visiting that node and all of its child nodes.
- *
- * By returning different values from the enter and leave functions, the
- * behavior of the visitor can be altered, including skipping over a sub-tree of
- * the AST (by returning false), editing the AST by returning a value or null
- * to remove the value, or to stop the whole traversal by returning BREAK.
- *
- * When using visit() to edit an AST, the original AST will not be modified, and
- * a new version of the AST with the changes applied will be returned from the
- * visit function.
- *
- * const editedAST = visit(ast, {
- * enter(node, key, parent, path, ancestors) {
- * // @return
- * // undefined: no action
- * // false: skip visiting this node
- * // visitor.BREAK: stop visiting altogether
- * // null: delete this node
- * // any value: replace this node with the returned value
- * },
- * leave(node, key, parent, path, ancestors) {
- * // @return
- * // undefined: no action
- * // false: no action
- * // visitor.BREAK: stop visiting altogether
- * // null: delete this node
- * // any value: replace this node with the returned value
- * }
- * });
- *
- * Alternatively to providing enter() and leave() functions, a visitor can
- * instead provide functions named the same as the kinds of AST nodes, or
- * enter/leave visitors at a named key, leading to four permutations of
- * visitor API:
- *
- * 1) Named visitors triggered when entering a node a specific kind.
- *
- * visit(ast, {
- * Kind(node) {
- * // enter the "Kind" node
- * }
- * })
- *
- * 2) Named visitors that trigger upon entering and leaving a node of
- * a specific kind.
- *
- * visit(ast, {
- * Kind: {
- * enter(node) {
- * // enter the "Kind" node
- * }
- * leave(node) {
- * // leave the "Kind" node
- * }
- * }
- * })
- *
- * 3) Generic visitors that trigger upon entering and leaving any node.
- *
- * visit(ast, {
- * enter(node) {
- * // enter any node
- * },
- * leave(node) {
- * // leave any node
- * }
- * })
- *
- * 4) Parallel visitors for entering and leaving nodes of a specific kind.
- *
- * visit(ast, {
- * enter: {
- * Kind(node) {
- * // enter the "Kind" node
- * }
- * },
- * leave: {
- * Kind(node) {
- * // leave the "Kind" node
- * }
- * }
- * })
- */
- function visit(root, visitor, keyMap) {
- var visitorKeys = keyMap || QueryDocumentKeys;
- var stack = void 0;
- var inArray = Array.isArray(root);
- var keys = [root];
- var index = -1;
- var edits = [];
- var parent = void 0;
- var path = [];
- var ancestors = [];
- var newRoot = root;
- do {
- index++;
- var isLeaving = index === keys.length;
- var key = void 0;
- var node = void 0;
- var isEdited = isLeaving && edits.length !== 0;
- if (isLeaving) {
- key = ancestors.length === 0 ? undefined : path.pop();
- node = parent;
- parent = ancestors.pop();
- if (isEdited) {
- if (inArray) {
- node = node.slice();
- } else {
- var clone = {};
- for (var k in node) {
- if (node.hasOwnProperty(k)) {
- clone[k] = node[k];
- }
- }
- node = clone;
- }
- var editOffset = 0;
- for (var ii = 0; ii < edits.length; ii++) {
- var editKey = edits[ii][0];
- var editValue = edits[ii][1];
- if (inArray) {
- editKey -= editOffset;
- }
- if (inArray && editValue === null) {
- node.splice(editKey, 1);
- editOffset++;
- } else {
- node[editKey] = editValue;
- }
- }
- }
- index = stack.index;
- keys = stack.keys;
- edits = stack.edits;
- inArray = stack.inArray;
- stack = stack.prev;
- } else {
- key = parent ? inArray ? index : keys[index] : undefined;
- node = parent ? parent[key] : newRoot;
- if (node === null || node === undefined) {
- continue;
- }
- if (parent) {
- path.push(key);
- }
- }
- var result = void 0;
- if (!Array.isArray(node)) {
- if (!isNode(node)) {
- throw new Error('Invalid AST Node: ' + JSON.stringify(node));
- }
- var visitFn = getVisitFn(visitor, node.kind, isLeaving);
- if (visitFn) {
- result = visitFn.call(visitor, node, key, parent, path, ancestors);
- if (result === BREAK) {
- break;
- }
- if (result === false) {
- if (!isLeaving) {
- path.pop();
- continue;
- }
- } else if (result !== undefined) {
- edits.push([key, result]);
- if (!isLeaving) {
- if (isNode(result)) {
- node = result;
- } else {
- path.pop();
- continue;
- }
- }
- }
- }
- }
- if (result === undefined && isEdited) {
- edits.push([key, node]);
- }
- if (!isLeaving) {
- stack = { inArray: inArray, index: index, keys: keys, edits: edits, prev: stack };
- inArray = Array.isArray(node);
- keys = inArray ? node : visitorKeys[node.kind] || [];
- index = -1;
- edits = [];
- if (parent) {
- ancestors.push(parent);
- }
- parent = node;
- }
- } while (stack !== undefined);
- if (edits.length !== 0) {
- newRoot = edits[edits.length - 1][1];
- }
- return newRoot;
- }
- function isNode(maybeNode) {
- return maybeNode && typeof maybeNode.kind === 'string';
- }
- /**
- * Creates a new visitor instance which delegates to many visitors to run in
- * parallel. Each visitor will be visited for each node before moving on.
- *
- * If a prior visitor edits a node, no following visitors will see that node.
- */
- function visitInParallel(visitors) {
- var skipping = new Array(visitors.length);
- return {
- enter: function enter(node) {
- for (var i = 0; i < visitors.length; i++) {
- if (!skipping[i]) {
- var fn = getVisitFn(visitors[i], node.kind, /* isLeaving */false);
- if (fn) {
- var result = fn.apply(visitors[i], arguments);
- if (result === false) {
- skipping[i] = node;
- } else if (result === BREAK) {
- skipping[i] = BREAK;
- } else if (result !== undefined) {
- return result;
- }
- }
- }
- }
- },
- leave: function leave(node) {
- for (var i = 0; i < visitors.length; i++) {
- if (!skipping[i]) {
- var fn = getVisitFn(visitors[i], node.kind, /* isLeaving */true);
- if (fn) {
- var result = fn.apply(visitors[i], arguments);
- if (result === BREAK) {
- skipping[i] = BREAK;
- } else if (result !== undefined && result !== false) {
- return result;
- }
- }
- } else if (skipping[i] === node) {
- skipping[i] = null;
- }
- }
- }
- };
- }
- /**
- * Creates a new visitor instance which maintains a provided TypeInfo instance
- * along with visiting visitor.
- */
- function visitWithTypeInfo(typeInfo, visitor) {
- return {
- enter: function enter(node) {
- typeInfo.enter(node);
- var fn = getVisitFn(visitor, node.kind, /* isLeaving */false);
- if (fn) {
- var result = fn.apply(visitor, arguments);
- if (result !== undefined) {
- typeInfo.leave(node);
- if (isNode(result)) {
- typeInfo.enter(result);
- }
- }
- return result;
- }
- },
- leave: function leave(node) {
- var fn = getVisitFn(visitor, node.kind, /* isLeaving */true);
- var result = void 0;
- if (fn) {
- result = fn.apply(visitor, arguments);
- }
- typeInfo.leave(node);
- return result;
- }
- };
- }
- /**
- * Given a visitor instance, if it is leaving or not, and a node kind, return
- * the function the visitor runtime should call.
- */
- function getVisitFn(visitor, kind, isLeaving) {
- var kindVisitor = visitor[kind];
- if (kindVisitor) {
- if (!isLeaving && typeof kindVisitor === 'function') {
- // { Kind() {} }
- return kindVisitor;
- }
- var kindSpecificVisitor = isLeaving ? kindVisitor.leave : kindVisitor.enter;
- if (typeof kindSpecificVisitor === 'function') {
- // { Kind: { enter() {}, leave() {} } }
- return kindSpecificVisitor;
- }
- } else {
- var specificVisitor = isLeaving ? visitor.leave : visitor.enter;
- if (specificVisitor) {
- if (typeof specificVisitor === 'function') {
- // { enter() {}, leave() {} }
- return specificVisitor;
- }
- var specificKindVisitor = specificVisitor[kind];
- if (typeof specificKindVisitor === 'function') {
- // { enter: { Kind() {} }, leave: { Kind() {} } }
- return specificKindVisitor;
- }
- }
- }
- }
- /***/ }),
- /* 16 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.valueFromAST = valueFromAST;
- var _keyMap = __webpack_require__(12);
- var _keyMap2 = _interopRequireDefault(_keyMap);
- var _invariant = __webpack_require__(3);
- var _invariant2 = _interopRequireDefault(_invariant);
- var _isNullish = __webpack_require__(6);
- var _isNullish2 = _interopRequireDefault(_isNullish);
- var _isInvalid = __webpack_require__(14);
- var _isInvalid2 = _interopRequireDefault(_isInvalid);
- var _kinds = __webpack_require__(2);
- var Kind = _interopRequireWildcard(_kinds);
- var _definition = __webpack_require__(1);
- 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; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- /**
- * Produces a JavaScript value given a GraphQL Value AST.
- *
- * A GraphQL type must be provided, which will be used to interpret different
- * GraphQL Value literals.
- *
- * Returns `undefined` when the value could not be validly coerced according to
- * the provided type.
- *
- * | GraphQL Value | JSON Value |
- * | -------------------- | ------------- |
- * | Input Object | Object |
- * | List | Array |
- * | Boolean | Boolean |
- * | String | String |
- * | Int / Float | Number |
- * | Enum Value | Mixed |
- * | NullValue | null |
- *
- */
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function valueFromAST(valueNode, type, variables) {
- if (!valueNode) {
- // When there is no node, then there is also no value.
- // Importantly, this is different from returning the value null.
- return;
- }
- if (type instanceof _definition.GraphQLNonNull) {
- if (valueNode.kind === Kind.NULL) {
- return; // Invalid: intentionally return no value.
- }
- return valueFromAST(valueNode, type.ofType, variables);
- }
- if (valueNode.kind === Kind.NULL) {
- // This is explicitly returning the value null.
- return null;
- }
- if (valueNode.kind === Kind.VARIABLE) {
- var variableName = valueNode.name.value;
- if (!variables || (0, _isInvalid2.default)(variables[variableName])) {
- // No valid return value.
- return;
- }
- // Note: we're not doing any checking that this variable is correct. We're
- // assuming that this query has been validated and the variable usage here
- // is of the correct type.
- return variables[variableName];
- }
- if (type instanceof _definition.GraphQLList) {
- var itemType = type.ofType;
- if (valueNode.kind === Kind.LIST) {
- var coercedValues = [];
- var itemNodes = valueNode.values;
- for (var i = 0; i < itemNodes.length; i++) {
- if (isMissingVariable(itemNodes[i], variables)) {
- // If an array contains a missing variable, it is either coerced to
- // null or if the item type is non-null, it considered invalid.
- if (itemType instanceof _definition.GraphQLNonNull) {
- return; // Invalid: intentionally return no value.
- }
- coercedValues.push(null);
- } else {
- var itemValue = valueFromAST(itemNodes[i], itemType, variables);
- if ((0, _isInvalid2.default)(itemValue)) {
- return; // Invalid: intentionally return no value.
- }
- coercedValues.push(itemValue);
- }
- }
- return coercedValues;
- }
- var coercedValue = valueFromAST(valueNode, itemType, variables);
- if ((0, _isInvalid2.default)(coercedValue)) {
- return; // Invalid: intentionally return no value.
- }
- return [coercedValue];
- }
- if (type instanceof _definition.GraphQLInputObjectType) {
- if (valueNode.kind !== Kind.OBJECT) {
- return; // Invalid: intentionally return no value.
- }
- var coercedObj = Object.create(null);
- var fields = type.getFields();
- var fieldNodes = (0, _keyMap2.default)(valueNode.fields, function (field) {
- return field.name.value;
- });
- var fieldNames = Object.keys(fields);
- for (var _i = 0; _i < fieldNames.length; _i++) {
- var fieldName = fieldNames[_i];
- var field = fields[fieldName];
- var fieldNode = fieldNodes[fieldName];
- if (!fieldNode || isMissingVariable(fieldNode.value, variables)) {
- if (!(0, _isInvalid2.default)(field.defaultValue)) {
- coercedObj[fieldName] = field.defaultValue;
- } else if (field.type instanceof _definition.GraphQLNonNull) {
- return; // Invalid: intentionally return no value.
- }
- continue;
- }
- var fieldValue = valueFromAST(fieldNode.value, field.type, variables);
- if ((0, _isInvalid2.default)(fieldValue)) {
- return; // Invalid: intentionally return no value.
- }
- coercedObj[fieldName] = fieldValue;
- }
- return coercedObj;
- }
- (0, _invariant2.default)(type instanceof _definition.GraphQLScalarType || type instanceof _definition.GraphQLEnumType, 'Must be input type');
- var parsed = type.parseLiteral(valueNode);
- if ((0, _isNullish2.default)(parsed)) {
- // null or invalid values represent a failure to parse correctly,
- // in which case no value is returned.
- return;
- }
- return parsed;
- }
- // Returns true if the provided valueNode is a variable which is not defined
- // in the set of variables.
- function isMissingVariable(valueNode, variables) {
- return valueNode.kind === Kind.VARIABLE && (!variables || (0, _isInvalid2.default)(variables[valueNode.name.value]));
- }
- /***/ }),
- /* 17 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.parse = parse;
- exports.parseValue = parseValue;
- exports.parseType = parseType;
- exports.parseConstValue = parseConstValue;
- exports.parseTypeReference = parseTypeReference;
- exports.parseNamedType = parseNamedType;
- var _source = __webpack_require__(26);
- var _error = __webpack_require__(0);
- var _lexer = __webpack_require__(24);
- var _kinds = __webpack_require__(2);
- /**
- * Given a GraphQL source, parses it into a Document.
- * Throws GraphQLError if a syntax error is encountered.
- */
- /**
- * Configuration options to control parser behavior
- */
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function parse(source, options) {
- var sourceObj = typeof source === 'string' ? new _source.Source(source) : source;
- var lexer = (0, _lexer.createLexer)(sourceObj, options || {});
- return parseDocument(lexer);
- }
- /**
- * Given a string containing a GraphQL value (ex. `[42]`), parse the AST for
- * that value.
- * Throws GraphQLError if a syntax error is encountered.
- *
- * This is useful within tools that operate upon GraphQL Values directly and
- * in isolation of complete GraphQL documents.
- *
- * Consider providing the results to the utility function: valueFromAST().
- */
- function parseValue(source, options) {
- var sourceObj = typeof source === 'string' ? new _source.Source(source) : source;
- var lexer = (0, _lexer.createLexer)(sourceObj, options || {});
- expect(lexer, _lexer.TokenKind.SOF);
- var value = parseValueLiteral(lexer, false);
- expect(lexer, _lexer.TokenKind.EOF);
- return value;
- }
- /**
- * Given a string containing a GraphQL Type (ex. `[Int!]`), parse the AST for
- * that type.
- * Throws GraphQLError if a syntax error is encountered.
- *
- * This is useful within tools that operate upon GraphQL Types directly and
- * in isolation of complete GraphQL documents.
- *
- * Consider providing the results to the utility function: typeFromAST().
- */
- function parseType(source, options) {
- var sourceObj = typeof source === 'string' ? new _source.Source(source) : source;
- var lexer = (0, _lexer.createLexer)(sourceObj, options || {});
- expect(lexer, _lexer.TokenKind.SOF);
- var type = parseTypeReference(lexer);
- expect(lexer, _lexer.TokenKind.EOF);
- return type;
- }
- /**
- * Converts a name lex token into a name parse node.
- */
- function parseName(lexer) {
- var token = expect(lexer, _lexer.TokenKind.NAME);
- return {
- kind: _kinds.NAME,
- value: token.value,
- loc: loc(lexer, token)
- };
- }
- // Implements the parsing rules in the Document section.
- /**
- * Document : Definition+
- */
- function parseDocument(lexer) {
- var start = lexer.token;
- expect(lexer, _lexer.TokenKind.SOF);
- var definitions = [];
- do {
- definitions.push(parseDefinition(lexer));
- } while (!skip(lexer, _lexer.TokenKind.EOF));
- return {
- kind: _kinds.DOCUMENT,
- definitions: definitions,
- loc: loc(lexer, start)
- };
- }
- /**
- * Definition :
- * - OperationDefinition
- * - FragmentDefinition
- * - TypeSystemDefinition
- */
- function parseDefinition(lexer) {
- if (peek(lexer, _lexer.TokenKind.BRACE_L)) {
- return parseOperationDefinition(lexer);
- }
- if (peek(lexer, _lexer.TokenKind.NAME)) {
- switch (lexer.token.value) {
- // Note: subscription is an experimental non-spec addition.
- case 'query':
- case 'mutation':
- case 'subscription':
- return parseOperationDefinition(lexer);
- case 'fragment':
- return parseFragmentDefinition(lexer);
- // Note: the Type System IDL is an experimental non-spec addition.
- case 'schema':
- case 'scalar':
- case 'type':
- case 'interface':
- case 'union':
- case 'enum':
- case 'input':
- case 'extend':
- case 'directive':
- return parseTypeSystemDefinition(lexer);
- }
- }
- throw unexpected(lexer);
- }
- // Implements the parsing rules in the Operations section.
- /**
- * OperationDefinition :
- * - SelectionSet
- * - OperationType Name? VariableDefinitions? Directives? SelectionSet
- */
- function parseOperationDefinition(lexer) {
- var start = lexer.token;
- if (peek(lexer, _lexer.TokenKind.BRACE_L)) {
- return {
- kind: _kinds.OPERATION_DEFINITION,
- operation: 'query',
- name: null,
- variableDefinitions: null,
- directives: [],
- selectionSet: parseSelectionSet(lexer),
- loc: loc(lexer, start)
- };
- }
- var operation = parseOperationType(lexer);
- var name = void 0;
- if (peek(lexer, _lexer.TokenKind.NAME)) {
- name = parseName(lexer);
- }
- return {
- kind: _kinds.OPERATION_DEFINITION,
- operation: operation,
- name: name,
- variableDefinitions: parseVariableDefinitions(lexer),
- directives: parseDirectives(lexer),
- selectionSet: parseSelectionSet(lexer),
- loc: loc(lexer, start)
- };
- }
- /**
- * OperationType : one of query mutation subscription
- */
- function parseOperationType(lexer) {
- var operationToken = expect(lexer, _lexer.TokenKind.NAME);
- switch (operationToken.value) {
- case 'query':
- return 'query';
- case 'mutation':
- return 'mutation';
- // Note: subscription is an experimental non-spec addition.
- case 'subscription':
- return 'subscription';
- }
- throw unexpected(lexer, operationToken);
- }
- /**
- * VariableDefinitions : ( VariableDefinition+ )
- */
- function parseVariableDefinitions(lexer) {
- return peek(lexer, _lexer.TokenKind.PAREN_L) ? many(lexer, _lexer.TokenKind.PAREN_L, parseVariableDefinition, _lexer.TokenKind.PAREN_R) : [];
- }
- /**
- * VariableDefinition : Variable : Type DefaultValue?
- */
- function parseVariableDefinition(lexer) {
- var start = lexer.token;
- return {
- kind: _kinds.VARIABLE_DEFINITION,
- variable: parseVariable(lexer),
- type: (expect(lexer, _lexer.TokenKind.COLON), parseTypeReference(lexer)),
- defaultValue: skip(lexer, _lexer.TokenKind.EQUALS) ? parseValueLiteral(lexer, true) : null,
- loc: loc(lexer, start)
- };
- }
- /**
- * Variable : $ Name
- */
- function parseVariable(lexer) {
- var start = lexer.token;
- expect(lexer, _lexer.TokenKind.DOLLAR);
- return {
- kind: _kinds.VARIABLE,
- name: parseName(lexer),
- loc: loc(lexer, start)
- };
- }
- /**
- * SelectionSet : { Selection+ }
- */
- function parseSelectionSet(lexer) {
- var start = lexer.token;
- return {
- kind: _kinds.SELECTION_SET,
- selections: many(lexer, _lexer.TokenKind.BRACE_L, parseSelection, _lexer.TokenKind.BRACE_R),
- loc: loc(lexer, start)
- };
- }
- /**
- * Selection :
- * - Field
- * - FragmentSpread
- * - InlineFragment
- */
- function parseSelection(lexer) {
- return peek(lexer, _lexer.TokenKind.SPREAD) ? parseFragment(lexer) : parseField(lexer);
- }
- /**
- * Field : Alias? Name Arguments? Directives? SelectionSet?
- *
- * Alias : Name :
- */
- function parseField(lexer) {
- var start = lexer.token;
- var nameOrAlias = parseName(lexer);
- var alias = void 0;
- var name = void 0;
- if (skip(lexer, _lexer.TokenKind.COLON)) {
- alias = nameOrAlias;
- name = parseName(lexer);
- } else {
- alias = null;
- name = nameOrAlias;
- }
- return {
- kind: _kinds.FIELD,
- alias: alias,
- name: name,
- arguments: parseArguments(lexer),
- directives: parseDirectives(lexer),
- selectionSet: peek(lexer, _lexer.TokenKind.BRACE_L) ? parseSelectionSet(lexer) : null,
- loc: loc(lexer, start)
- };
- }
- /**
- * Arguments : ( Argument+ )
- */
- function parseArguments(lexer) {
- return peek(lexer, _lexer.TokenKind.PAREN_L) ? many(lexer, _lexer.TokenKind.PAREN_L, parseArgument, _lexer.TokenKind.PAREN_R) : [];
- }
- /**
- * Argument : Name : Value
- */
- function parseArgument(lexer) {
- var start = lexer.token;
- return {
- kind: _kinds.ARGUMENT,
- name: parseName(lexer),
- value: (expect(lexer, _lexer.TokenKind.COLON), parseValueLiteral(lexer, false)),
- loc: loc(lexer, start)
- };
- }
- // Implements the parsing rules in the Fragments section.
- /**
- * Corresponds to both FragmentSpread and InlineFragment in the spec.
- *
- * FragmentSpread : ... FragmentName Directives?
- *
- * InlineFragment : ... TypeCondition? Directives? SelectionSet
- */
- function parseFragment(lexer) {
- var start = lexer.token;
- expect(lexer, _lexer.TokenKind.SPREAD);
- if (peek(lexer, _lexer.TokenKind.NAME) && lexer.token.value !== 'on') {
- return {
- kind: _kinds.FRAGMENT_SPREAD,
- name: parseFragmentName(lexer),
- directives: parseDirectives(lexer),
- loc: loc(lexer, start)
- };
- }
- var typeCondition = null;
- if (lexer.token.value === 'on') {
- lexer.advance();
- typeCondition = parseNamedType(lexer);
- }
- return {
- kind: _kinds.INLINE_FRAGMENT,
- typeCondition: typeCondition,
- directives: parseDirectives(lexer),
- selectionSet: parseSelectionSet(lexer),
- loc: loc(lexer, start)
- };
- }
- /**
- * FragmentDefinition :
- * - fragment FragmentName on TypeCondition Directives? SelectionSet
- *
- * TypeCondition : NamedType
- */
- function parseFragmentDefinition(lexer) {
- var start = lexer.token;
- expectKeyword(lexer, 'fragment');
- return {
- kind: _kinds.FRAGMENT_DEFINITION,
- name: parseFragmentName(lexer),
- typeCondition: (expectKeyword(lexer, 'on'), parseNamedType(lexer)),
- directives: parseDirectives(lexer),
- selectionSet: parseSelectionSet(lexer),
- loc: loc(lexer, start)
- };
- }
- /**
- * FragmentName : Name but not `on`
- */
- function parseFragmentName(lexer) {
- if (lexer.token.value === 'on') {
- throw unexpected(lexer);
- }
- return parseName(lexer);
- }
- // Implements the parsing rules in the Values section.
- /**
- * Value[Const] :
- * - [~Const] Variable
- * - IntValue
- * - FloatValue
- * - StringValue
- * - BooleanValue
- * - NullValue
- * - EnumValue
- * - ListValue[?Const]
- * - ObjectValue[?Const]
- *
- * BooleanValue : one of `true` `false`
- *
- * NullValue : `null`
- *
- * EnumValue : Name but not `true`, `false` or `null`
- */
- function parseValueLiteral(lexer, isConst) {
- var token = lexer.token;
- switch (token.kind) {
- case _lexer.TokenKind.BRACKET_L:
- return parseList(lexer, isConst);
- case _lexer.TokenKind.BRACE_L:
- return parseObject(lexer, isConst);
- case _lexer.TokenKind.INT:
- lexer.advance();
- return {
- kind: _kinds.INT,
- value: token.value,
- loc: loc(lexer, token)
- };
- case _lexer.TokenKind.FLOAT:
- lexer.advance();
- return {
- kind: _kinds.FLOAT,
- value: token.value,
- loc: loc(lexer, token)
- };
- case _lexer.TokenKind.STRING:
- lexer.advance();
- return {
- kind: _kinds.STRING,
- value: token.value,
- loc: loc(lexer, token)
- };
- case _lexer.TokenKind.NAME:
- if (token.value === 'true' || token.value === 'false') {
- lexer.advance();
- return {
- kind: _kinds.BOOLEAN,
- value: token.value === 'true',
- loc: loc(lexer, token)
- };
- } else if (token.value === 'null') {
- lexer.advance();
- return {
- kind: _kinds.NULL,
- loc: loc(lexer, token)
- };
- }
- lexer.advance();
- return {
- kind: _kinds.ENUM,
- value: token.value,
- loc: loc(lexer, token)
- };
- case _lexer.TokenKind.DOLLAR:
- if (!isConst) {
- return parseVariable(lexer);
- }
- break;
- }
- throw unexpected(lexer);
- }
- function parseConstValue(lexer) {
- return parseValueLiteral(lexer, true);
- }
- function parseValueValue(lexer) {
- return parseValueLiteral(lexer, false);
- }
- /**
- * ListValue[Const] :
- * - [ ]
- * - [ Value[?Const]+ ]
- */
- function parseList(lexer, isConst) {
- var start = lexer.token;
- var item = isConst ? parseConstValue : parseValueValue;
- return {
- kind: _kinds.LIST,
- values: any(lexer, _lexer.TokenKind.BRACKET_L, item, _lexer.TokenKind.BRACKET_R),
- loc: loc(lexer, start)
- };
- }
- /**
- * ObjectValue[Const] :
- * - { }
- * - { ObjectField[?Const]+ }
- */
- function parseObject(lexer, isConst) {
- var start = lexer.token;
- expect(lexer, _lexer.TokenKind.BRACE_L);
- var fields = [];
- while (!skip(lexer, _lexer.TokenKind.BRACE_R)) {
- fields.push(parseObjectField(lexer, isConst));
- }
- return {
- kind: _kinds.OBJECT,
- fields: fields,
- loc: loc(lexer, start)
- };
- }
- /**
- * ObjectField[Const] : Name : Value[?Const]
- */
- function parseObjectField(lexer, isConst) {
- var start = lexer.token;
- return {
- kind: _kinds.OBJECT_FIELD,
- name: parseName(lexer),
- value: (expect(lexer, _lexer.TokenKind.COLON), parseValueLiteral(lexer, isConst)),
- loc: loc(lexer, start)
- };
- }
- // Implements the parsing rules in the Directives section.
- /**
- * Directives : Directive+
- */
- function parseDirectives(lexer) {
- var directives = [];
- while (peek(lexer, _lexer.TokenKind.AT)) {
- directives.push(parseDirective(lexer));
- }
- return directives;
- }
- /**
- * Directive : @ Name Arguments?
- */
- function parseDirective(lexer) {
- var start = lexer.token;
- expect(lexer, _lexer.TokenKind.AT);
- return {
- kind: _kinds.DIRECTIVE,
- name: parseName(lexer),
- arguments: parseArguments(lexer),
- loc: loc(lexer, start)
- };
- }
- // Implements the parsing rules in the Types section.
- /**
- * Type :
- * - NamedType
- * - ListType
- * - NonNullType
- */
- function parseTypeReference(lexer) {
- var start = lexer.token;
- var type = void 0;
- if (skip(lexer, _lexer.TokenKind.BRACKET_L)) {
- type = parseTypeReference(lexer);
- expect(lexer, _lexer.TokenKind.BRACKET_R);
- type = {
- kind: _kinds.LIST_TYPE,
- type: type,
- loc: loc(lexer, start)
- };
- } else {
- type = parseNamedType(lexer);
- }
- if (skip(lexer, _lexer.TokenKind.BANG)) {
- return {
- kind: _kinds.NON_NULL_TYPE,
- type: type,
- loc: loc(lexer, start)
- };
- }
- return type;
- }
- /**
- * NamedType : Name
- */
- function parseNamedType(lexer) {
- var start = lexer.token;
- return {
- kind: _kinds.NAMED_TYPE,
- name: parseName(lexer),
- loc: loc(lexer, start)
- };
- }
- // Implements the parsing rules in the Type Definition section.
- /**
- * TypeSystemDefinition :
- * - SchemaDefinition
- * - TypeDefinition
- * - TypeExtensionDefinition
- * - DirectiveDefinition
- *
- * TypeDefinition :
- * - ScalarTypeDefinition
- * - ObjectTypeDefinition
- * - InterfaceTypeDefinition
- * - UnionTypeDefinition
- * - EnumTypeDefinition
- * - InputObjectTypeDefinition
- */
- function parseTypeSystemDefinition(lexer) {
- if (peek(lexer, _lexer.TokenKind.NAME)) {
- switch (lexer.token.value) {
- case 'schema':
- return parseSchemaDefinition(lexer);
- case 'scalar':
- return parseScalarTypeDefinition(lexer);
- case 'type':
- return parseObjectTypeDefinition(lexer);
- case 'interface':
- return parseInterfaceTypeDefinition(lexer);
- case 'union':
- return parseUnionTypeDefinition(lexer);
- case 'enum':
- return parseEnumTypeDefinition(lexer);
- case 'input':
- return parseInputObjectTypeDefinition(lexer);
- case 'extend':
- return parseTypeExtensionDefinition(lexer);
- case 'directive':
- return parseDirectiveDefinition(lexer);
- }
- }
- throw unexpected(lexer);
- }
- /**
- * SchemaDefinition : schema Directives? { OperationTypeDefinition+ }
- *
- * OperationTypeDefinition : OperationType : NamedType
- */
- function parseSchemaDefinition(lexer) {
- var start = lexer.token;
- expectKeyword(lexer, 'schema');
- var directives = parseDirectives(lexer);
- var operationTypes = many(lexer, _lexer.TokenKind.BRACE_L, parseOperationTypeDefinition, _lexer.TokenKind.BRACE_R);
- return {
- kind: _kinds.SCHEMA_DEFINITION,
- directives: directives,
- operationTypes: operationTypes,
- loc: loc(lexer, start)
- };
- }
- function parseOperationTypeDefinition(lexer) {
- var start = lexer.token;
- var operation = parseOperationType(lexer);
- expect(lexer, _lexer.TokenKind.COLON);
- var type = parseNamedType(lexer);
- return {
- kind: _kinds.OPERATION_TYPE_DEFINITION,
- operation: operation,
- type: type,
- loc: loc(lexer, start)
- };
- }
- /**
- * ScalarTypeDefinition : scalar Name Directives?
- */
- function parseScalarTypeDefinition(lexer) {
- var start = lexer.token;
- expectKeyword(lexer, 'scalar');
- var name = parseName(lexer);
- var directives = parseDirectives(lexer);
- return {
- kind: _kinds.SCALAR_TYPE_DEFINITION,
- name: name,
- directives: directives,
- loc: loc(lexer, start)
- };
- }
- /**
- * ObjectTypeDefinition :
- * - type Name ImplementsInterfaces? Directives? { FieldDefinition+ }
- */
- function parseObjectTypeDefinition(lexer) {
- var start = lexer.token;
- expectKeyword(lexer, 'type');
- var name = parseName(lexer);
- var interfaces = parseImplementsInterfaces(lexer);
- var directives = parseDirectives(lexer);
- var fields = any(lexer, _lexer.TokenKind.BRACE_L, parseFieldDefinition, _lexer.TokenKind.BRACE_R);
- return {
- kind: _kinds.OBJECT_TYPE_DEFINITION,
- name: name,
- interfaces: interfaces,
- directives: directives,
- fields: fields,
- loc: loc(lexer, start)
- };
- }
- /**
- * ImplementsInterfaces : implements NamedType+
- */
- function parseImplementsInterfaces(lexer) {
- var types = [];
- if (lexer.token.value === 'implements') {
- lexer.advance();
- do {
- types.push(parseNamedType(lexer));
- } while (peek(lexer, _lexer.TokenKind.NAME));
- }
- return types;
- }
- /**
- * FieldDefinition : Name ArgumentsDefinition? : Type Directives?
- */
- function parseFieldDefinition(lexer) {
- var start = lexer.token;
- var name = parseName(lexer);
- var args = parseArgumentDefs(lexer);
- expect(lexer, _lexer.TokenKind.COLON);
- var type = parseTypeReference(lexer);
- var directives = parseDirectives(lexer);
- return {
- kind: _kinds.FIELD_DEFINITION,
- name: name,
- arguments: args,
- type: type,
- directives: directives,
- loc: loc(lexer, start)
- };
- }
- /**
- * ArgumentsDefinition : ( InputValueDefinition+ )
- */
- function parseArgumentDefs(lexer) {
- if (!peek(lexer, _lexer.TokenKind.PAREN_L)) {
- return [];
- }
- return many(lexer, _lexer.TokenKind.PAREN_L, parseInputValueDef, _lexer.TokenKind.PAREN_R);
- }
- /**
- * InputValueDefinition : Name : Type DefaultValue? Directives?
- */
- function parseInputValueDef(lexer) {
- var start = lexer.token;
- var name = parseName(lexer);
- expect(lexer, _lexer.TokenKind.COLON);
- var type = parseTypeReference(lexer);
- var defaultValue = null;
- if (skip(lexer, _lexer.TokenKind.EQUALS)) {
- defaultValue = parseConstValue(lexer);
- }
- var directives = parseDirectives(lexer);
- return {
- kind: _kinds.INPUT_VALUE_DEFINITION,
- name: name,
- type: type,
- defaultValue: defaultValue,
- directives: directives,
- loc: loc(lexer, start)
- };
- }
- /**
- * InterfaceTypeDefinition : interface Name Directives? { FieldDefinition+ }
- */
- function parseInterfaceTypeDefinition(lexer) {
- var start = lexer.token;
- expectKeyword(lexer, 'interface');
- var name = parseName(lexer);
- var directives = parseDirectives(lexer);
- var fields = any(lexer, _lexer.TokenKind.BRACE_L, parseFieldDefinition, _lexer.TokenKind.BRACE_R);
- return {
- kind: _kinds.INTERFACE_TYPE_DEFINITION,
- name: name,
- directives: directives,
- fields: fields,
- loc: loc(lexer, start)
- };
- }
- /**
- * UnionTypeDefinition : union Name Directives? = UnionMembers
- */
- function parseUnionTypeDefinition(lexer) {
- var start = lexer.token;
- expectKeyword(lexer, 'union');
- var name = parseName(lexer);
- var directives = parseDirectives(lexer);
- expect(lexer, _lexer.TokenKind.EQUALS);
- var types = parseUnionMembers(lexer);
- return {
- kind: _kinds.UNION_TYPE_DEFINITION,
- name: name,
- directives: directives,
- types: types,
- loc: loc(lexer, start)
- };
- }
- /**
- * UnionMembers :
- * - NamedType
- * - UnionMembers | NamedType
- */
- function parseUnionMembers(lexer) {
- var members = [];
- do {
- members.push(parseNamedType(lexer));
- } while (skip(lexer, _lexer.TokenKind.PIPE));
- return members;
- }
- /**
- * EnumTypeDefinition : enum Name Directives? { EnumValueDefinition+ }
- */
- function parseEnumTypeDefinition(lexer) {
- var start = lexer.token;
- expectKeyword(lexer, 'enum');
- var name = parseName(lexer);
- var directives = parseDirectives(lexer);
- var values = many(lexer, _lexer.TokenKind.BRACE_L, parseEnumValueDefinition, _lexer.TokenKind.BRACE_R);
- return {
- kind: _kinds.ENUM_TYPE_DEFINITION,
- name: name,
- directives: directives,
- values: values,
- loc: loc(lexer, start)
- };
- }
- /**
- * EnumValueDefinition : EnumValue Directives?
- *
- * EnumValue : Name
- */
- function parseEnumValueDefinition(lexer) {
- var start = lexer.token;
- var name = parseName(lexer);
- var directives = parseDirectives(lexer);
- return {
- kind: _kinds.ENUM_VALUE_DEFINITION,
- name: name,
- directives: directives,
- loc: loc(lexer, start)
- };
- }
- /**
- * InputObjectTypeDefinition : input Name Directives? { InputValueDefinition+ }
- */
- function parseInputObjectTypeDefinition(lexer) {
- var start = lexer.token;
- expectKeyword(lexer, 'input');
- var name = parseName(lexer);
- var directives = parseDirectives(lexer);
- var fields = any(lexer, _lexer.TokenKind.BRACE_L, parseInputValueDef, _lexer.TokenKind.BRACE_R);
- return {
- kind: _kinds.INPUT_OBJECT_TYPE_DEFINITION,
- name: name,
- directives: directives,
- fields: fields,
- loc: loc(lexer, start)
- };
- }
- /**
- * TypeExtensionDefinition : extend ObjectTypeDefinition
- */
- function parseTypeExtensionDefinition(lexer) {
- var start = lexer.token;
- expectKeyword(lexer, 'extend');
- var definition = parseObjectTypeDefinition(lexer);
- return {
- kind: _kinds.TYPE_EXTENSION_DEFINITION,
- definition: definition,
- loc: loc(lexer, start)
- };
- }
- /**
- * DirectiveDefinition :
- * - directive @ Name ArgumentsDefinition? on DirectiveLocations
- */
- function parseDirectiveDefinition(lexer) {
- var start = lexer.token;
- expectKeyword(lexer, 'directive');
- expect(lexer, _lexer.TokenKind.AT);
- var name = parseName(lexer);
- var args = parseArgumentDefs(lexer);
- expectKeyword(lexer, 'on');
- var locations = parseDirectiveLocations(lexer);
- return {
- kind: _kinds.DIRECTIVE_DEFINITION,
- name: name,
- arguments: args,
- locations: locations,
- loc: loc(lexer, start)
- };
- }
- /**
- * DirectiveLocations :
- * - Name
- * - DirectiveLocations | Name
- */
- function parseDirectiveLocations(lexer) {
- var locations = [];
- do {
- locations.push(parseName(lexer));
- } while (skip(lexer, _lexer.TokenKind.PIPE));
- return locations;
- }
- // Core parsing utility functions
- /**
- * Returns a location object, used to identify the place in
- * the source that created a given parsed object.
- */
- function loc(lexer, startToken) {
- if (!lexer.options.noLocation) {
- return new Loc(startToken, lexer.lastToken, lexer.source);
- }
- }
- function Loc(startToken, endToken, source) {
- this.start = startToken.start;
- this.end = endToken.end;
- this.startToken = startToken;
- this.endToken = endToken;
- this.source = source;
- }
- // Print a simplified form when appearing in JSON/util.inspect.
- Loc.prototype.toJSON = Loc.prototype.inspect = function toJSON() {
- return { start: this.start, end: this.end };
- };
- /**
- * Determines if the next token is of a given kind
- */
- function peek(lexer, kind) {
- return lexer.token.kind === kind;
- }
- /**
- * If the next token is of the given kind, return true after advancing
- * the lexer. Otherwise, do not change the parser state and return false.
- */
- function skip(lexer, kind) {
- var match = lexer.token.kind === kind;
- if (match) {
- lexer.advance();
- }
- return match;
- }
- /**
- * If the next token is of the given kind, return that token after advancing
- * the lexer. Otherwise, do not change the parser state and throw an error.
- */
- function expect(lexer, kind) {
- var token = lexer.token;
- if (token.kind === kind) {
- lexer.advance();
- return token;
- }
- throw (0, _error.syntaxError)(lexer.source, token.start, 'Expected ' + kind + ', found ' + (0, _lexer.getTokenDesc)(token));
- }
- /**
- * If the next token is a keyword with the given value, return that token after
- * advancing the lexer. Otherwise, do not change the parser state and return
- * false.
- */
- function expectKeyword(lexer, value) {
- var token = lexer.token;
- if (token.kind === _lexer.TokenKind.NAME && token.value === value) {
- lexer.advance();
- return token;
- }
- throw (0, _error.syntaxError)(lexer.source, token.start, 'Expected "' + value + '", found ' + (0, _lexer.getTokenDesc)(token));
- }
- /**
- * Helper function for creating an error when an unexpected lexed token
- * is encountered.
- */
- function unexpected(lexer, atToken) {
- var token = atToken || lexer.token;
- return (0, _error.syntaxError)(lexer.source, token.start, 'Unexpected ' + (0, _lexer.getTokenDesc)(token));
- }
- /**
- * Returns a possibly empty list of parse nodes, determined by
- * the parseFn. This list begins with a lex token of openKind
- * and ends with a lex token of closeKind. Advances the parser
- * to the next lex token after the closing token.
- */
- function any(lexer, openKind, parseFn, closeKind) {
- expect(lexer, openKind);
- var nodes = [];
- while (!skip(lexer, closeKind)) {
- nodes.push(parseFn(lexer));
- }
- return nodes;
- }
- /**
- * Returns a non-empty list of parse nodes, determined by
- * the parseFn. This list begins with a lex token of openKind
- * and ends with a lex token of closeKind. Advances the parser
- * to the next lex token after the closing token.
- */
- function many(lexer, openKind, parseFn, closeKind) {
- expect(lexer, openKind);
- var nodes = [parseFn(lexer)];
- while (!skip(lexer, closeKind)) {
- nodes.push(parseFn(lexer));
- }
- return nodes;
- }
- /***/ }),
- /* 18 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.isValidLiteralValue = isValidLiteralValue;
- var _printer = __webpack_require__(4);
- var _kinds = __webpack_require__(2);
- var _definition = __webpack_require__(1);
- var _invariant = __webpack_require__(3);
- var _invariant2 = _interopRequireDefault(_invariant);
- var _keyMap = __webpack_require__(12);
- var _keyMap2 = _interopRequireDefault(_keyMap);
- var _isNullish = __webpack_require__(6);
- var _isNullish2 = _interopRequireDefault(_isNullish);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- /**
- * Utility for validators which determines if a value literal node is valid
- * given an input type.
- *
- * Note that this only validates literal values, variables are assumed to
- * provide values of the correct type.
- */
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function isValidLiteralValue(type, valueNode) {
- // A value must be provided if the type is non-null.
- if (type instanceof _definition.GraphQLNonNull) {
- if (!valueNode || valueNode.kind === _kinds.NULL) {
- return ['Expected "' + String(type) + '", found null.'];
- }
- return isValidLiteralValue(type.ofType, valueNode);
- }
- if (!valueNode || valueNode.kind === _kinds.NULL) {
- return [];
- }
- // This function only tests literals, and assumes variables will provide
- // values of the correct type.
- if (valueNode.kind === _kinds.VARIABLE) {
- return [];
- }
- // Lists accept a non-list value as a list of one.
- if (type instanceof _definition.GraphQLList) {
- var _ret = function () {
- var itemType = type.ofType;
- if (valueNode.kind === _kinds.LIST) {
- return {
- v: valueNode.values.reduce(function (acc, item, index) {
- var errors = isValidLiteralValue(itemType, item);
- return acc.concat(errors.map(function (error) {
- return 'In element #' + index + ': ' + error;
- }));
- }, [])
- };
- }
- return {
- v: isValidLiteralValue(itemType, valueNode)
- };
- }();
- if (typeof _ret === "object") return _ret.v;
- }
- // Input objects check each defined field and look for undefined fields.
- if (type instanceof _definition.GraphQLInputObjectType) {
- var _ret2 = function () {
- if (valueNode.kind !== _kinds.OBJECT) {
- return {
- v: ['Expected "' + type.name + '", found not an object.']
- };
- }
- var fields = type.getFields();
- var errors = [];
- // Ensure every provided field is defined.
- var fieldNodes = valueNode.fields;
- fieldNodes.forEach(function (providedFieldNode) {
- if (!fields[providedFieldNode.name.value]) {
- errors.push('In field "' + providedFieldNode.name.value + '": Unknown field.');
- }
- });
- // Ensure every defined field is valid.
- var fieldNodeMap = (0, _keyMap2.default)(fieldNodes, function (fieldNode) {
- return fieldNode.name.value;
- });
- Object.keys(fields).forEach(function (fieldName) {
- var result = isValidLiteralValue(fields[fieldName].type, fieldNodeMap[fieldName] && fieldNodeMap[fieldName].value);
- errors.push.apply(errors, result.map(function (error) {
- return 'In field "' + fieldName + '": ' + error;
- }));
- });
- return {
- v: errors
- };
- }();
- if (typeof _ret2 === "object") return _ret2.v;
- }
- (0, _invariant2.default)(type instanceof _definition.GraphQLScalarType || type instanceof _definition.GraphQLEnumType, 'Must be input type');
- // Scalar/Enum input checks to ensure the type can parse the value to
- // a non-null value.
- var parseResult = type.parseLiteral(valueNode);
- if ((0, _isNullish2.default)(parseResult)) {
- return ['Expected type "' + type.name + '", found ' + (0, _printer.print)(valueNode) + '.'];
- }
- return [];
- }
- /***/ }),
- /* 19 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.isEqualType = isEqualType;
- exports.isTypeSubTypeOf = isTypeSubTypeOf;
- exports.doTypesOverlap = doTypesOverlap;
- var _definition = __webpack_require__(1);
- /**
- * Provided two types, return true if the types are equal (invariant).
- */
- function isEqualType(typeA, typeB) {
- // Equivalent types are equal.
- if (typeA === typeB) {
- return true;
- }
- // If either type is non-null, the other must also be non-null.
- if (typeA instanceof _definition.GraphQLNonNull && typeB instanceof _definition.GraphQLNonNull) {
- return isEqualType(typeA.ofType, typeB.ofType);
- }
- // If either type is a list, the other must also be a list.
- if (typeA instanceof _definition.GraphQLList && typeB instanceof _definition.GraphQLList) {
- return isEqualType(typeA.ofType, typeB.ofType);
- }
- // Otherwise the types are not equal.
- return false;
- }
- /**
- * Provided a type and a super type, return true if the first type is either
- * equal or a subset of the second super type (covariant).
- */
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function isTypeSubTypeOf(schema, maybeSubType, superType) {
- // Equivalent type is a valid subtype
- if (maybeSubType === superType) {
- return true;
- }
- // If superType is non-null, maybeSubType must also be non-null.
- if (superType instanceof _definition.GraphQLNonNull) {
- if (maybeSubType instanceof _definition.GraphQLNonNull) {
- return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType);
- }
- return false;
- } else if (maybeSubType instanceof _definition.GraphQLNonNull) {
- // If superType is nullable, maybeSubType may be non-null or nullable.
- return isTypeSubTypeOf(schema, maybeSubType.ofType, superType);
- }
- // If superType type is a list, maybeSubType type must also be a list.
- if (superType instanceof _definition.GraphQLList) {
- if (maybeSubType instanceof _definition.GraphQLList) {
- return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType);
- }
- return false;
- } else if (maybeSubType instanceof _definition.GraphQLList) {
- // If superType is not a list, maybeSubType must also be not a list.
- return false;
- }
- // If superType type is an abstract type, maybeSubType type may be a currently
- // possible object type.
- if ((0, _definition.isAbstractType)(superType) && maybeSubType instanceof _definition.GraphQLObjectType && schema.isPossibleType(superType, maybeSubType)) {
- return true;
- }
- // Otherwise, the child type is not a valid subtype of the parent type.
- return false;
- }
- /**
- * Provided two composite types, determine if they "overlap". Two composite
- * types overlap when the Sets of possible concrete types for each intersect.
- *
- * This is often used to determine if a fragment of a given type could possibly
- * be visited in a context of another type.
- *
- * This function is commutative.
- */
- function doTypesOverlap(schema, typeA, typeB) {
- // So flow is aware this is constant
- var _typeB = typeB;
- // Equivalent types overlap
- if (typeA === _typeB) {
- return true;
- }
- if (typeA instanceof _definition.GraphQLInterfaceType || typeA instanceof _definition.GraphQLUnionType) {
- if (_typeB instanceof _definition.GraphQLInterfaceType || _typeB instanceof _definition.GraphQLUnionType) {
- // If both types are abstract, then determine if there is any intersection
- // between possible concrete types of each.
- return schema.getPossibleTypes(typeA).some(function (type) {
- return schema.isPossibleType(_typeB, type);
- });
- }
- // Determine if the latter type is a possible concrete type of the former.
- return schema.isPossibleType(typeA, _typeB);
- }
- if (_typeB instanceof _definition.GraphQLInterfaceType || _typeB instanceof _definition.GraphQLUnionType) {
- // Determine if the former type is a possible concrete type of the latter.
- return schema.isPossibleType(_typeB, typeA);
- }
- // Otherwise the types do not overlap.
- return false;
- }
- /***/ }),
- /* 20 */
- /***/ (function(module, exports) {
- /**
- * Copyright (c) 2016, Lee Byron
- * All rights reserved.
- *
- * This source code is licensed under the MIT license found in the
- * LICENSE file in the root directory of this source tree.
- *
- * @ignore
- */
- /**
- * [Iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#iterator)
- * is a *protocol* which describes a standard way to produce a sequence of
- * values, typically the values of the Iterable represented by this Iterator.
- *
- * While described by the [ES2015 version of JavaScript](http://www.ecma-international.org/ecma-262/6.0/#sec-iterator-interface)
- * it can be utilized by any version of JavaScript.
- *
- * @typedef {Object} Iterator
- * @template T The type of each iterated value
- * @property {function (): { value: T, done: boolean }} next
- * A method which produces either the next value in a sequence or a result
- * where the `done` property is `true` indicating the end of the Iterator.
- */
- /**
- * [Iterable](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#iterable)
- * is a *protocol* which when implemented allows a JavaScript object to define
- * their iteration behavior, such as what values are looped over in a `for..of`
- * loop or `iterall`'s `forEach` function. Many [built-in types](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#Builtin_iterables)
- * implement the Iterable protocol, including `Array` and `Map`.
- *
- * While described by the [ES2015 version of JavaScript](http://www.ecma-international.org/ecma-262/6.0/#sec-iterable-interface)
- * it can be utilized by any version of JavaScript.
- *
- * @typedef {Object} Iterable
- * @template T The type of each iterated value
- * @property {function (): Iterator<T>} Symbol.iterator
- * A method which produces an Iterator for this Iterable.
- */
- // In ES2015 (or a polyfilled) environment, this will be Symbol.iterator
- var SYMBOL_ITERATOR = typeof Symbol === 'function' && Symbol.iterator
- /**
- * A property name to be used as the name of an Iterable's method responsible
- * for producing an Iterator, referred to as `@@iterator`. Typically represents
- * the value `Symbol.iterator` but falls back to the string `"@@iterator"` when
- * `Symbol.iterator` is not defined.
- *
- * Use `$$iterator` for defining new Iterables instead of `Symbol.iterator`,
- * but do not use it for accessing existing Iterables, instead use
- * `getIterator()` or `isIterable()`.
- *
- * @example
- *
- * var $$iterator = require('iterall').$$iterator
- *
- * function Counter (to) {
- * this.to = to
- * }
- *
- * Counter.prototype[$$iterator] = function () {
- * return {
- * to: this.to,
- * num: 0,
- * next () {
- * if (this.num >= this.to) {
- * return { value: undefined, done: true }
- * }
- * return { value: this.num++, done: false }
- * }
- * }
- * }
- *
- * var counter = new Counter(3)
- * for (var number of counter) {
- * console.log(number) // 0 ... 1 ... 2
- * }
- *
- * @type {Symbol|string}
- */
- var $$iterator = SYMBOL_ITERATOR || '@@iterator'
- exports.$$iterator = $$iterator
- /**
- * Returns true if the provided object implements the Iterator protocol via
- * either implementing a `Symbol.iterator` or `"@@iterator"` method.
- *
- * @example
- *
- * var isIterable = require('iterall').isIterable
- * isIterable([ 1, 2, 3 ]) // true
- * isIterable('ABC') // true
- * isIterable({ length: 1, 0: 'Alpha' }) // false
- * isIterable({ key: 'value' }) // false
- * isIterable(new Map()) // true
- *
- * @param obj
- * A value which might implement the Iterable protocol.
- * @return {boolean} true if Iterable.
- */
- function isIterable (obj) {
- return !!getIteratorMethod(obj)
- }
- exports.isIterable = isIterable
- /**
- * Returns true if the provided object implements the Array-like protocol via
- * defining a positive-integer `length` property.
- *
- * @example
- *
- * var isArrayLike = require('iterall').isArrayLike
- * isArrayLike([ 1, 2, 3 ]) // true
- * isArrayLike('ABC') // true
- * isArrayLike({ length: 1, 0: 'Alpha' }) // true
- * isArrayLike({ key: 'value' }) // false
- * isArrayLike(new Map()) // false
- *
- * @param obj
- * A value which might implement the Array-like protocol.
- * @return {boolean} true if Array-like.
- */
- function isArrayLike (obj) {
- var length = obj != null && obj.length
- return typeof length === 'number' && length >= 0 && length % 1 === 0
- }
- exports.isArrayLike = isArrayLike
- /**
- * Returns true if the provided object is an Object (i.e. not a string literal)
- * and is either Iterable or Array-like.
- *
- * This may be used in place of [Array.isArray()][isArray] to determine if an
- * object should be iterated-over. It always excludes string literals and
- * includes Arrays (regardless of if it is Iterable). It also includes other
- * Array-like objects such as NodeList, TypedArray, and Buffer.
- *
- * @example
- *
- * var isCollection = require('iterall').isCollection
- * isCollection([ 1, 2, 3 ]) // true
- * isCollection('ABC') // false
- * isCollection({ length: 1, 0: 'Alpha' }) // true
- * isCollection({ key: 'value' }) // false
- * isCollection(new Map()) // true
- *
- * @example
- *
- * var forEach = require('iterall').forEach
- * if (isCollection(obj)) {
- * forEach(obj, function (value) {
- * console.log(value)
- * })
- * }
- *
- * @param obj
- * An Object value which might implement the Iterable or Array-like protocols.
- * @return {boolean} true if Iterable or Array-like Object.
- */
- function isCollection (obj) {
- return Object(obj) === obj && (isArrayLike(obj) || isIterable(obj))
- }
- exports.isCollection = isCollection
- /**
- * If the provided object implements the Iterator protocol, its Iterator object
- * is returned. Otherwise returns undefined.
- *
- * @example
- *
- * var getIterator = require('iterall').getIterator
- * var iterator = getIterator([ 1, 2, 3 ])
- * iterator.next() // { value: 1, done: false }
- * iterator.next() // { value: 2, done: false }
- * iterator.next() // { value: 3, done: false }
- * iterator.next() // { value: undefined, done: true }
- *
- * @template T the type of each iterated value
- * @param {Iterable<T>} iterable
- * An Iterable object which is the source of an Iterator.
- * @return {Iterator<T>} new Iterator instance.
- */
- function getIterator (iterable) {
- var method = getIteratorMethod(iterable)
- if (method) {
- return method.call(iterable)
- }
- }
- exports.getIterator = getIterator
- /**
- * If the provided object implements the Iterator protocol, the method
- * responsible for producing its Iterator object is returned.
- *
- * This is used in rare cases for performance tuning. This method must be called
- * with obj as the contextual this-argument.
- *
- * @example
- *
- * var getIteratorMethod = require('iterall').getIteratorMethod
- * var myArray = [ 1, 2, 3 ]
- * var method = getIteratorMethod(myArray)
- * if (method) {
- * var iterator = method.call(myArray)
- * }
- *
- * @template T the type of each iterated value
- * @param {Iterable<T>} iterable
- * An Iterable object which defines an `@@iterator` method.
- * @return {function(): Iterator<T>} `@@iterator` method.
- */
- function getIteratorMethod (iterable) {
- if (iterable != null) {
- var method = SYMBOL_ITERATOR && iterable[SYMBOL_ITERATOR] || iterable['@@iterator']
- if (typeof method === 'function') {
- return method
- }
- }
- }
- exports.getIteratorMethod = getIteratorMethod
- /**
- * Given an object which either implements the Iterable protocol or is
- * Array-like, iterate over it, calling the `callback` at each iteration.
- *
- * Use `forEach` where you would expect to use a `for ... of` loop in ES6.
- * However `forEach` adheres to the behavior of [Array#forEach][] described in
- * the ECMAScript specification, skipping over "holes" in Array-likes. It will
- * also delegate to a `forEach` method on `collection` if one is defined,
- * ensuring native performance for `Arrays`.
- *
- * Similar to [Array#forEach][], the `callback` function accepts three
- * arguments, and is provided with `thisArg` as the calling context.
- *
- * Note: providing an infinite Iterator to forEach will produce an error.
- *
- * [Array#forEach]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach
- *
- * @example
- *
- * var forEach = require('iterall').forEach
- *
- * forEach(myIterable, function (value, index, iterable) {
- * console.log(value, index, iterable === myIterable)
- * })
- *
- * @example
- *
- * // ES6:
- * for (let value of myIterable) {
- * console.log(value)
- * }
- *
- * // Any JavaScript environment:
- * forEach(myIterable, function (value) {
- * console.log(value)
- * })
- *
- * @template T the type of each iterated value
- * @param {Iterable<T>|{ length: number }} collection
- * The Iterable or array to iterate over.
- * @param {function(T, number, object)} callback
- * Function to execute for each iteration, taking up to three arguments
- * @param [thisArg]
- * Optional. Value to use as `this` when executing `callback`.
- */
- function forEach (collection, callback, thisArg) {
- if (collection != null) {
- if (typeof collection.forEach === 'function') {
- return collection.forEach(callback, thisArg)
- }
- var i = 0
- var iterator = getIterator(collection)
- if (iterator) {
- var step
- while (!(step = iterator.next()).done) {
- callback.call(thisArg, step.value, i++, collection)
- // Infinite Iterators could cause forEach to run forever.
- // After a very large number of iterations, produce an error.
- /* istanbul ignore if */
- if (i > 9999999) {
- throw new TypeError('Near-infinite iteration.')
- }
- }
- } else if (isArrayLike(collection)) {
- for (; i < collection.length; i++) {
- if (collection.hasOwnProperty(i)) {
- callback.call(thisArg, collection[i], i, collection)
- }
- }
- }
- }
- }
- exports.forEach = forEach
- /**
- * Similar to `getIterator()`, this method returns a new Iterator given an
- * Iterable. However it will also create an Iterator for a non-Iterable
- * Array-like collection, such as Array in a non-ES2015 environment.
- *
- * `createIterator` is complimentary to `forEach`, but allows a "pull"-based
- * iteration as opposed to `forEach`'s "push"-based iteration.
- *
- * `createIterator` produces an Iterator for Array-likes with the same behavior
- * as ArrayIteratorPrototype described in the ECMAScript specification, and
- * does *not* skip over "holes".
- *
- * @example
- *
- * var createIterator = require('iterall').createIterator
- *
- * var myArraylike = { length: 3, 0: 'Alpha', 1: 'Bravo', 2: 'Charlie' }
- * var iterator = createIterator(myArraylike)
- * iterator.next() // { value: 'Alpha', done: false }
- * iterator.next() // { value: 'Bravo', done: false }
- * iterator.next() // { value: 'Charlie', done: false }
- * iterator.next() // { value: undefined, done: true }
- *
- * @template T the type of each iterated value
- * @param {Iterable<T>|{ length: number }} collection
- * An Iterable or Array-like object to produce an Iterator.
- * @return {Iterator<T>} new Iterator instance.
- */
- function createIterator (collection) {
- if (collection != null) {
- var iterator = getIterator(collection)
- if (iterator) {
- return iterator
- }
- if (isArrayLike(collection)) {
- return new ArrayLikeIterator(collection)
- }
- }
- }
- exports.createIterator = createIterator
- // When the object provided to `createIterator` is not Iterable but is
- // Array-like, this simple Iterator is created.
- function ArrayLikeIterator (obj) {
- this._o = obj
- this._i = 0
- }
- // Note: all Iterators are themselves Iterable.
- ArrayLikeIterator.prototype[$$iterator] = function () {
- return this
- }
- // A simple state-machine determines the IteratorResult returned, yielding
- // each value in the Array-like object in order of their indicies.
- ArrayLikeIterator.prototype.next = function () {
- if (this._o === void 0 || this._i >= this._o.length) {
- this._o = void 0
- return { value: void 0, done: true }
- }
- return { value: this._o[this._i++], done: false }
- }
- /***/ }),
- /* 21 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = keyValMap;
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- /**
- * Creates a keyed JS object from an array, given a function to produce the keys
- * and a function to produce the values from each item in the array.
- *
- * const phoneBook = [
- * { name: 'Jon', num: '555-1234' },
- * { name: 'Jenny', num: '867-5309' }
- * ]
- *
- * // { Jon: '555-1234', Jenny: '867-5309' }
- * const phonesByName = keyValMap(
- * phoneBook,
- * entry => entry.name,
- * entry => entry.num
- * )
- *
- */
- function keyValMap(list, keyFn, valFn) {
- return list.reduce(function (map, item) {
- return map[keyFn(item)] = valFn(item), map;
- }, {});
- }
- /***/ }),
- /* 22 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = quotedOrList;
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- var MAX_LENGTH = 5;
- /**
- * Given [ A, B, C ] return '"A", "B", or "C"'.
- */
- function quotedOrList(items) {
- var selected = items.slice(0, MAX_LENGTH);
- return selected.map(function (item) {
- return '"' + item + '"';
- }).reduce(function (list, quoted, index) {
- return list + (selected.length > 2 ? ', ' : ' ') + (index === selected.length - 1 ? 'or ' : '') + quoted;
- });
- }
- /***/ }),
- /* 23 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.default = suggestionList;
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- /**
- * Given an invalid input string and a list of valid options, returns a filtered
- * list of valid options sorted based on their similarity with the input.
- */
- function suggestionList(input, options) {
- var optionsByDistance = Object.create(null);
- var oLength = options.length;
- var inputThreshold = input.length / 2;
- for (var i = 0; i < oLength; i++) {
- var distance = lexicalDistance(input, options[i]);
- var threshold = Math.max(inputThreshold, options[i].length / 2, 1);
- if (distance <= threshold) {
- optionsByDistance[options[i]] = distance;
- }
- }
- return Object.keys(optionsByDistance).sort(function (a, b) {
- return optionsByDistance[a] - optionsByDistance[b];
- });
- }
- /**
- * Computes the lexical distance between strings A and B.
- *
- * The "distance" between two strings is given by counting the minimum number
- * of edits needed to transform string A into string B. An edit can be an
- * insertion, deletion, or substitution of a single character, or a swap of two
- * adjacent characters.
- *
- * This distance can be useful for detecting typos in input or sorting
- *
- * @param {string} a
- * @param {string} b
- * @return {int} distance in number of edits
- */
- function lexicalDistance(a, b) {
- var i = void 0;
- var j = void 0;
- var d = [];
- var aLength = a.length;
- var bLength = b.length;
- for (i = 0; i <= aLength; i++) {
- d[i] = [i];
- }
- for (j = 1; j <= bLength; j++) {
- d[0][j] = j;
- }
- for (i = 1; i <= aLength; i++) {
- for (j = 1; j <= bLength; j++) {
- var cost = a[i - 1] === b[j - 1] ? 0 : 1;
- d[i][j] = Math.min(d[i - 1][j] + 1, d[i][j - 1] + 1, d[i - 1][j - 1] + cost);
- if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) {
- d[i][j] = Math.min(d[i][j], d[i - 2][j - 2] + cost);
- }
- }
- }
- return d[aLength][bLength];
- }
- /***/ }),
- /* 24 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.TokenKind = undefined;
- exports.createLexer = createLexer;
- exports.getTokenDesc = getTokenDesc;
- var _error = __webpack_require__(0);
- /**
- * Given a Source object, this returns a Lexer for that source.
- * A Lexer is a stateful stream generator in that every time
- * it is advanced, it returns the next token in the Source. Assuming the
- * source lexes, the final Token emitted by the lexer will be of kind
- * EOF, after which the lexer will repeatedly return the same EOF token
- * whenever called.
- */
- function createLexer(source, options) {
- var startOfFileToken = new Tok(SOF, 0, 0, 0, 0, null);
- var lexer = {
- source: source,
- options: options,
- lastToken: startOfFileToken,
- token: startOfFileToken,
- line: 1,
- lineStart: 0,
- advance: advanceLexer
- };
- return lexer;
- } /* /
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function advanceLexer() {
- var token = this.lastToken = this.token;
- if (token.kind !== EOF) {
- do {
- token = token.next = readToken(this, token);
- } while (token.kind === COMMENT);
- this.token = token;
- }
- return token;
- }
- /**
- * The return type of createLexer.
- */
- // Each kind of token.
- var SOF = '<SOF>';
- var EOF = '<EOF>';
- var BANG = '!';
- var DOLLAR = '$';
- var PAREN_L = '(';
- var PAREN_R = ')';
- var SPREAD = '...';
- var COLON = ':';
- var EQUALS = '=';
- var AT = '@';
- var BRACKET_L = '[';
- var BRACKET_R = ']';
- var BRACE_L = '{';
- var PIPE = '|';
- var BRACE_R = '}';
- var NAME = 'Name';
- var INT = 'Int';
- var FLOAT = 'Float';
- var STRING = 'String';
- var COMMENT = 'Comment';
- /**
- * An exported enum describing the different kinds of tokens that the
- * lexer emits.
- */
- var TokenKind = exports.TokenKind = {
- SOF: SOF,
- EOF: EOF,
- BANG: BANG,
- DOLLAR: DOLLAR,
- PAREN_L: PAREN_L,
- PAREN_R: PAREN_R,
- SPREAD: SPREAD,
- COLON: COLON,
- EQUALS: EQUALS,
- AT: AT,
- BRACKET_L: BRACKET_L,
- BRACKET_R: BRACKET_R,
- BRACE_L: BRACE_L,
- PIPE: PIPE,
- BRACE_R: BRACE_R,
- NAME: NAME,
- INT: INT,
- FLOAT: FLOAT,
- STRING: STRING,
- COMMENT: COMMENT
- };
- /**
- * A helper function to describe a token as a string for debugging
- */
- function getTokenDesc(token) {
- var value = token.value;
- return value ? token.kind + ' "' + value + '"' : token.kind;
- }
- var charCodeAt = String.prototype.charCodeAt;
- var slice = String.prototype.slice;
- /**
- * Helper function for constructing the Token object.
- */
- function Tok(kind, start, end, line, column, prev, value) {
- this.kind = kind;
- this.start = start;
- this.end = end;
- this.line = line;
- this.column = column;
- this.value = value;
- this.prev = prev;
- this.next = null;
- }
- // Print a simplified form when appearing in JSON/util.inspect.
- Tok.prototype.toJSON = Tok.prototype.inspect = function toJSON() {
- return {
- kind: this.kind,
- value: this.value,
- line: this.line,
- column: this.column
- };
- };
- function printCharCode(code) {
- return (
- // NaN/undefined represents access beyond the end of the file.
- isNaN(code) ? EOF :
- // Trust JSON for ASCII.
- code < 0x007F ? JSON.stringify(String.fromCharCode(code)) :
- // Otherwise print the escaped form.
- '"\\u' + ('00' + code.toString(16).toUpperCase()).slice(-4) + '"'
- );
- }
- /**
- * Gets the next token from the source starting at the given position.
- *
- * This skips over whitespace and comments until it finds the next lexable
- * token, then lexes punctuators immediately or calls the appropriate helper
- * function for more complicated tokens.
- */
- function readToken(lexer, prev) {
- var source = lexer.source;
- var body = source.body;
- var bodyLength = body.length;
- var position = positionAfterWhitespace(body, prev.end, lexer);
- var line = lexer.line;
- var col = 1 + position - lexer.lineStart;
- if (position >= bodyLength) {
- return new Tok(EOF, bodyLength, bodyLength, line, col, prev);
- }
- var code = charCodeAt.call(body, position);
- // SourceCharacter
- if (code < 0x0020 && code !== 0x0009 && code !== 0x000A && code !== 0x000D) {
- throw (0, _error.syntaxError)(source, position, 'Cannot contain the invalid character ' + printCharCode(code) + '.');
- }
- switch (code) {
- // !
- case 33:
- return new Tok(BANG, position, position + 1, line, col, prev);
- // #
- case 35:
- return readComment(source, position, line, col, prev);
- // $
- case 36:
- return new Tok(DOLLAR, position, position + 1, line, col, prev);
- // (
- case 40:
- return new Tok(PAREN_L, position, position + 1, line, col, prev);
- // )
- case 41:
- return new Tok(PAREN_R, position, position + 1, line, col, prev);
- // .
- case 46:
- if (charCodeAt.call(body, position + 1) === 46 && charCodeAt.call(body, position + 2) === 46) {
- return new Tok(SPREAD, position, position + 3, line, col, prev);
- }
- break;
- // :
- case 58:
- return new Tok(COLON, position, position + 1, line, col, prev);
- // =
- case 61:
- return new Tok(EQUALS, position, position + 1, line, col, prev);
- // @
- case 64:
- return new Tok(AT, position, position + 1, line, col, prev);
- // [
- case 91:
- return new Tok(BRACKET_L, position, position + 1, line, col, prev);
- // ]
- case 93:
- return new Tok(BRACKET_R, position, position + 1, line, col, prev);
- // {
- case 123:
- return new Tok(BRACE_L, position, position + 1, line, col, prev);
- // |
- case 124:
- return new Tok(PIPE, position, position + 1, line, col, prev);
- // }
- case 125:
- return new Tok(BRACE_R, position, position + 1, line, col, prev);
- // A-Z _ a-z
- case 65:case 66:case 67:case 68:case 69:case 70:case 71:case 72:
- case 73:case 74:case 75:case 76:case 77:case 78:case 79:case 80:
- case 81:case 82:case 83:case 84:case 85:case 86:case 87:case 88:
- case 89:case 90:
- case 95:
- case 97:case 98:case 99:case 100:case 101:case 102:case 103:case 104:
- case 105:case 106:case 107:case 108:case 109:case 110:case 111:
- case 112:case 113:case 114:case 115:case 116:case 117:case 118:
- case 119:case 120:case 121:case 122:
- return readName(source, position, line, col, prev);
- // - 0-9
- case 45:
- case 48:case 49:case 50:case 51:case 52:
- case 53:case 54:case 55:case 56:case 57:
- return readNumber(source, position, code, line, col, prev);
- // "
- case 34:
- return readString(source, position, line, col, prev);
- }
- throw (0, _error.syntaxError)(source, position, unexpectedCharacterMessage(code));
- }
- /**
- * Report a message that an unexpected character was encountered.
- */
- function unexpectedCharacterMessage(code) {
- if (code === 39) {
- // '
- return 'Unexpected single quote character (\'), did you mean to use ' + 'a double quote (")?';
- }
- return 'Cannot parse the unexpected character ' + printCharCode(code) + '.';
- }
- /**
- * Reads from body starting at startPosition until it finds a non-whitespace
- * or commented character, then returns the position of that character for
- * lexing.
- */
- function positionAfterWhitespace(body, startPosition, lexer) {
- var bodyLength = body.length;
- var position = startPosition;
- while (position < bodyLength) {
- var code = charCodeAt.call(body, position);
- // tab | space | comma | BOM
- if (code === 9 || code === 32 || code === 44 || code === 0xFEFF) {
- ++position;
- } else if (code === 10) {
- // new line
- ++position;
- ++lexer.line;
- lexer.lineStart = position;
- } else if (code === 13) {
- // carriage return
- if (charCodeAt.call(body, position + 1) === 10) {
- position += 2;
- } else {
- ++position;
- }
- ++lexer.line;
- lexer.lineStart = position;
- } else {
- break;
- }
- }
- return position;
- }
- /**
- * Reads a comment token from the source file.
- *
- * #[\u0009\u0020-\uFFFF]*
- */
- function readComment(source, start, line, col, prev) {
- var body = source.body;
- var code = void 0;
- var position = start;
- do {
- code = charCodeAt.call(body, ++position);
- } while (code !== null && (
- // SourceCharacter but not LineTerminator
- code > 0x001F || code === 0x0009));
- return new Tok(COMMENT, start, position, line, col, prev, slice.call(body, start + 1, position));
- }
- /**
- * Reads a number token from the source file, either a float
- * or an int depending on whether a decimal point appears.
- *
- * Int: -?(0|[1-9][0-9]*)
- * Float: -?(0|[1-9][0-9]*)(\.[0-9]+)?((E|e)(+|-)?[0-9]+)?
- */
- function readNumber(source, start, firstCode, line, col, prev) {
- var body = source.body;
- var code = firstCode;
- var position = start;
- var isFloat = false;
- if (code === 45) {
- // -
- code = charCodeAt.call(body, ++position);
- }
- if (code === 48) {
- // 0
- code = charCodeAt.call(body, ++position);
- if (code >= 48 && code <= 57) {
- throw (0, _error.syntaxError)(source, position, 'Invalid number, unexpected digit after 0: ' + printCharCode(code) + '.');
- }
- } else {
- position = readDigits(source, position, code);
- code = charCodeAt.call(body, position);
- }
- if (code === 46) {
- // .
- isFloat = true;
- code = charCodeAt.call(body, ++position);
- position = readDigits(source, position, code);
- code = charCodeAt.call(body, position);
- }
- if (code === 69 || code === 101) {
- // E e
- isFloat = true;
- code = charCodeAt.call(body, ++position);
- if (code === 43 || code === 45) {
- // + -
- code = charCodeAt.call(body, ++position);
- }
- position = readDigits(source, position, code);
- }
- return new Tok(isFloat ? FLOAT : INT, start, position, line, col, prev, slice.call(body, start, position));
- }
- /**
- * Returns the new position in the source after reading digits.
- */
- function readDigits(source, start, firstCode) {
- var body = source.body;
- var position = start;
- var code = firstCode;
- if (code >= 48 && code <= 57) {
- // 0 - 9
- do {
- code = charCodeAt.call(body, ++position);
- } while (code >= 48 && code <= 57); // 0 - 9
- return position;
- }
- throw (0, _error.syntaxError)(source, position, 'Invalid number, expected digit but got: ' + printCharCode(code) + '.');
- }
- /**
- * Reads a string token from the source file.
- *
- * "([^"\\\u000A\u000D]|(\\(u[0-9a-fA-F]{4}|["\\/bfnrt])))*"
- */
- function readString(source, start, line, col, prev) {
- var body = source.body;
- var position = start + 1;
- var chunkStart = position;
- var code = 0;
- var value = '';
- while (position < body.length && (code = charCodeAt.call(body, position)) !== null &&
- // not LineTerminator
- code !== 0x000A && code !== 0x000D &&
- // not Quote (")
- code !== 34) {
- // SourceCharacter
- if (code < 0x0020 && code !== 0x0009) {
- throw (0, _error.syntaxError)(source, position, 'Invalid character within String: ' + printCharCode(code) + '.');
- }
- ++position;
- if (code === 92) {
- // \
- value += slice.call(body, chunkStart, position - 1);
- code = charCodeAt.call(body, position);
- switch (code) {
- case 34:
- value += '"';break;
- case 47:
- value += '/';break;
- case 92:
- value += '\\';break;
- case 98:
- value += '\b';break;
- case 102:
- value += '\f';break;
- case 110:
- value += '\n';break;
- case 114:
- value += '\r';break;
- case 116:
- value += '\t';break;
- case 117:
- // u
- var charCode = uniCharCode(charCodeAt.call(body, position + 1), charCodeAt.call(body, position + 2), charCodeAt.call(body, position + 3), charCodeAt.call(body, position + 4));
- if (charCode < 0) {
- throw (0, _error.syntaxError)(source, position, 'Invalid character escape sequence: ' + ('\\u' + body.slice(position + 1, position + 5) + '.'));
- }
- value += String.fromCharCode(charCode);
- position += 4;
- break;
- default:
- throw (0, _error.syntaxError)(source, position, 'Invalid character escape sequence: \\' + String.fromCharCode(code) + '.');
- }
- ++position;
- chunkStart = position;
- }
- }
- if (code !== 34) {
- // quote (")
- throw (0, _error.syntaxError)(source, position, 'Unterminated string.');
- }
- value += slice.call(body, chunkStart, position);
- return new Tok(STRING, start, position + 1, line, col, prev, value);
- }
- /**
- * Converts four hexidecimal chars to the integer that the
- * string represents. For example, uniCharCode('0','0','0','f')
- * will return 15, and uniCharCode('0','0','f','f') returns 255.
- *
- * Returns a negative number on error, if a char was invalid.
- *
- * This is implemented by noting that char2hex() returns -1 on error,
- * which means the result of ORing the char2hex() will also be negative.
- */
- function uniCharCode(a, b, c, d) {
- return char2hex(a) << 12 | char2hex(b) << 8 | char2hex(c) << 4 | char2hex(d);
- }
- /**
- * Converts a hex character to its integer value.
- * '0' becomes 0, '9' becomes 9
- * 'A' becomes 10, 'F' becomes 15
- * 'a' becomes 10, 'f' becomes 15
- *
- * Returns -1 on error.
- */
- function char2hex(a) {
- return a >= 48 && a <= 57 ? a - 48 : // 0-9
- a >= 65 && a <= 70 ? a - 55 : // A-F
- a >= 97 && a <= 102 ? a - 87 : // a-f
- -1;
- }
- /**
- * Reads an alphanumeric + underscore name from the source.
- *
- * [_A-Za-z][_0-9A-Za-z]*
- */
- function readName(source, position, line, col, prev) {
- var body = source.body;
- var bodyLength = body.length;
- var end = position + 1;
- var code = 0;
- while (end !== bodyLength && (code = charCodeAt.call(body, end)) !== null && (code === 95 || // _
- code >= 48 && code <= 57 || // 0-9
- code >= 65 && code <= 90 || // A-Z
- code >= 97 && code <= 122 // a-z
- )) {
- ++end;
- }
- return new Tok(NAME, position, end, line, col, prev, slice.call(body, position, end));
- }
- /***/ }),
- /* 25 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.getLocation = getLocation;
- /**
- * Takes a Source and a UTF-8 character offset, and returns the corresponding
- * line and column as a SourceLocation.
- */
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function getLocation(source, position) {
- var lineRegexp = /\r\n|[\n\r]/g;
- var line = 1;
- var column = position + 1;
- var match = void 0;
- while ((match = lineRegexp.exec(source.body)) && match.index < position) {
- line += 1;
- column = position + 1 - (match.index + match[0].length);
- }
- return { line: line, column: column };
- }
- /**
- * Represents a location in a Source.
- */
- /***/ }),
- /* 26 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- /**
- * A representation of source input to GraphQL. The name is optional,
- * but is mostly useful for clients who store GraphQL documents in
- * source files; for example, if the GraphQL input is in a file Foo.graphql,
- * it might be useful for name to be "Foo.graphql".
- */
- var Source = exports.Source = function Source(body, name) {
- _classCallCheck(this, Source);
- this.body = body;
- this.name = name || 'GraphQL';
- };
- /***/ }),
- /* 27 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.TypeInfo = undefined;
- var _kinds = __webpack_require__(2);
- var Kind = _interopRequireWildcard(_kinds);
- var _definition = __webpack_require__(1);
- var _introspection = __webpack_require__(11);
- var _typeFromAST = __webpack_require__(9);
- var _find = __webpack_require__(10);
- var _find2 = _interopRequireDefault(_find);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- 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; } }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- /**
- * TypeInfo is a utility class which, given a GraphQL schema, can keep track
- * of the current field and type definitions at any point in a GraphQL document
- * AST during a recursive descent by calling `enter(node)` and `leave(node)`.
- */
- var TypeInfo = exports.TypeInfo = function () {
- function TypeInfo(schema,
- // NOTE: this experimental optional second parameter is only needed in order
- // to support non-spec-compliant codebases. You should never need to use it.
- getFieldDefFn) {
- _classCallCheck(this, TypeInfo);
- this._schema = schema;
- this._typeStack = [];
- this._parentTypeStack = [];
- this._inputTypeStack = [];
- this._fieldDefStack = [];
- this._directive = null;
- this._argument = null;
- this._enumValue = null;
- this._getFieldDef = getFieldDefFn || getFieldDef;
- }
- TypeInfo.prototype.getType = function getType() {
- if (this._typeStack.length > 0) {
- return this._typeStack[this._typeStack.length - 1];
- }
- };
- TypeInfo.prototype.getParentType = function getParentType() {
- if (this._parentTypeStack.length > 0) {
- return this._parentTypeStack[this._parentTypeStack.length - 1];
- }
- };
- TypeInfo.prototype.getInputType = function getInputType() {
- if (this._inputTypeStack.length > 0) {
- return this._inputTypeStack[this._inputTypeStack.length - 1];
- }
- };
- TypeInfo.prototype.getFieldDef = function getFieldDef() {
- if (this._fieldDefStack.length > 0) {
- return this._fieldDefStack[this._fieldDefStack.length - 1];
- }
- };
- TypeInfo.prototype.getDirective = function getDirective() {
- return this._directive;
- };
- TypeInfo.prototype.getArgument = function getArgument() {
- return this._argument;
- };
- TypeInfo.prototype.getEnumValue = function getEnumValue() {
- return this._enumValue;
- };
- // Flow does not yet handle this case.
- TypeInfo.prototype.enter = function enter(node /* ASTNode */) {
- var schema = this._schema;
- switch (node.kind) {
- case Kind.SELECTION_SET:
- var namedType = (0, _definition.getNamedType)(this.getType());
- var compositeType = void 0;
- if ((0, _definition.isCompositeType)(namedType)) {
- // isCompositeType is a type refining predicate, so this is safe.
- compositeType = namedType;
- }
- this._parentTypeStack.push(compositeType);
- break;
- case Kind.FIELD:
- var parentType = this.getParentType();
- var fieldDef = void 0;
- if (parentType) {
- fieldDef = this._getFieldDef(schema, parentType, node);
- }
- this._fieldDefStack.push(fieldDef);
- this._typeStack.push(fieldDef && fieldDef.type);
- break;
- case Kind.DIRECTIVE:
- this._directive = schema.getDirective(node.name.value);
- break;
- case Kind.OPERATION_DEFINITION:
- var type = void 0;
- if (node.operation === 'query') {
- type = schema.getQueryType();
- } else if (node.operation === 'mutation') {
- type = schema.getMutationType();
- } else if (node.operation === 'subscription') {
- type = schema.getSubscriptionType();
- }
- this._typeStack.push(type);
- break;
- case Kind.INLINE_FRAGMENT:
- case Kind.FRAGMENT_DEFINITION:
- var typeConditionAST = node.typeCondition;
- var outputType = typeConditionAST ? (0, _typeFromAST.typeFromAST)(schema, typeConditionAST) : this.getType();
- this._typeStack.push(outputType);
- break;
- case Kind.VARIABLE_DEFINITION:
- var inputType = (0, _typeFromAST.typeFromAST)(schema, node.type);
- this._inputTypeStack.push(inputType);
- break;
- case Kind.ARGUMENT:
- var argDef = void 0;
- var argType = void 0;
- var fieldOrDirective = this.getDirective() || this.getFieldDef();
- if (fieldOrDirective) {
- argDef = (0, _find2.default)(fieldOrDirective.args, function (arg) {
- return arg.name === node.name.value;
- });
- if (argDef) {
- argType = argDef.type;
- }
- }
- this._argument = argDef;
- this._inputTypeStack.push(argType);
- break;
- case Kind.LIST:
- var listType = (0, _definition.getNullableType)(this.getInputType());
- this._inputTypeStack.push(listType instanceof _definition.GraphQLList ? listType.ofType : undefined);
- break;
- case Kind.OBJECT_FIELD:
- var objectType = (0, _definition.getNamedType)(this.getInputType());
- var fieldType = void 0;
- if (objectType instanceof _definition.GraphQLInputObjectType) {
- var inputField = objectType.getFields()[node.name.value];
- fieldType = inputField ? inputField.type : undefined;
- }
- this._inputTypeStack.push(fieldType);
- break;
- case Kind.ENUM:
- var enumType = (0, _definition.getNamedType)(this.getInputType());
- var enumValue = void 0;
- if (enumType instanceof _definition.GraphQLEnumType) {
- enumValue = enumType.getValue(node.value);
- }
- this._enumValue = enumValue;
- break;
- }
- };
- TypeInfo.prototype.leave = function leave(node) {
- switch (node.kind) {
- case Kind.SELECTION_SET:
- this._parentTypeStack.pop();
- break;
- case Kind.FIELD:
- this._fieldDefStack.pop();
- this._typeStack.pop();
- break;
- case Kind.DIRECTIVE:
- this._directive = null;
- break;
- case Kind.OPERATION_DEFINITION:
- case Kind.INLINE_FRAGMENT:
- case Kind.FRAGMENT_DEFINITION:
- this._typeStack.pop();
- break;
- case Kind.VARIABLE_DEFINITION:
- this._inputTypeStack.pop();
- break;
- case Kind.ARGUMENT:
- this._argument = null;
- this._inputTypeStack.pop();
- break;
- case Kind.LIST:
- case Kind.OBJECT_FIELD:
- this._inputTypeStack.pop();
- break;
- case Kind.ENUM:
- this._enumValue = null;
- break;
- }
- };
- return TypeInfo;
- }();
- /**
- * Not exactly the same as the executor's definition of getFieldDef, in this
- * statically evaluated environment we do not always have an Object type,
- * and need to handle Interface and Union types.
- */
- function getFieldDef(schema, parentType, fieldNode) {
- var name = fieldNode.name.value;
- if (name === _introspection.SchemaMetaFieldDef.name && schema.getQueryType() === parentType) {
- return _introspection.SchemaMetaFieldDef;
- }
- if (name === _introspection.TypeMetaFieldDef.name && schema.getQueryType() === parentType) {
- return _introspection.TypeMetaFieldDef;
- }
- if (name === _introspection.TypeNameMetaFieldDef.name && (parentType instanceof _definition.GraphQLObjectType || parentType instanceof _definition.GraphQLInterfaceType || parentType instanceof _definition.GraphQLUnionType)) {
- return _introspection.TypeNameMetaFieldDef;
- }
- if (parentType instanceof _definition.GraphQLObjectType || parentType instanceof _definition.GraphQLInterfaceType) {
- return parentType.getFields()[name];
- }
- }
- /***/ }),
- /* 28 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.assertValidName = assertValidName;
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- var NAME_RX = /^[_a-zA-Z][_a-zA-Z0-9]*$/;
- // Ensures console warnings are only issued once.
- var hasWarnedAboutDunder = false;
- /**
- * Upholds the spec rules about naming.
- */
- function assertValidName(name, isIntrospection) {
- if (!name || typeof name !== 'string') {
- throw new Error('Must be named. Unexpected name: ' + name + '.');
- }
- if (!isIntrospection && name.slice(0, 2) === '__' && !hasWarnedAboutDunder) {
- hasWarnedAboutDunder = true;
- /* eslint-disable no-console */
- if (console && console.error) {
- var error = new Error('Name "' + name + '" must not begin with "__", which is reserved by ' + 'GraphQL introspection.');
- console.error(error.stack || String(error));
- }
- /* eslint-enable no-console */
- }
- if (!NAME_RX.test(name)) {
- throw new Error('Names must match /^[_a-zA-Z][_a-zA-Z0-9]*$/ but "' + name + '" does not.');
- }
- }
- /***/ }),
- /* 29 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.astFromValue = astFromValue;
- var _iterall = __webpack_require__(20);
- var _invariant = __webpack_require__(3);
- var _invariant2 = _interopRequireDefault(_invariant);
- var _isNullish = __webpack_require__(6);
- var _isNullish2 = _interopRequireDefault(_isNullish);
- var _isInvalid = __webpack_require__(14);
- var _isInvalid2 = _interopRequireDefault(_isInvalid);
- var _kinds = __webpack_require__(2);
- var _definition = __webpack_require__(1);
- var _scalars = __webpack_require__(7);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- /**
- * Produces a GraphQL Value AST given a JavaScript value.
- *
- * A GraphQL type must be provided, which will be used to interpret different
- * JavaScript values.
- *
- * | JSON Value | GraphQL Value |
- * | ------------- | -------------------- |
- * | Object | Input Object |
- * | Array | List |
- * | Boolean | Boolean |
- * | String | String / Enum Value |
- * | Number | Int / Float |
- * | Mixed | Enum Value |
- * | null | NullValue |
- *
- */
- function astFromValue(value, type) {
- // Ensure flow knows that we treat function params as const.
- var _value = value;
- if (type instanceof _definition.GraphQLNonNull) {
- var astValue = astFromValue(_value, type.ofType);
- if (astValue && astValue.kind === _kinds.NULL) {
- return null;
- }
- return astValue;
- }
- // only explicit null, not undefined, NaN
- if (_value === null) {
- return { kind: _kinds.NULL };
- }
- // undefined, NaN
- if ((0, _isInvalid2.default)(_value)) {
- return null;
- }
- // Convert JavaScript array to GraphQL list. If the GraphQLType is a list, but
- // the value is not an array, convert the value using the list's item type.
- if (type instanceof _definition.GraphQLList) {
- var _ret = function () {
- var itemType = type.ofType;
- if ((0, _iterall.isCollection)(_value)) {
- var _ret2 = function () {
- var valuesNodes = [];
- (0, _iterall.forEach)(_value, function (item) {
- var itemNode = astFromValue(item, itemType);
- if (itemNode) {
- valuesNodes.push(itemNode);
- }
- });
- return {
- v: {
- v: { kind: _kinds.LIST, values: valuesNodes }
- }
- };
- }();
- if (typeof _ret2 === "object") return _ret2.v;
- }
- return {
- v: astFromValue(_value, itemType)
- };
- }();
- if (typeof _ret === "object") return _ret.v;
- }
- // Populate the fields of the input object by creating ASTs from each value
- // in the JavaScript object according to the fields in the input type.
- if (type instanceof _definition.GraphQLInputObjectType) {
- var _ret3 = function () {
- if (_value === null || typeof _value !== 'object') {
- return {
- v: null
- };
- }
- var fields = type.getFields();
- var fieldNodes = [];
- Object.keys(fields).forEach(function (fieldName) {
- var fieldType = fields[fieldName].type;
- var fieldValue = astFromValue(_value[fieldName], fieldType);
- if (fieldValue) {
- fieldNodes.push({
- kind: _kinds.OBJECT_FIELD,
- name: { kind: _kinds.NAME, value: fieldName },
- value: fieldValue
- });
- }
- });
- return {
- v: { kind: _kinds.OBJECT, fields: fieldNodes }
- };
- }();
- if (typeof _ret3 === "object") return _ret3.v;
- }
- (0, _invariant2.default)(type instanceof _definition.GraphQLScalarType || type instanceof _definition.GraphQLEnumType, 'Must provide Input Type, cannot use: ' + String(type));
- // Since value is an internally represented value, it must be serialized
- // to an externally represented value before converting into an AST.
- var serialized = type.serialize(_value);
- if ((0, _isNullish2.default)(serialized)) {
- return null;
- }
- // Others serialize based on their corresponding JavaScript scalar types.
- if (typeof serialized === 'boolean') {
- return { kind: _kinds.BOOLEAN, value: serialized };
- }
- // JavaScript numbers can be Int or Float values.
- if (typeof serialized === 'number') {
- var stringNum = String(serialized);
- return (/^[0-9]+$/.test(stringNum) ? { kind: _kinds.INT, value: stringNum } : { kind: _kinds.FLOAT, value: stringNum }
- );
- }
- if (typeof serialized === 'string') {
- // Enum types use Enum literals.
- if (type instanceof _definition.GraphQLEnumType) {
- return { kind: _kinds.ENUM, value: serialized };
- }
- // ID types can use Int literals.
- if (type === _scalars.GraphQLID && /^[0-9]+$/.test(serialized)) {
- return { kind: _kinds.INT, value: serialized };
- }
- // Use JSON stringify, which uses the same string encoding as GraphQL,
- // then remove the quotes.
- return {
- kind: _kinds.STRING,
- value: JSON.stringify(serialized).slice(1, -1)
- };
- }
- throw new TypeError('Cannot convert value to AST: ' + String(serialized));
- }
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- /***/ }),
- /* 30 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.defaultFieldResolver = undefined;
- exports.execute = execute;
- exports.responsePathAsArray = responsePathAsArray;
- var _iterall = __webpack_require__(20);
- var _error = __webpack_require__(0);
- var _find = __webpack_require__(10);
- var _find2 = _interopRequireDefault(_find);
- var _invariant = __webpack_require__(3);
- var _invariant2 = _interopRequireDefault(_invariant);
- var _isNullish = __webpack_require__(6);
- var _isNullish2 = _interopRequireDefault(_isNullish);
- var _typeFromAST = __webpack_require__(9);
- var _kinds = __webpack_require__(2);
- var Kind = _interopRequireWildcard(_kinds);
- var _values = __webpack_require__(31);
- var _definition = __webpack_require__(1);
- var _schema = __webpack_require__(8);
- var _introspection = __webpack_require__(11);
- var _directives = __webpack_require__(5);
- 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; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- /**
- * Implements the "Evaluating requests" section of the GraphQL specification.
- *
- * Returns a Promise that will eventually be resolved and never rejected.
- *
- * If the arguments to this function do not result in a legal execution context,
- * a GraphQLError will be thrown immediately explaining the invalid input.
- */
- /**
- * Terminology
- *
- * "Definitions" are the generic name for top-level statements in the document.
- * Examples of this include:
- * 1) Operations (such as a query)
- * 2) Fragments
- *
- * "Operations" are a generic name for requests in the document.
- * Examples of this include:
- * 1) query,
- * 2) mutation
- *
- * "Selections" are the definitions that can appear legally and at
- * single level of the query. These include:
- * 1) field references e.g "a"
- * 2) fragment "spreads" e.g. "...c"
- * 3) inline fragment "spreads" e.g. "...on Type { a }"
- */
- /**
- * Data that must be available at all points during query execution.
- *
- * Namely, schema of the type system that is currently executing,
- * and the fragments defined in the query document
- */
- /**
- * The result of GraphQL execution.
- *
- * - `data` is the result of a successful execution of the query.
- * - `errors` is included when any errors occurred as a non-empty array.
- */
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function execute(schema, document, rootValue, contextValue, variableValues, operationName) {
- (0, _invariant2.default)(schema, 'Must provide schema');
- (0, _invariant2.default)(document, 'Must provide document');
- (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.');
- // Variables, if provided, must be an object.
- (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.');
- // If a valid context cannot be created due to incorrect arguments,
- // this will throw an error.
- var context = buildExecutionContext(schema, document, rootValue, contextValue, variableValues, operationName);
- // Return a Promise that will eventually resolve to the data described by
- // The "Response" section of the GraphQL specification.
- //
- // If errors are encountered while executing a GraphQL field, only that
- // field and its descendants will be omitted, and sibling fields will still
- // be executed. An execution which encounters errors will still result in a
- // resolved Promise.
- return new Promise(function (resolve) {
- resolve(executeOperation(context, context.operation, rootValue));
- }).then(undefined, function (error) {
- // Errors from sub-fields of a NonNull type may propagate to the top level,
- // at which point we still log the error and null the parent field, which
- // in this case is the entire response.
- context.errors.push(error);
- return null;
- }).then(function (data) {
- if (!context.errors.length) {
- return { data: data };
- }
- return { data: data, errors: context.errors };
- });
- }
- /**
- * Given a ResponsePath (found in the `path` entry in the information provided
- * as the last argument to a field resolver), return an Array of the path keys.
- */
- function responsePathAsArray(path) {
- var flattened = [];
- var curr = path;
- while (curr) {
- flattened.push(curr.key);
- curr = curr.prev;
- }
- return flattened.reverse();
- }
- function addPath(prev, key) {
- return { prev: prev, key: key };
- }
- /**
- * Constructs a ExecutionContext object from the arguments passed to
- * execute, which we will pass throughout the other execution methods.
- *
- * Throws a GraphQLError if a valid execution context cannot be created.
- */
- function buildExecutionContext(schema, document, rootValue, contextValue, rawVariableValues, operationName) {
- var errors = [];
- var operation = void 0;
- var fragments = Object.create(null);
- document.definitions.forEach(function (definition) {
- switch (definition.kind) {
- case Kind.OPERATION_DEFINITION:
- if (!operationName && operation) {
- throw new _error.GraphQLError('Must provide operation name if query contains multiple operations.');
- }
- if (!operationName || definition.name && definition.name.value === operationName) {
- operation = definition;
- }
- break;
- case Kind.FRAGMENT_DEFINITION:
- fragments[definition.name.value] = definition;
- break;
- default:
- throw new _error.GraphQLError('GraphQL cannot execute a request containing a ' + definition.kind + '.', [definition]);
- }
- });
- if (!operation) {
- if (operationName) {
- throw new _error.GraphQLError('Unknown operation named "' + operationName + '".');
- } else {
- throw new _error.GraphQLError('Must provide an operation.');
- }
- }
- var variableValues = (0, _values.getVariableValues)(schema, operation.variableDefinitions || [], rawVariableValues || {});
- return {
- schema: schema,
- fragments: fragments,
- rootValue: rootValue,
- contextValue: contextValue,
- operation: operation,
- variableValues: variableValues,
- errors: errors
- };
- }
- /**
- * Implements the "Evaluating operations" section of the spec.
- */
- function executeOperation(exeContext, operation, rootValue) {
- var type = getOperationRootType(exeContext.schema, operation);
- var fields = collectFields(exeContext, type, operation.selectionSet, Object.create(null), Object.create(null));
- var path = undefined;
- if (operation.operation === 'mutation') {
- return executeFieldsSerially(exeContext, type, rootValue, path, fields);
- }
- return executeFields(exeContext, type, rootValue, path, fields);
- }
- /**
- * Extracts the root type of the operation from the schema.
- */
- function getOperationRootType(schema, operation) {
- switch (operation.operation) {
- case 'query':
- return schema.getQueryType();
- case 'mutation':
- var mutationType = schema.getMutationType();
- if (!mutationType) {
- throw new _error.GraphQLError('Schema is not configured for mutations', [operation]);
- }
- return mutationType;
- case 'subscription':
- var subscriptionType = schema.getSubscriptionType();
- if (!subscriptionType) {
- throw new _error.GraphQLError('Schema is not configured for subscriptions', [operation]);
- }
- return subscriptionType;
- default:
- throw new _error.GraphQLError('Can only execute queries, mutations and subscriptions', [operation]);
- }
- }
- /**
- * Implements the "Evaluating selection sets" section of the spec
- * for "write" mode.
- */
- function executeFieldsSerially(exeContext, parentType, sourceValue, path, fields) {
- return Object.keys(fields).reduce(function (prevPromise, responseName) {
- return prevPromise.then(function (results) {
- var fieldNodes = fields[responseName];
- var fieldPath = addPath(path, responseName);
- var result = resolveField(exeContext, parentType, sourceValue, fieldNodes, fieldPath);
- if (result === undefined) {
- return results;
- }
- if (isThenable(result)) {
- return result.then(function (resolvedResult) {
- results[responseName] = resolvedResult;
- return results;
- });
- }
- results[responseName] = result;
- return results;
- });
- }, Promise.resolve({}));
- }
- /**
- * Implements the "Evaluating selection sets" section of the spec
- * for "read" mode.
- */
- function executeFields(exeContext, parentType, sourceValue, path, fields) {
- var containsPromise = false;
- var finalResults = Object.keys(fields).reduce(function (results, responseName) {
- var fieldNodes = fields[responseName];
- var fieldPath = addPath(path, responseName);
- var result = resolveField(exeContext, parentType, sourceValue, fieldNodes, fieldPath);
- if (result === undefined) {
- return results;
- }
- results[responseName] = result;
- if (isThenable(result)) {
- containsPromise = true;
- }
- return results;
- }, Object.create(null));
- // If there are no promises, we can just return the object
- if (!containsPromise) {
- return finalResults;
- }
- // Otherwise, results is a map from field name to the result
- // of resolving that field, which is possibly a promise. Return
- // a promise that will return this same map, but with any
- // promises replaced with the values they resolved to.
- return promiseForObject(finalResults);
- }
- /**
- * Given a selectionSet, adds all of the fields in that selection to
- * the passed in map of fields, and returns it at the end.
- *
- * CollectFields requires the "runtime type" of an object. For a field which
- * returns and Interface or Union type, the "runtime type" will be the actual
- * Object type returned by that field.
- */
- function collectFields(exeContext, runtimeType, selectionSet, fields, visitedFragmentNames) {
- for (var i = 0; i < selectionSet.selections.length; i++) {
- var selection = selectionSet.selections[i];
- switch (selection.kind) {
- case Kind.FIELD:
- if (!shouldIncludeNode(exeContext, selection.directives)) {
- continue;
- }
- var _name = getFieldEntryKey(selection);
- if (!fields[_name]) {
- fields[_name] = [];
- }
- fields[_name].push(selection);
- break;
- case Kind.INLINE_FRAGMENT:
- if (!shouldIncludeNode(exeContext, selection.directives) || !doesFragmentConditionMatch(exeContext, selection, runtimeType)) {
- continue;
- }
- collectFields(exeContext, runtimeType, selection.selectionSet, fields, visitedFragmentNames);
- break;
- case Kind.FRAGMENT_SPREAD:
- var fragName = selection.name.value;
- if (visitedFragmentNames[fragName] || !shouldIncludeNode(exeContext, selection.directives)) {
- continue;
- }
- visitedFragmentNames[fragName] = true;
- var fragment = exeContext.fragments[fragName];
- if (!fragment || !doesFragmentConditionMatch(exeContext, fragment, runtimeType)) {
- continue;
- }
- collectFields(exeContext, runtimeType, fragment.selectionSet, fields, visitedFragmentNames);
- break;
- }
- }
- return fields;
- }
- /**
- * Determines if a field should be included based on the @include and @skip
- * directives, where @skip has higher precidence than @include.
- */
- function shouldIncludeNode(exeContext, directives) {
- var skipNode = directives && (0, _find2.default)(directives, function (directive) {
- return directive.name.value === _directives.GraphQLSkipDirective.name;
- });
- if (skipNode) {
- var _getArgumentValues = (0, _values.getArgumentValues)(_directives.GraphQLSkipDirective, skipNode, exeContext.variableValues),
- skipIf = _getArgumentValues.if;
- if (skipIf === true) {
- return false;
- }
- }
- var includeNode = directives && (0, _find2.default)(directives, function (directive) {
- return directive.name.value === _directives.GraphQLIncludeDirective.name;
- });
- if (includeNode) {
- var _getArgumentValues2 = (0, _values.getArgumentValues)(_directives.GraphQLIncludeDirective, includeNode, exeContext.variableValues),
- includeIf = _getArgumentValues2.if;
- if (includeIf === false) {
- return false;
- }
- }
- return true;
- }
- /**
- * Determines if a fragment is applicable to the given type.
- */
- function doesFragmentConditionMatch(exeContext, fragment, type) {
- var typeConditionNode = fragment.typeCondition;
- if (!typeConditionNode) {
- return true;
- }
- var conditionalType = (0, _typeFromAST.typeFromAST)(exeContext.schema, typeConditionNode);
- if (conditionalType === type) {
- return true;
- }
- if ((0, _definition.isAbstractType)(conditionalType)) {
- var abstractType = conditionalType;
- return exeContext.schema.isPossibleType(abstractType, type);
- }
- return false;
- }
- /**
- * This function transforms a JS object `{[key: string]: Promise<T>}` into
- * a `Promise<{[key: string]: T}>`
- *
- * This is akin to bluebird's `Promise.props`, but implemented only using
- * `Promise.all` so it will work with any implementation of ES6 promises.
- */
- function promiseForObject(object) {
- var keys = Object.keys(object);
- var valuesAndPromises = keys.map(function (name) {
- return object[name];
- });
- return Promise.all(valuesAndPromises).then(function (values) {
- return values.reduce(function (resolvedObject, value, i) {
- resolvedObject[keys[i]] = value;
- return resolvedObject;
- }, Object.create(null));
- });
- }
- /**
- * Implements the logic to compute the key of a given field's entry
- */
- function getFieldEntryKey(node) {
- return node.alias ? node.alias.value : node.name.value;
- }
- /**
- * Resolves the field on the given source object. In particular, this
- * figures out the value that the field returns by calling its resolve function,
- * then calls completeValue to complete promises, serialize scalars, or execute
- * the sub-selection-set for objects.
- */
- function resolveField(exeContext, parentType, source, fieldNodes, path) {
- var fieldNode = fieldNodes[0];
- var fieldName = fieldNode.name.value;
- var fieldDef = getFieldDef(exeContext.schema, parentType, fieldName);
- if (!fieldDef) {
- return;
- }
- var returnType = fieldDef.type;
- var resolveFn = fieldDef.resolve || defaultFieldResolver;
- // The resolve function's optional third argument is a context value that
- // is provided to every resolve function within an execution. It is commonly
- // used to represent an authenticated user, or request-specific caches.
- var context = exeContext.contextValue;
- // The resolve function's optional fourth argument is a collection of
- // information about the current execution state.
- var info = {
- fieldName: fieldName,
- fieldNodes: fieldNodes,
- returnType: returnType,
- parentType: parentType,
- path: path,
- schema: exeContext.schema,
- fragments: exeContext.fragments,
- rootValue: exeContext.rootValue,
- operation: exeContext.operation,
- variableValues: exeContext.variableValues
- };
- // Get the resolve function, regardless of if its result is normal
- // or abrupt (error).
- var result = resolveOrError(exeContext, fieldDef, fieldNode, resolveFn, source, context, info);
- return completeValueCatchingError(exeContext, returnType, fieldNodes, info, path, result);
- }
- // Isolates the "ReturnOrAbrupt" behavior to not de-opt the `resolveField`
- // function. Returns the result of resolveFn or the abrupt-return Error object.
- function resolveOrError(exeContext, fieldDef, fieldNode, resolveFn, source, context, info) {
- try {
- // Build a JS object of arguments from the field.arguments AST, using the
- // variables scope to fulfill any variable references.
- // TODO: find a way to memoize, in case this field is within a List type.
- var args = (0, _values.getArgumentValues)(fieldDef, fieldNode, exeContext.variableValues);
- return resolveFn(source, args, context, info);
- } catch (error) {
- // Sometimes a non-error is thrown, wrap it as an Error for a
- // consistent interface.
- return error instanceof Error ? error : new Error(error);
- }
- }
- // This is a small wrapper around completeValue which detects and logs errors
- // in the execution context.
- function completeValueCatchingError(exeContext, returnType, fieldNodes, info, path, result) {
- // If the field type is non-nullable, then it is resolved without any
- // protection from errors, however it still properly locates the error.
- if (returnType instanceof _definition.GraphQLNonNull) {
- return completeValueWithLocatedError(exeContext, returnType, fieldNodes, info, path, result);
- }
- // Otherwise, error protection is applied, logging the error and resolving
- // a null value for this field if one is encountered.
- try {
- var completed = completeValueWithLocatedError(exeContext, returnType, fieldNodes, info, path, result);
- if (isThenable(completed)) {
- // If `completeValueWithLocatedError` returned a rejected promise, log
- // the rejection error and resolve to null.
- // Note: we don't rely on a `catch` method, but we do expect "thenable"
- // to take a second callback for the error case.
- return completed.then(undefined, function (error) {
- exeContext.errors.push(error);
- return Promise.resolve(null);
- });
- }
- return completed;
- } catch (error) {
- // If `completeValueWithLocatedError` returned abruptly (threw an error),
- // log the error and return null.
- exeContext.errors.push(error);
- return null;
- }
- }
- // This is a small wrapper around completeValue which annotates errors with
- // location information.
- function completeValueWithLocatedError(exeContext, returnType, fieldNodes, info, path, result) {
- try {
- var completed = completeValue(exeContext, returnType, fieldNodes, info, path, result);
- if (isThenable(completed)) {
- return completed.then(undefined, function (error) {
- return Promise.reject((0, _error.locatedError)(error, fieldNodes, responsePathAsArray(path)));
- });
- }
- return completed;
- } catch (error) {
- throw (0, _error.locatedError)(error, fieldNodes, responsePathAsArray(path));
- }
- }
- /**
- * Implements the instructions for completeValue as defined in the
- * "Field entries" section of the spec.
- *
- * If the field type is Non-Null, then this recursively completes the value
- * for the inner type. It throws a field error if that completion returns null,
- * as per the "Nullability" section of the spec.
- *
- * If the field type is a List, then this recursively completes the value
- * for the inner type on each item in the list.
- *
- * If the field type is a Scalar or Enum, ensures the completed value is a legal
- * value of the type by calling the `serialize` method of GraphQL type
- * definition.
- *
- * If the field is an abstract type, determine the runtime type of the value
- * and then complete based on that type
- *
- * Otherwise, the field type expects a sub-selection set, and will complete the
- * value by evaluating all sub-selections.
- */
- function completeValue(exeContext, returnType, fieldNodes, info, path, result) {
- // If result is a Promise, apply-lift over completeValue.
- if (isThenable(result)) {
- return result.then(function (resolved) {
- return completeValue(exeContext, returnType, fieldNodes, info, path, resolved);
- });
- }
- // If result is an Error, throw a located error.
- if (result instanceof Error) {
- throw result;
- }
- // If field type is NonNull, complete for inner type, and throw field error
- // if result is null.
- if (returnType instanceof _definition.GraphQLNonNull) {
- var completed = completeValue(exeContext, returnType.ofType, fieldNodes, info, path, result);
- if (completed === null) {
- throw new Error('Cannot return null for non-nullable field ' + info.parentType.name + '.' + info.fieldName + '.');
- }
- return completed;
- }
- // If result value is null-ish (null, undefined, or NaN) then return null.
- if ((0, _isNullish2.default)(result)) {
- return null;
- }
- // If field type is List, complete each item in the list with the inner type
- if (returnType instanceof _definition.GraphQLList) {
- return completeListValue(exeContext, returnType, fieldNodes, info, path, result);
- }
- // If field type is a leaf type, Scalar or Enum, serialize to a valid value,
- // returning null if serialization is not possible.
- if (returnType instanceof _definition.GraphQLScalarType || returnType instanceof _definition.GraphQLEnumType) {
- return completeLeafValue(returnType, result);
- }
- // If field type is an abstract type, Interface or Union, determine the
- // runtime Object type and complete for that type.
- if (returnType instanceof _definition.GraphQLInterfaceType || returnType instanceof _definition.GraphQLUnionType) {
- return completeAbstractValue(exeContext, returnType, fieldNodes, info, path, result);
- }
- // If field type is Object, execute and complete all sub-selections.
- if (returnType instanceof _definition.GraphQLObjectType) {
- return completeObjectValue(exeContext, returnType, fieldNodes, info, path, result);
- }
- // Not reachable. All possible output types have been considered.
- throw new Error('Cannot complete value of unexpected type "' + String(returnType) + '".');
- }
- /**
- * Complete a list value by completing each item in the list with the
- * inner type
- */
- function completeListValue(exeContext, returnType, fieldNodes, info, path, result) {
- (0, _invariant2.default)((0, _iterall.isCollection)(result), 'Expected Iterable, but did not find one for field ' + info.parentType.name + '.' + info.fieldName + '.');
- // This is specified as a simple map, however we're optimizing the path
- // where the list contains no Promises by avoiding creating another Promise.
- var itemType = returnType.ofType;
- var containsPromise = false;
- var completedResults = [];
- (0, _iterall.forEach)(result, function (item, index) {
- // No need to modify the info object containing the path,
- // since from here on it is not ever accessed by resolver functions.
- var fieldPath = addPath(path, index);
- var completedItem = completeValueCatchingError(exeContext, itemType, fieldNodes, info, fieldPath, item);
- if (!containsPromise && isThenable(completedItem)) {
- containsPromise = true;
- }
- completedResults.push(completedItem);
- });
- return containsPromise ? Promise.all(completedResults) : completedResults;
- }
- /**
- * Complete a Scalar or Enum by serializing to a valid value, returning
- * null if serialization is not possible.
- */
- function completeLeafValue(returnType, result) {
- (0, _invariant2.default)(returnType.serialize, 'Missing serialize method on type');
- var serializedResult = returnType.serialize(result);
- if ((0, _isNullish2.default)(serializedResult)) {
- throw new Error('Expected a value of type "' + String(returnType) + '" but ' + ('received: ' + String(result)));
- }
- return serializedResult;
- }
- /**
- * Complete a value of an abstract type by determining the runtime object type
- * of that value, then complete the value for that type.
- */
- function completeAbstractValue(exeContext, returnType, fieldNodes, info, path, result) {
- var runtimeType = returnType.resolveType ? returnType.resolveType(result, exeContext.contextValue, info) : defaultResolveTypeFn(result, exeContext.contextValue, info, returnType);
- if (isThenable(runtimeType)) {
- // Cast to Promise
- var runtimeTypePromise = runtimeType;
- return runtimeTypePromise.then(function (resolvedRuntimeType) {
- return completeObjectValue(exeContext, ensureValidRuntimeType(resolvedRuntimeType, exeContext, returnType, fieldNodes, info, result), fieldNodes, info, path, result);
- });
- }
- return completeObjectValue(exeContext, ensureValidRuntimeType(runtimeType, exeContext, returnType, fieldNodes, info, result), fieldNodes, info, path, result);
- }
- function ensureValidRuntimeType(runtimeTypeOrName, exeContext, returnType, fieldNodes, info, result) {
- var runtimeType = typeof runtimeTypeOrName === 'string' ? exeContext.schema.getType(runtimeTypeOrName) : runtimeTypeOrName;
- if (!(runtimeType instanceof _definition.GraphQLObjectType)) {
- 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);
- }
- if (!exeContext.schema.isPossibleType(returnType, runtimeType)) {
- throw new _error.GraphQLError('Runtime Object type "' + runtimeType.name + '" is not a possible type ' + ('for "' + returnType.name + '".'), fieldNodes);
- }
- return runtimeType;
- }
- /**
- * Complete an Object value by executing all sub-selections.
- */
- function completeObjectValue(exeContext, returnType, fieldNodes, info, path, result) {
- // If there is an isTypeOf predicate function, call it with the
- // current result. If isTypeOf returns false, then raise an error rather
- // than continuing execution.
- if (returnType.isTypeOf) {
- var isTypeOf = returnType.isTypeOf(result, exeContext.contextValue, info);
- if (isThenable(isTypeOf)) {
- return isTypeOf.then(function (isTypeOfResult) {
- if (!isTypeOfResult) {
- throw invalidReturnTypeError(returnType, result, fieldNodes);
- }
- return collectAndExecuteSubfields(exeContext, returnType, fieldNodes, info, path, result);
- });
- }
- if (!isTypeOf) {
- throw invalidReturnTypeError(returnType, result, fieldNodes);
- }
- }
- return collectAndExecuteSubfields(exeContext, returnType, fieldNodes, info, path, result);
- }
- function invalidReturnTypeError(returnType, result, fieldNodes) {
- return new _error.GraphQLError('Expected value of type "' + returnType.name + '" but got: ' + String(result) + '.', fieldNodes);
- }
- function collectAndExecuteSubfields(exeContext, returnType, fieldNodes, info, path, result) {
- // Collect sub-fields to execute to complete this value.
- var subFieldNodes = Object.create(null);
- var visitedFragmentNames = Object.create(null);
- for (var i = 0; i < fieldNodes.length; i++) {
- var selectionSet = fieldNodes[i].selectionSet;
- if (selectionSet) {
- subFieldNodes = collectFields(exeContext, returnType, selectionSet, subFieldNodes, visitedFragmentNames);
- }
- }
- return executeFields(exeContext, returnType, result, path, subFieldNodes);
- }
- /**
- * If a resolveType function is not given, then a default resolve behavior is
- * used which tests each possible type for the abstract type by calling
- * isTypeOf for the object being coerced, returning the first type that matches.
- */
- function defaultResolveTypeFn(value, context, info, abstractType) {
- var possibleTypes = info.schema.getPossibleTypes(abstractType);
- var promisedIsTypeOfResults = [];
- for (var i = 0; i < possibleTypes.length; i++) {
- var type = possibleTypes[i];
- if (type.isTypeOf) {
- var isTypeOfResult = type.isTypeOf(value, context, info);
- if (isThenable(isTypeOfResult)) {
- promisedIsTypeOfResults[i] = isTypeOfResult;
- } else if (isTypeOfResult) {
- return type;
- }
- }
- }
- if (promisedIsTypeOfResults.length) {
- return Promise.all(promisedIsTypeOfResults).then(function (isTypeOfResults) {
- for (var _i = 0; _i < isTypeOfResults.length; _i++) {
- if (isTypeOfResults[_i]) {
- return possibleTypes[_i];
- }
- }
- });
- }
- }
- /**
- * If a resolve function is not given, then a default resolve behavior is used
- * which takes the property of the source object of the same name as the field
- * and returns it as the result, or if it's a function, returns the result
- * of calling that function while passing along args and context.
- */
- var defaultFieldResolver = exports.defaultFieldResolver = function defaultFieldResolver(source, args, context, info) {
- // ensure source is a value for which property access is acceptable.
- if (typeof source === 'object' || typeof source === 'function') {
- var property = source[info.fieldName];
- if (typeof property === 'function') {
- return source[info.fieldName](args, context, info);
- }
- return property;
- }
- };
- /**
- * Checks to see if this object acts like a Promise, i.e. has a "then"
- * function.
- */
- function isThenable(value) {
- return typeof value === 'object' && value !== null && typeof value.then === 'function';
- }
- /**
- * This method looks up the field on the given type defintion.
- * It has special casing for the two introspection fields, __schema
- * and __typename. __typename is special because it can always be
- * queried as a field, even in situations where no other fields
- * are allowed, like on a Union. __schema could get automatically
- * added to the query type, but that would require mutating type
- * definitions, which would cause issues.
- */
- function getFieldDef(schema, parentType, fieldName) {
- if (fieldName === _introspection.SchemaMetaFieldDef.name && schema.getQueryType() === parentType) {
- return _introspection.SchemaMetaFieldDef;
- } else if (fieldName === _introspection.TypeMetaFieldDef.name && schema.getQueryType() === parentType) {
- return _introspection.TypeMetaFieldDef;
- } else if (fieldName === _introspection.TypeNameMetaFieldDef.name) {
- return _introspection.TypeNameMetaFieldDef;
- }
- return parentType.getFields()[fieldName];
- }
- /***/ }),
- /* 31 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.getVariableValues = getVariableValues;
- exports.getArgumentValues = getArgumentValues;
- var _iterall = __webpack_require__(20);
- var _error = __webpack_require__(0);
- var _invariant = __webpack_require__(3);
- var _invariant2 = _interopRequireDefault(_invariant);
- var _isNullish = __webpack_require__(6);
- var _isNullish2 = _interopRequireDefault(_isNullish);
- var _isInvalid = __webpack_require__(14);
- var _isInvalid2 = _interopRequireDefault(_isInvalid);
- var _keyMap = __webpack_require__(12);
- var _keyMap2 = _interopRequireDefault(_keyMap);
- var _typeFromAST = __webpack_require__(9);
- var _valueFromAST = __webpack_require__(16);
- var _isValidJSValue = __webpack_require__(33);
- var _isValidLiteralValue = __webpack_require__(18);
- var _kinds = __webpack_require__(2);
- var Kind = _interopRequireWildcard(_kinds);
- var _printer = __webpack_require__(4);
- var _definition = __webpack_require__(1);
- 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; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- /**
- * Prepares an object map of variableValues of the correct type based on the
- * provided variable definitions and arbitrary input. If the input cannot be
- * parsed to match the variable definitions, a GraphQLError will be thrown.
- */
- function getVariableValues(schema, varDefNodes, inputs) {
- var coercedValues = Object.create(null);
- for (var i = 0; i < varDefNodes.length; i++) {
- var varDefNode = varDefNodes[i];
- var varName = varDefNode.variable.name.value;
- var varType = (0, _typeFromAST.typeFromAST)(schema, varDefNode.type);
- if (!(0, _definition.isInputType)(varType)) {
- 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]);
- }
- varType = varType;
- var value = inputs[varName];
- if ((0, _isInvalid2.default)(value)) {
- var defaultValue = varDefNode.defaultValue;
- if (defaultValue) {
- coercedValues[varName] = (0, _valueFromAST.valueFromAST)(defaultValue, varType);
- }
- if (varType instanceof _definition.GraphQLNonNull) {
- throw new _error.GraphQLError('Variable "$' + varName + '" of required type ' + ('"' + String(varType) + '" was not provided.'), [varDefNode]);
- }
- } else {
- var errors = (0, _isValidJSValue.isValidJSValue)(value, varType);
- if (errors.length) {
- var message = errors ? '\n' + errors.join('\n') : '';
- throw new _error.GraphQLError('Variable "$' + varName + '" got invalid value ' + (JSON.stringify(value) + '.' + message), [varDefNode]);
- }
- var coercedValue = coerceValue(varType, value);
- (0, _invariant2.default)(!(0, _isInvalid2.default)(coercedValue), 'Should have reported error.');
- coercedValues[varName] = coercedValue;
- }
- }
- return coercedValues;
- }
- /**
- * Prepares an object map of argument values given a list of argument
- * definitions and list of argument AST nodes.
- */
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function getArgumentValues(def, node, variableValues) {
- var argDefs = def.args;
- var argNodes = node.arguments;
- if (!argDefs || !argNodes) {
- return {};
- }
- var coercedValues = Object.create(null);
- var argNodeMap = (0, _keyMap2.default)(argNodes, function (arg) {
- return arg.name.value;
- });
- for (var i = 0; i < argDefs.length; i++) {
- var argDef = argDefs[i];
- var name = argDef.name;
- var argType = argDef.type;
- var argumentNode = argNodeMap[name];
- var defaultValue = argDef.defaultValue;
- if (!argumentNode) {
- if (!(0, _isInvalid2.default)(defaultValue)) {
- coercedValues[name] = defaultValue;
- } else if (argType instanceof _definition.GraphQLNonNull) {
- throw new _error.GraphQLError('Argument "' + name + '" of required type ' + ('"' + String(argType) + '" was not provided.'), [node]);
- }
- } else if (argumentNode.value.kind === Kind.VARIABLE) {
- var variableName = argumentNode.value.name.value;
- if (variableValues && !(0, _isInvalid2.default)(variableValues[variableName])) {
- // Note: this does not check that this variable value is correct.
- // This assumes that this query has been validated and the variable
- // usage here is of the correct type.
- coercedValues[name] = variableValues[variableName];
- } else if (!(0, _isInvalid2.default)(defaultValue)) {
- coercedValues[name] = defaultValue;
- } else if (argType instanceof _definition.GraphQLNonNull) {
- 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]);
- }
- } else {
- var valueNode = argumentNode.value;
- var coercedValue = (0, _valueFromAST.valueFromAST)(valueNode, argType, variableValues);
- if ((0, _isInvalid2.default)(coercedValue)) {
- var errors = (0, _isValidLiteralValue.isValidLiteralValue)(argType, valueNode);
- var message = errors ? '\n' + errors.join('\n') : '';
- throw new _error.GraphQLError('Argument "' + name + '" got invalid value ' + (0, _printer.print)(valueNode) + '.' + message, [argumentNode.value]);
- }
- coercedValues[name] = coercedValue;
- }
- }
- return coercedValues;
- }
- /**
- * Given a type and any value, return a runtime value coerced to match the type.
- */
- function coerceValue(type, value) {
- // Ensure flow knows that we treat function params as const.
- var _value = value;
- if ((0, _isInvalid2.default)(_value)) {
- return; // Intentionally return no value.
- }
- if (type instanceof _definition.GraphQLNonNull) {
- if (_value === null) {
- return; // Intentionally return no value.
- }
- return coerceValue(type.ofType, _value);
- }
- if (_value === null) {
- // Intentionally return the value null.
- return null;
- }
- if (type instanceof _definition.GraphQLList) {
- var itemType = type.ofType;
- if ((0, _iterall.isCollection)(_value)) {
- var coercedValues = [];
- var valueIter = (0, _iterall.createIterator)(_value);
- if (!valueIter) {
- return; // Intentionally return no value.
- }
- var step = void 0;
- while (!(step = valueIter.next()).done) {
- var itemValue = coerceValue(itemType, step.value);
- if ((0, _isInvalid2.default)(itemValue)) {
- return; // Intentionally return no value.
- }
- coercedValues.push(itemValue);
- }
- return coercedValues;
- }
- var coercedValue = coerceValue(itemType, _value);
- if ((0, _isInvalid2.default)(coercedValue)) {
- return; // Intentionally return no value.
- }
- return [coerceValue(itemType, _value)];
- }
- if (type instanceof _definition.GraphQLInputObjectType) {
- if (typeof _value !== 'object') {
- return; // Intentionally return no value.
- }
- var coercedObj = Object.create(null);
- var fields = type.getFields();
- var fieldNames = Object.keys(fields);
- for (var i = 0; i < fieldNames.length; i++) {
- var fieldName = fieldNames[i];
- var field = fields[fieldName];
- if ((0, _isInvalid2.default)(_value[fieldName])) {
- if (!(0, _isInvalid2.default)(field.defaultValue)) {
- coercedObj[fieldName] = field.defaultValue;
- } else if (field.type instanceof _definition.GraphQLNonNull) {
- return; // Intentionally return no value.
- }
- continue;
- }
- var fieldValue = coerceValue(field.type, _value[fieldName]);
- if ((0, _isInvalid2.default)(fieldValue)) {
- return; // Intentionally return no value.
- }
- coercedObj[fieldName] = fieldValue;
- }
- return coercedObj;
- }
- (0, _invariant2.default)(type instanceof _definition.GraphQLScalarType || type instanceof _definition.GraphQLEnumType, 'Must be input type');
- var parsed = type.parseValue(_value);
- if ((0, _isNullish2.default)(parsed)) {
- // null or invalid values represent a failure to parse correctly,
- // in which case no value is returned.
- return;
- }
- return parsed;
- }
- /***/ }),
- /* 32 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.buildASTSchema = buildASTSchema;
- exports.getDescription = getDescription;
- exports.buildSchema = buildSchema;
- var _find = __webpack_require__(10);
- var _find2 = _interopRequireDefault(_find);
- var _invariant = __webpack_require__(3);
- var _invariant2 = _interopRequireDefault(_invariant);
- var _keyValMap = __webpack_require__(21);
- var _keyValMap2 = _interopRequireDefault(_keyValMap);
- var _valueFromAST = __webpack_require__(16);
- var _lexer = __webpack_require__(24);
- var _parser = __webpack_require__(17);
- var _values = __webpack_require__(31);
- var _kinds = __webpack_require__(2);
- var _schema = __webpack_require__(8);
- var _scalars = __webpack_require__(7);
- var _definition = __webpack_require__(1);
- var _directives = __webpack_require__(5);
- var _introspection = __webpack_require__(11);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- function buildWrappedType(innerType, inputTypeNode) {
- if (inputTypeNode.kind === _kinds.LIST_TYPE) {
- return new _definition.GraphQLList(buildWrappedType(innerType, inputTypeNode.type));
- }
- if (inputTypeNode.kind === _kinds.NON_NULL_TYPE) {
- var wrappedType = buildWrappedType(innerType, inputTypeNode.type);
- (0, _invariant2.default)(!(wrappedType instanceof _definition.GraphQLNonNull), 'No nesting nonnull.');
- return new _definition.GraphQLNonNull(wrappedType);
- }
- return innerType;
- }
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function getNamedTypeNode(typeNode) {
- var namedType = typeNode;
- while (namedType.kind === _kinds.LIST_TYPE || namedType.kind === _kinds.NON_NULL_TYPE) {
- namedType = namedType.type;
- }
- return namedType;
- }
- /**
- * This takes the ast of a schema document produced by the parse function in
- * src/language/parser.js.
- *
- * If no schema definition is provided, then it will look for types named Query
- * and Mutation.
- *
- * Given that AST it constructs a GraphQLSchema. The resulting schema
- * has no resolve methods, so execution will use default resolvers.
- */
- function buildASTSchema(ast) {
- if (!ast || ast.kind !== _kinds.DOCUMENT) {
- throw new Error('Must provide a document ast.');
- }
- var schemaDef = void 0;
- var typeDefs = [];
- var nodeMap = Object.create(null);
- var directiveDefs = [];
- for (var i = 0; i < ast.definitions.length; i++) {
- var d = ast.definitions[i];
- switch (d.kind) {
- case _kinds.SCHEMA_DEFINITION:
- if (schemaDef) {
- throw new Error('Must provide only one schema definition.');
- }
- schemaDef = d;
- break;
- case _kinds.SCALAR_TYPE_DEFINITION:
- case _kinds.OBJECT_TYPE_DEFINITION:
- case _kinds.INTERFACE_TYPE_DEFINITION:
- case _kinds.ENUM_TYPE_DEFINITION:
- case _kinds.UNION_TYPE_DEFINITION:
- case _kinds.INPUT_OBJECT_TYPE_DEFINITION:
- typeDefs.push(d);
- nodeMap[d.name.value] = d;
- break;
- case _kinds.DIRECTIVE_DEFINITION:
- directiveDefs.push(d);
- break;
- }
- }
- var queryTypeName = void 0;
- var mutationTypeName = void 0;
- var subscriptionTypeName = void 0;
- if (schemaDef) {
- schemaDef.operationTypes.forEach(function (operationType) {
- var typeName = operationType.type.name.value;
- if (operationType.operation === 'query') {
- if (queryTypeName) {
- throw new Error('Must provide only one query type in schema.');
- }
- if (!nodeMap[typeName]) {
- throw new Error('Specified query type "' + typeName + '" not found in document.');
- }
- queryTypeName = typeName;
- } else if (operationType.operation === 'mutation') {
- if (mutationTypeName) {
- throw new Error('Must provide only one mutation type in schema.');
- }
- if (!nodeMap[typeName]) {
- throw new Error('Specified mutation type "' + typeName + '" not found in document.');
- }
- mutationTypeName = typeName;
- } else if (operationType.operation === 'subscription') {
- if (subscriptionTypeName) {
- throw new Error('Must provide only one subscription type in schema.');
- }
- if (!nodeMap[typeName]) {
- throw new Error('Specified subscription type "' + typeName + '" not found in document.');
- }
- subscriptionTypeName = typeName;
- }
- });
- } else {
- if (nodeMap.Query) {
- queryTypeName = 'Query';
- }
- if (nodeMap.Mutation) {
- mutationTypeName = 'Mutation';
- }
- if (nodeMap.Subscription) {
- subscriptionTypeName = 'Subscription';
- }
- }
- if (!queryTypeName) {
- throw new Error('Must provide schema definition with query type or a type named Query.');
- }
- var innerTypeMap = {
- String: _scalars.GraphQLString,
- Int: _scalars.GraphQLInt,
- Float: _scalars.GraphQLFloat,
- Boolean: _scalars.GraphQLBoolean,
- ID: _scalars.GraphQLID,
- __Schema: _introspection.__Schema,
- __Directive: _introspection.__Directive,
- __DirectiveLocation: _introspection.__DirectiveLocation,
- __Type: _introspection.__Type,
- __Field: _introspection.__Field,
- __InputValue: _introspection.__InputValue,
- __EnumValue: _introspection.__EnumValue,
- __TypeKind: _introspection.__TypeKind
- };
- var types = typeDefs.map(function (def) {
- return typeDefNamed(def.name.value);
- });
- var directives = directiveDefs.map(getDirective);
- // If specified directives were not explicitly declared, add them.
- if (!directives.some(function (directive) {
- return directive.name === 'skip';
- })) {
- directives.push(_directives.GraphQLSkipDirective);
- }
- if (!directives.some(function (directive) {
- return directive.name === 'include';
- })) {
- directives.push(_directives.GraphQLIncludeDirective);
- }
- if (!directives.some(function (directive) {
- return directive.name === 'deprecated';
- })) {
- directives.push(_directives.GraphQLDeprecatedDirective);
- }
- return new _schema.GraphQLSchema({
- query: getObjectType(nodeMap[queryTypeName]),
- mutation: mutationTypeName ? getObjectType(nodeMap[mutationTypeName]) : null,
- subscription: subscriptionTypeName ? getObjectType(nodeMap[subscriptionTypeName]) : null,
- types: types,
- directives: directives
- });
- function getDirective(directiveNode) {
- return new _directives.GraphQLDirective({
- name: directiveNode.name.value,
- description: getDescription(directiveNode),
- locations: directiveNode.locations.map(function (node) {
- return node.value;
- }),
- args: directiveNode.arguments && makeInputValues(directiveNode.arguments)
- });
- }
- function getObjectType(typeNode) {
- var type = typeDefNamed(typeNode.name.value);
- (0, _invariant2.default)(type instanceof _definition.GraphQLObjectType, 'AST must provide object type.');
- return type;
- }
- function produceType(typeNode) {
- var typeName = getNamedTypeNode(typeNode).name.value;
- var typeDef = typeDefNamed(typeName);
- return buildWrappedType(typeDef, typeNode);
- }
- function produceInputType(typeNode) {
- var type = produceType(typeNode);
- (0, _invariant2.default)((0, _definition.isInputType)(type), 'Expected Input type.');
- return type;
- }
- function produceOutputType(typeNode) {
- var type = produceType(typeNode);
- (0, _invariant2.default)((0, _definition.isOutputType)(type), 'Expected Output type.');
- return type;
- }
- function produceObjectType(typeNode) {
- var type = produceType(typeNode);
- (0, _invariant2.default)(type instanceof _definition.GraphQLObjectType, 'Expected Object type.');
- return type;
- }
- function produceInterfaceType(typeNode) {
- var type = produceType(typeNode);
- (0, _invariant2.default)(type instanceof _definition.GraphQLInterfaceType, 'Expected Interface type.');
- return type;
- }
- function typeDefNamed(typeName) {
- if (innerTypeMap[typeName]) {
- return innerTypeMap[typeName];
- }
- if (!nodeMap[typeName]) {
- throw new Error('Type "' + typeName + '" not found in document.');
- }
- var innerTypeDef = makeSchemaDef(nodeMap[typeName]);
- if (!innerTypeDef) {
- throw new Error('Nothing constructed for "' + typeName + '".');
- }
- innerTypeMap[typeName] = innerTypeDef;
- return innerTypeDef;
- }
- function makeSchemaDef(def) {
- if (!def) {
- throw new Error('def must be defined');
- }
- switch (def.kind) {
- case _kinds.OBJECT_TYPE_DEFINITION:
- return makeTypeDef(def);
- case _kinds.INTERFACE_TYPE_DEFINITION:
- return makeInterfaceDef(def);
- case _kinds.ENUM_TYPE_DEFINITION:
- return makeEnumDef(def);
- case _kinds.UNION_TYPE_DEFINITION:
- return makeUnionDef(def);
- case _kinds.SCALAR_TYPE_DEFINITION:
- return makeScalarDef(def);
- case _kinds.INPUT_OBJECT_TYPE_DEFINITION:
- return makeInputObjectDef(def);
- default:
- throw new Error('Type kind "' + def.kind + '" not supported.');
- }
- }
- function makeTypeDef(def) {
- var typeName = def.name.value;
- return new _definition.GraphQLObjectType({
- name: typeName,
- description: getDescription(def),
- fields: function fields() {
- return makeFieldDefMap(def);
- },
- interfaces: function interfaces() {
- return makeImplementedInterfaces(def);
- }
- });
- }
- function makeFieldDefMap(def) {
- return (0, _keyValMap2.default)(def.fields, function (field) {
- return field.name.value;
- }, function (field) {
- return {
- type: produceOutputType(field.type),
- description: getDescription(field),
- args: makeInputValues(field.arguments),
- deprecationReason: getDeprecationReason(field.directives)
- };
- });
- }
- function makeImplementedInterfaces(def) {
- return def.interfaces && def.interfaces.map(function (iface) {
- return produceInterfaceType(iface);
- });
- }
- function makeInputValues(values) {
- return (0, _keyValMap2.default)(values, function (value) {
- return value.name.value;
- }, function (value) {
- var type = produceInputType(value.type);
- return {
- type: type,
- description: getDescription(value),
- defaultValue: (0, _valueFromAST.valueFromAST)(value.defaultValue, type)
- };
- });
- }
- function makeInterfaceDef(def) {
- var typeName = def.name.value;
- return new _definition.GraphQLInterfaceType({
- name: typeName,
- description: getDescription(def),
- fields: function fields() {
- return makeFieldDefMap(def);
- },
- resolveType: cannotExecuteSchema
- });
- }
- function makeEnumDef(def) {
- var enumType = new _definition.GraphQLEnumType({
- name: def.name.value,
- description: getDescription(def),
- values: (0, _keyValMap2.default)(def.values, function (enumValue) {
- return enumValue.name.value;
- }, function (enumValue) {
- return {
- description: getDescription(enumValue),
- deprecationReason: getDeprecationReason(enumValue.directives)
- };
- })
- });
- return enumType;
- }
- function makeUnionDef(def) {
- return new _definition.GraphQLUnionType({
- name: def.name.value,
- description: getDescription(def),
- types: def.types.map(function (t) {
- return produceObjectType(t);
- }),
- resolveType: cannotExecuteSchema
- });
- }
- function makeScalarDef(def) {
- return new _definition.GraphQLScalarType({
- name: def.name.value,
- description: getDescription(def),
- serialize: function serialize() {
- return null;
- },
- // Note: validation calls the parse functions to determine if a
- // literal value is correct. Returning null would cause use of custom
- // scalars to always fail validation. Returning false causes them to
- // always pass validation.
- parseValue: function parseValue() {
- return false;
- },
- parseLiteral: function parseLiteral() {
- return false;
- }
- });
- }
- function makeInputObjectDef(def) {
- return new _definition.GraphQLInputObjectType({
- name: def.name.value,
- description: getDescription(def),
- fields: function fields() {
- return makeInputValues(def.fields);
- }
- });
- }
- }
- function getDeprecationReason(directives) {
- var deprecatedAST = directives && (0, _find2.default)(directives, function (directive) {
- return directive.name.value === _directives.GraphQLDeprecatedDirective.name;
- });
- if (!deprecatedAST) {
- return;
- }
- var _getArgumentValues = (0, _values.getArgumentValues)(_directives.GraphQLDeprecatedDirective, deprecatedAST),
- reason = _getArgumentValues.reason;
- return reason;
- }
- /**
- * Given an ast node, returns its string description based on a contiguous
- * block full-line of comments preceding it.
- */
- function getDescription(node) {
- var loc = node.loc;
- if (!loc) {
- return;
- }
- var comments = [];
- var minSpaces = void 0;
- var token = loc.startToken.prev;
- while (token && token.kind === _lexer.TokenKind.COMMENT && token.next && token.prev && token.line + 1 === token.next.line && token.line !== token.prev.line) {
- var value = String(token.value);
- var spaces = leadingSpaces(value);
- if (minSpaces === undefined || spaces < minSpaces) {
- minSpaces = spaces;
- }
- comments.push(value);
- token = token.prev;
- }
- return comments.reverse().map(function (comment) {
- return comment.slice(minSpaces);
- }).join('\n');
- }
- /**
- * A helper function to build a GraphQLSchema directly from a source
- * document.
- */
- function buildSchema(source) {
- return buildASTSchema((0, _parser.parse)(source));
- }
- // Count the number of spaces on the starting side of a string.
- function leadingSpaces(str) {
- var i = 0;
- for (; i < str.length; i++) {
- if (str[i] !== ' ') {
- break;
- }
- }
- return i;
- }
- function cannotExecuteSchema() {
- throw new Error('Generated Schema cannot use Interface or Union types for execution.');
- }
- /***/ }),
- /* 33 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.isValidJSValue = isValidJSValue;
- var _iterall = __webpack_require__(20);
- var _invariant = __webpack_require__(3);
- var _invariant2 = _interopRequireDefault(_invariant);
- var _isNullish = __webpack_require__(6);
- var _isNullish2 = _interopRequireDefault(_isNullish);
- var _definition = __webpack_require__(1);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- /**
- * Given a JavaScript value and a GraphQL type, determine if the value will be
- * accepted for that type. This is primarily useful for validating the
- * runtime values of query variables.
- */
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function isValidJSValue(value, type) {
- // A value must be provided if the type is non-null.
- if (type instanceof _definition.GraphQLNonNull) {
- if ((0, _isNullish2.default)(value)) {
- return ['Expected "' + String(type) + '", found null.'];
- }
- return isValidJSValue(value, type.ofType);
- }
- if ((0, _isNullish2.default)(value)) {
- return [];
- }
- // Lists accept a non-list value as a list of one.
- if (type instanceof _definition.GraphQLList) {
- var _ret = function () {
- var itemType = type.ofType;
- if ((0, _iterall.isCollection)(value)) {
- var _ret2 = function () {
- var errors = [];
- (0, _iterall.forEach)(value, function (item, index) {
- errors.push.apply(errors, isValidJSValue(item, itemType).map(function (error) {
- return 'In element #' + index + ': ' + error;
- }));
- });
- return {
- v: {
- v: errors
- }
- };
- }();
- if (typeof _ret2 === "object") return _ret2.v;
- }
- return {
- v: isValidJSValue(value, itemType)
- };
- }();
- if (typeof _ret === "object") return _ret.v;
- }
- // Input objects check each defined field.
- if (type instanceof _definition.GraphQLInputObjectType) {
- var _ret3 = function () {
- if (typeof value !== 'object' || value === null) {
- return {
- v: ['Expected "' + type.name + '", found not an object.']
- };
- }
- var fields = type.getFields();
- var errors = [];
- // Ensure every provided field is defined.
- Object.keys(value).forEach(function (providedField) {
- if (!fields[providedField]) {
- errors.push('In field "' + providedField + '": Unknown field.');
- }
- });
- // Ensure every defined field is valid.
- Object.keys(fields).forEach(function (fieldName) {
- var newErrors = isValidJSValue(value[fieldName], fields[fieldName].type);
- errors.push.apply(errors, newErrors.map(function (error) {
- return 'In field "' + fieldName + '": ' + error;
- }));
- });
- return {
- v: errors
- };
- }();
- if (typeof _ret3 === "object") return _ret3.v;
- }
- (0, _invariant2.default)(type instanceof _definition.GraphQLScalarType || type instanceof _definition.GraphQLEnumType, 'Must be input type');
- // Scalar/Enum input checks to ensure the type can parse the value to
- // a non-null value.
- try {
- var parseResult = type.parseValue(value);
- if ((0, _isNullish2.default)(parseResult)) {
- return ['Expected type "' + type.name + '", found ' + JSON.stringify(value) + '.'];
- }
- } catch (error) {
- return ['Expected type "' + type.name + '", found ' + JSON.stringify(value) + ': ' + error.message];
- }
- return [];
- }
- /***/ }),
- /* 34 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.specifiedRules = undefined;
- var _UniqueOperationNames = __webpack_require__(77);
- var _LoneAnonymousOperation = __webpack_require__(64);
- var _KnownTypeNames = __webpack_require__(63);
- var _FragmentsOnCompositeTypes = __webpack_require__(59);
- var _VariablesAreInputTypes = __webpack_require__(79);
- var _ScalarLeafs = __webpack_require__(72);
- var _FieldsOnCorrectType = __webpack_require__(58);
- var _UniqueFragmentNames = __webpack_require__(75);
- var _KnownFragmentNames = __webpack_require__(62);
- var _NoUnusedFragments = __webpack_require__(67);
- var _PossibleFragmentSpreads = __webpack_require__(70);
- var _NoFragmentCycles = __webpack_require__(65);
- var _UniqueVariableNames = __webpack_require__(78);
- var _NoUndefinedVariables = __webpack_require__(66);
- var _NoUnusedVariables = __webpack_require__(68);
- var _KnownDirectives = __webpack_require__(61);
- var _UniqueDirectivesPerLocation = __webpack_require__(74);
- var _KnownArgumentNames = __webpack_require__(60);
- var _UniqueArgumentNames = __webpack_require__(73);
- var _ArgumentsOfCorrectType = __webpack_require__(56);
- var _ProvidedNonNullArguments = __webpack_require__(71);
- var _DefaultValuesOfCorrectType = __webpack_require__(57);
- var _VariablesInAllowedPosition = __webpack_require__(80);
- var _OverlappingFieldsCanBeMerged = __webpack_require__(69);
- var _UniqueInputFieldNames = __webpack_require__(76);
- /**
- * This set includes all validation rules defined by the GraphQL spec.
- */
- // Spec Section: "Field Selection Merging"
- // Spec Section: "Variable Default Values Are Correctly Typed"
- // Spec Section: "Argument Values Type Correctness"
- // Spec Section: "Argument Names"
- // Spec Section: "Directives Are Defined"
- // Spec Section: "All Variable Used Defined"
- // Spec Section: "Fragments must not form cycles"
- // Spec Section: "Fragments must be used"
- // Spec Section: "Fragment Name Uniqueness"
- // Spec Section: "Leaf Field Selections"
- // Spec Section: "Fragments on Composite Types"
- // Spec Section: "Lone Anonymous Operation"
- 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];
- // Spec Section: "Input Object Field Uniqueness"
- // Spec Section: "All Variable Usages Are Allowed"
- // Spec Section: "Argument Optionality"
- // Spec Section: "Argument Uniqueness"
- // Spec Section: "Directives Are Unique Per Location"
- // Spec Section: "All Variables Used"
- // Spec Section: "Variable Uniqueness"
- // Spec Section: "Fragment spread is possible"
- // Spec Section: "Fragment spread target defined"
- // Spec Section: "Field Selections on Objects, Interfaces, and Unions Types"
- // Spec Section: "Variables are Input Types"
- // Spec Section: "Fragment Spread Type Existence"
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- // Spec Section: "Operation Name Uniqueness"
- /***/ }),
- /* 35 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.ValidationContext = undefined;
- exports.validate = validate;
- exports.visitUsingRules = visitUsingRules;
- var _invariant = __webpack_require__(3);
- var _invariant2 = _interopRequireDefault(_invariant);
- var _error = __webpack_require__(0);
- var _visitor = __webpack_require__(15);
- var _kinds = __webpack_require__(2);
- var Kind = _interopRequireWildcard(_kinds);
- var _schema = __webpack_require__(8);
- var _TypeInfo = __webpack_require__(27);
- var _specifiedRules = __webpack_require__(34);
- 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; } }
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- /**
- * Implements the "Validation" section of the spec.
- *
- * Validation runs synchronously, returning an array of encountered errors, or
- * an empty array if no errors were encountered and the document is valid.
- *
- * A list of specific validation rules may be provided. If not provided, the
- * default list of rules defined by the GraphQL specification will be used.
- *
- * Each validation rules is a function which returns a visitor
- * (see the language/visitor API). Visitor methods are expected to return
- * GraphQLErrors, or Arrays of GraphQLErrors when invalid.
- */
- function validate(schema, ast, rules) {
- (0, _invariant2.default)(schema, 'Must provide schema');
- (0, _invariant2.default)(ast, 'Must provide document');
- (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.');
- var typeInfo = new _TypeInfo.TypeInfo(schema);
- return visitUsingRules(schema, typeInfo, ast, rules || _specifiedRules.specifiedRules);
- }
- /**
- * This uses a specialized visitor which runs multiple visitors in parallel,
- * while maintaining the visitor skip and break API.
- *
- * @internal
- */
- function visitUsingRules(schema, typeInfo, documentAST, rules) {
- var context = new ValidationContext(schema, documentAST, typeInfo);
- var visitors = rules.map(function (rule) {
- return rule(context);
- });
- // Visit the whole document with each instance of all provided rules.
- (0, _visitor.visit)(documentAST, (0, _visitor.visitWithTypeInfo)(typeInfo, (0, _visitor.visitInParallel)(visitors)));
- return context.getErrors();
- }
- /**
- * An instance of this class is passed as the "this" context to all validators,
- * allowing access to commonly useful contextual information from within a
- * validation rule.
- */
- var ValidationContext = exports.ValidationContext = function () {
- function ValidationContext(schema, ast, typeInfo) {
- _classCallCheck(this, ValidationContext);
- this._schema = schema;
- this._ast = ast;
- this._typeInfo = typeInfo;
- this._errors = [];
- this._fragmentSpreads = new Map();
- this._recursivelyReferencedFragments = new Map();
- this._variableUsages = new Map();
- this._recursiveVariableUsages = new Map();
- }
- ValidationContext.prototype.reportError = function reportError(error) {
- this._errors.push(error);
- };
- ValidationContext.prototype.getErrors = function getErrors() {
- return this._errors;
- };
- ValidationContext.prototype.getSchema = function getSchema() {
- return this._schema;
- };
- ValidationContext.prototype.getDocument = function getDocument() {
- return this._ast;
- };
- ValidationContext.prototype.getFragment = function getFragment(name) {
- var fragments = this._fragments;
- if (!fragments) {
- this._fragments = fragments = this.getDocument().definitions.reduce(function (frags, statement) {
- if (statement.kind === Kind.FRAGMENT_DEFINITION) {
- frags[statement.name.value] = statement;
- }
- return frags;
- }, {});
- }
- return fragments[name];
- };
- ValidationContext.prototype.getFragmentSpreads = function getFragmentSpreads(node) {
- var spreads = this._fragmentSpreads.get(node);
- if (!spreads) {
- spreads = [];
- var setsToVisit = [node];
- while (setsToVisit.length !== 0) {
- var set = setsToVisit.pop();
- for (var i = 0; i < set.selections.length; i++) {
- var selection = set.selections[i];
- if (selection.kind === Kind.FRAGMENT_SPREAD) {
- spreads.push(selection);
- } else if (selection.selectionSet) {
- setsToVisit.push(selection.selectionSet);
- }
- }
- }
- this._fragmentSpreads.set(node, spreads);
- }
- return spreads;
- };
- ValidationContext.prototype.getRecursivelyReferencedFragments = function getRecursivelyReferencedFragments(operation) {
- var fragments = this._recursivelyReferencedFragments.get(operation);
- if (!fragments) {
- fragments = [];
- var collectedNames = Object.create(null);
- var nodesToVisit = [operation.selectionSet];
- while (nodesToVisit.length !== 0) {
- var _node = nodesToVisit.pop();
- var spreads = this.getFragmentSpreads(_node);
- for (var i = 0; i < spreads.length; i++) {
- var fragName = spreads[i].name.value;
- if (collectedNames[fragName] !== true) {
- collectedNames[fragName] = true;
- var fragment = this.getFragment(fragName);
- if (fragment) {
- fragments.push(fragment);
- nodesToVisit.push(fragment.selectionSet);
- }
- }
- }
- }
- this._recursivelyReferencedFragments.set(operation, fragments);
- }
- return fragments;
- };
- ValidationContext.prototype.getVariableUsages = function getVariableUsages(node) {
- var _this = this;
- var usages = this._variableUsages.get(node);
- if (!usages) {
- (function () {
- var newUsages = [];
- var typeInfo = new _TypeInfo.TypeInfo(_this._schema);
- (0, _visitor.visit)(node, (0, _visitor.visitWithTypeInfo)(typeInfo, {
- VariableDefinition: function VariableDefinition() {
- return false;
- },
- Variable: function Variable(variable) {
- newUsages.push({ node: variable, type: typeInfo.getInputType() });
- }
- }));
- usages = newUsages;
- _this._variableUsages.set(node, usages);
- })();
- }
- return usages;
- };
- ValidationContext.prototype.getRecursiveVariableUsages = function getRecursiveVariableUsages(operation) {
- var usages = this._recursiveVariableUsages.get(operation);
- if (!usages) {
- usages = this.getVariableUsages(operation);
- var fragments = this.getRecursivelyReferencedFragments(operation);
- for (var i = 0; i < fragments.length; i++) {
- Array.prototype.push.apply(usages, this.getVariableUsages(fragments[i]));
- }
- this._recursiveVariableUsages.set(operation, usages);
- }
- return usages;
- };
- ValidationContext.prototype.getType = function getType() {
- return this._typeInfo.getType();
- };
- ValidationContext.prototype.getParentType = function getParentType() {
- return this._typeInfo.getParentType();
- };
- ValidationContext.prototype.getInputType = function getInputType() {
- return this._typeInfo.getInputType();
- };
- ValidationContext.prototype.getFieldDef = function getFieldDef() {
- return this._typeInfo.getFieldDef();
- };
- ValidationContext.prototype.getDirective = function getDirective() {
- return this._typeInfo.getDirective();
- };
- ValidationContext.prototype.getArgument = function getArgument() {
- return this._typeInfo.getArgument();
- };
- return ValidationContext;
- }();
- /***/ }),
- /* 36 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- var _graphql = __webpack_require__(42);
- Object.defineProperty(exports, 'graphql', {
- enumerable: true,
- get: function get() {
- return _graphql.graphql;
- }
- });
- var _type = __webpack_require__(44);
- Object.defineProperty(exports, 'GraphQLSchema', {
- enumerable: true,
- get: function get() {
- return _type.GraphQLSchema;
- }
- });
- Object.defineProperty(exports, 'GraphQLScalarType', {
- enumerable: true,
- get: function get() {
- return _type.GraphQLScalarType;
- }
- });
- Object.defineProperty(exports, 'GraphQLObjectType', {
- enumerable: true,
- get: function get() {
- return _type.GraphQLObjectType;
- }
- });
- Object.defineProperty(exports, 'GraphQLInterfaceType', {
- enumerable: true,
- get: function get() {
- return _type.GraphQLInterfaceType;
- }
- });
- Object.defineProperty(exports, 'GraphQLUnionType', {
- enumerable: true,
- get: function get() {
- return _type.GraphQLUnionType;
- }
- });
- Object.defineProperty(exports, 'GraphQLEnumType', {
- enumerable: true,
- get: function get() {
- return _type.GraphQLEnumType;
- }
- });
- Object.defineProperty(exports, 'GraphQLInputObjectType', {
- enumerable: true,
- get: function get() {
- return _type.GraphQLInputObjectType;
- }
- });
- Object.defineProperty(exports, 'GraphQLList', {
- enumerable: true,
- get: function get() {
- return _type.GraphQLList;
- }
- });
- Object.defineProperty(exports, 'GraphQLNonNull', {
- enumerable: true,
- get: function get() {
- return _type.GraphQLNonNull;
- }
- });
- Object.defineProperty(exports, 'GraphQLDirective', {
- enumerable: true,
- get: function get() {
- return _type.GraphQLDirective;
- }
- });
- Object.defineProperty(exports, 'TypeKind', {
- enumerable: true,
- get: function get() {
- return _type.TypeKind;
- }
- });
- Object.defineProperty(exports, 'DirectiveLocation', {
- enumerable: true,
- get: function get() {
- return _type.DirectiveLocation;
- }
- });
- Object.defineProperty(exports, 'GraphQLInt', {
- enumerable: true,
- get: function get() {
- return _type.GraphQLInt;
- }
- });
- Object.defineProperty(exports, 'GraphQLFloat', {
- enumerable: true,
- get: function get() {
- return _type.GraphQLFloat;
- }
- });
- Object.defineProperty(exports, 'GraphQLString', {
- enumerable: true,
- get: function get() {
- return _type.GraphQLString;
- }
- });
- Object.defineProperty(exports, 'GraphQLBoolean', {
- enumerable: true,
- get: function get() {
- return _type.GraphQLBoolean;
- }
- });
- Object.defineProperty(exports, 'GraphQLID', {
- enumerable: true,
- get: function get() {
- return _type.GraphQLID;
- }
- });
- Object.defineProperty(exports, 'specifiedDirectives', {
- enumerable: true,
- get: function get() {
- return _type.specifiedDirectives;
- }
- });
- Object.defineProperty(exports, 'GraphQLIncludeDirective', {
- enumerable: true,
- get: function get() {
- return _type.GraphQLIncludeDirective;
- }
- });
- Object.defineProperty(exports, 'GraphQLSkipDirective', {
- enumerable: true,
- get: function get() {
- return _type.GraphQLSkipDirective;
- }
- });
- Object.defineProperty(exports, 'GraphQLDeprecatedDirective', {
- enumerable: true,
- get: function get() {
- return _type.GraphQLDeprecatedDirective;
- }
- });
- Object.defineProperty(exports, 'DEFAULT_DEPRECATION_REASON', {
- enumerable: true,
- get: function get() {
- return _type.DEFAULT_DEPRECATION_REASON;
- }
- });
- Object.defineProperty(exports, 'SchemaMetaFieldDef', {
- enumerable: true,
- get: function get() {
- return _type.SchemaMetaFieldDef;
- }
- });
- Object.defineProperty(exports, 'TypeMetaFieldDef', {
- enumerable: true,
- get: function get() {
- return _type.TypeMetaFieldDef;
- }
- });
- Object.defineProperty(exports, 'TypeNameMetaFieldDef', {
- enumerable: true,
- get: function get() {
- return _type.TypeNameMetaFieldDef;
- }
- });
- Object.defineProperty(exports, '__Schema', {
- enumerable: true,
- get: function get() {
- return _type.__Schema;
- }
- });
- Object.defineProperty(exports, '__Directive', {
- enumerable: true,
- get: function get() {
- return _type.__Directive;
- }
- });
- Object.defineProperty(exports, '__DirectiveLocation', {
- enumerable: true,
- get: function get() {
- return _type.__DirectiveLocation;
- }
- });
- Object.defineProperty(exports, '__Type', {
- enumerable: true,
- get: function get() {
- return _type.__Type;
- }
- });
- Object.defineProperty(exports, '__Field', {
- enumerable: true,
- get: function get() {
- return _type.__Field;
- }
- });
- Object.defineProperty(exports, '__InputValue', {
- enumerable: true,
- get: function get() {
- return _type.__InputValue;
- }
- });
- Object.defineProperty(exports, '__EnumValue', {
- enumerable: true,
- get: function get() {
- return _type.__EnumValue;
- }
- });
- Object.defineProperty(exports, '__TypeKind', {
- enumerable: true,
- get: function get() {
- return _type.__TypeKind;
- }
- });
- Object.defineProperty(exports, 'isType', {
- enumerable: true,
- get: function get() {
- return _type.isType;
- }
- });
- Object.defineProperty(exports, 'isInputType', {
- enumerable: true,
- get: function get() {
- return _type.isInputType;
- }
- });
- Object.defineProperty(exports, 'isOutputType', {
- enumerable: true,
- get: function get() {
- return _type.isOutputType;
- }
- });
- Object.defineProperty(exports, 'isLeafType', {
- enumerable: true,
- get: function get() {
- return _type.isLeafType;
- }
- });
- Object.defineProperty(exports, 'isCompositeType', {
- enumerable: true,
- get: function get() {
- return _type.isCompositeType;
- }
- });
- Object.defineProperty(exports, 'isAbstractType', {
- enumerable: true,
- get: function get() {
- return _type.isAbstractType;
- }
- });
- Object.defineProperty(exports, 'isNamedType', {
- enumerable: true,
- get: function get() {
- return _type.isNamedType;
- }
- });
- Object.defineProperty(exports, 'assertType', {
- enumerable: true,
- get: function get() {
- return _type.assertType;
- }
- });
- Object.defineProperty(exports, 'assertInputType', {
- enumerable: true,
- get: function get() {
- return _type.assertInputType;
- }
- });
- Object.defineProperty(exports, 'assertOutputType', {
- enumerable: true,
- get: function get() {
- return _type.assertOutputType;
- }
- });
- Object.defineProperty(exports, 'assertLeafType', {
- enumerable: true,
- get: function get() {
- return _type.assertLeafType;
- }
- });
- Object.defineProperty(exports, 'assertCompositeType', {
- enumerable: true,
- get: function get() {
- return _type.assertCompositeType;
- }
- });
- Object.defineProperty(exports, 'assertAbstractType', {
- enumerable: true,
- get: function get() {
- return _type.assertAbstractType;
- }
- });
- Object.defineProperty(exports, 'assertNamedType', {
- enumerable: true,
- get: function get() {
- return _type.assertNamedType;
- }
- });
- Object.defineProperty(exports, 'getNullableType', {
- enumerable: true,
- get: function get() {
- return _type.getNullableType;
- }
- });
- Object.defineProperty(exports, 'getNamedType', {
- enumerable: true,
- get: function get() {
- return _type.getNamedType;
- }
- });
- var _language = __webpack_require__(43);
- Object.defineProperty(exports, 'Source', {
- enumerable: true,
- get: function get() {
- return _language.Source;
- }
- });
- Object.defineProperty(exports, 'getLocation', {
- enumerable: true,
- get: function get() {
- return _language.getLocation;
- }
- });
- Object.defineProperty(exports, 'parse', {
- enumerable: true,
- get: function get() {
- return _language.parse;
- }
- });
- Object.defineProperty(exports, 'parseValue', {
- enumerable: true,
- get: function get() {
- return _language.parseValue;
- }
- });
- Object.defineProperty(exports, 'parseType', {
- enumerable: true,
- get: function get() {
- return _language.parseType;
- }
- });
- Object.defineProperty(exports, 'print', {
- enumerable: true,
- get: function get() {
- return _language.print;
- }
- });
- Object.defineProperty(exports, 'visit', {
- enumerable: true,
- get: function get() {
- return _language.visit;
- }
- });
- Object.defineProperty(exports, 'visitInParallel', {
- enumerable: true,
- get: function get() {
- return _language.visitInParallel;
- }
- });
- Object.defineProperty(exports, 'visitWithTypeInfo', {
- enumerable: true,
- get: function get() {
- return _language.visitWithTypeInfo;
- }
- });
- Object.defineProperty(exports, 'Kind', {
- enumerable: true,
- get: function get() {
- return _language.Kind;
- }
- });
- Object.defineProperty(exports, 'TokenKind', {
- enumerable: true,
- get: function get() {
- return _language.TokenKind;
- }
- });
- Object.defineProperty(exports, 'BREAK', {
- enumerable: true,
- get: function get() {
- return _language.BREAK;
- }
- });
- var _execution = __webpack_require__(41);
- Object.defineProperty(exports, 'execute', {
- enumerable: true,
- get: function get() {
- return _execution.execute;
- }
- });
- Object.defineProperty(exports, 'defaultFieldResolver', {
- enumerable: true,
- get: function get() {
- return _execution.defaultFieldResolver;
- }
- });
- Object.defineProperty(exports, 'responsePathAsArray', {
- enumerable: true,
- get: function get() {
- return _execution.responsePathAsArray;
- }
- });
- var _validation = __webpack_require__(55);
- Object.defineProperty(exports, 'validate', {
- enumerable: true,
- get: function get() {
- return _validation.validate;
- }
- });
- Object.defineProperty(exports, 'ValidationContext', {
- enumerable: true,
- get: function get() {
- return _validation.ValidationContext;
- }
- });
- Object.defineProperty(exports, 'specifiedRules', {
- enumerable: true,
- get: function get() {
- return _validation.specifiedRules;
- }
- });
- var _error = __webpack_require__(0);
- Object.defineProperty(exports, 'GraphQLError', {
- enumerable: true,
- get: function get() {
- return _error.GraphQLError;
- }
- });
- Object.defineProperty(exports, 'formatError', {
- enumerable: true,
- get: function get() {
- return _error.formatError;
- }
- });
- var _utilities = __webpack_require__(51);
- Object.defineProperty(exports, 'introspectionQuery', {
- enumerable: true,
- get: function get() {
- return _utilities.introspectionQuery;
- }
- });
- Object.defineProperty(exports, 'getOperationAST', {
- enumerable: true,
- get: function get() {
- return _utilities.getOperationAST;
- }
- });
- Object.defineProperty(exports, 'buildClientSchema', {
- enumerable: true,
- get: function get() {
- return _utilities.buildClientSchema;
- }
- });
- Object.defineProperty(exports, 'buildASTSchema', {
- enumerable: true,
- get: function get() {
- return _utilities.buildASTSchema;
- }
- });
- Object.defineProperty(exports, 'buildSchema', {
- enumerable: true,
- get: function get() {
- return _utilities.buildSchema;
- }
- });
- Object.defineProperty(exports, 'extendSchema', {
- enumerable: true,
- get: function get() {
- return _utilities.extendSchema;
- }
- });
- Object.defineProperty(exports, 'printSchema', {
- enumerable: true,
- get: function get() {
- return _utilities.printSchema;
- }
- });
- Object.defineProperty(exports, 'printType', {
- enumerable: true,
- get: function get() {
- return _utilities.printType;
- }
- });
- Object.defineProperty(exports, 'typeFromAST', {
- enumerable: true,
- get: function get() {
- return _utilities.typeFromAST;
- }
- });
- Object.defineProperty(exports, 'valueFromAST', {
- enumerable: true,
- get: function get() {
- return _utilities.valueFromAST;
- }
- });
- Object.defineProperty(exports, 'astFromValue', {
- enumerable: true,
- get: function get() {
- return _utilities.astFromValue;
- }
- });
- Object.defineProperty(exports, 'TypeInfo', {
- enumerable: true,
- get: function get() {
- return _utilities.TypeInfo;
- }
- });
- Object.defineProperty(exports, 'isValidJSValue', {
- enumerable: true,
- get: function get() {
- return _utilities.isValidJSValue;
- }
- });
- Object.defineProperty(exports, 'isValidLiteralValue', {
- enumerable: true,
- get: function get() {
- return _utilities.isValidLiteralValue;
- }
- });
- Object.defineProperty(exports, 'concatAST', {
- enumerable: true,
- get: function get() {
- return _utilities.concatAST;
- }
- });
- Object.defineProperty(exports, 'separateOperations', {
- enumerable: true,
- get: function get() {
- return _utilities.separateOperations;
- }
- });
- Object.defineProperty(exports, 'isEqualType', {
- enumerable: true,
- get: function get() {
- return _utilities.isEqualType;
- }
- });
- Object.defineProperty(exports, 'isTypeSubTypeOf', {
- enumerable: true,
- get: function get() {
- return _utilities.isTypeSubTypeOf;
- }
- });
- Object.defineProperty(exports, 'doTypesOverlap', {
- enumerable: true,
- get: function get() {
- return _utilities.doTypesOverlap;
- }
- });
- Object.defineProperty(exports, 'assertValidName', {
- enumerable: true,
- get: function get() {
- return _utilities.assertValidName;
- }
- });
- Object.defineProperty(exports, 'findBreakingChanges', {
- enumerable: true,
- get: function get() {
- return _utilities.findBreakingChanges;
- }
- });
- Object.defineProperty(exports, 'findDeprecatedUsages', {
- enumerable: true,
- get: function get() {
- return _utilities.findDeprecatedUsages;
- }
- });
- /***/ }),
- /* 37 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", { value: true });
- var graphql_1 = __webpack_require__(36);
- var hasSubscriptionOperation = function (graphQlParams) {
- var queryDoc = graphql_1.parse(graphQlParams.query);
- for (var _i = 0, _a = queryDoc.definitions; _i < _a.length; _i++) {
- var definition = _a[_i];
- if (definition.kind === 'OperationDefinition') {
- var operation = definition.operation;
- if (operation === 'subscription') {
- return true;
- }
- }
- }
- return false;
- };
- exports.graphQLFetcher = function (subscriptionsClient, fallbackFetcher) {
- var activeSubscriptionId = null;
- return function (graphQLParams) {
- if (subscriptionsClient && activeSubscriptionId !== null) {
- subscriptionsClient.unsubscribe(activeSubscriptionId);
- }
- if (subscriptionsClient && hasSubscriptionOperation(graphQLParams)) {
- return {
- subscribe: function (observer) {
- observer.next('Your subscription data will appear here after server publication!');
- activeSubscriptionId = subscriptionsClient.subscribe({
- query: graphQLParams.query,
- variables: graphQLParams.variables,
- }, function (error, result) {
- if (error) {
- observer.error(error);
- }
- else {
- observer.next(result);
- }
- });
- },
- };
- }
- else {
- return fallbackFetcher(graphQLParams);
- }
- };
- };
- //# sourceMappingURL=fetcher.js.map
- /***/ }),
- /* 38 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.formatError = formatError;
- var _invariant = __webpack_require__(3);
- var _invariant2 = _interopRequireDefault(_invariant);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- /**
- * Given a GraphQLError, format it according to the rules described by the
- * Response Format, Errors section of the GraphQL Specification.
- */
- function formatError(error) {
- (0, _invariant2.default)(error, 'Received null or undefined error.');
- return {
- message: error.message,
- locations: error.locations,
- path: error.path
- };
- }
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- /***/ }),
- /* 39 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.locatedError = locatedError;
- var _GraphQLError = __webpack_require__(13);
- /**
- * Given an arbitrary Error, presumably thrown while attempting to execute a
- * GraphQL operation, produce a new GraphQLError aware of the location in the
- * document responsible for the original Error.
- */
- function locatedError(originalError, nodes, path) {
- // Note: this uses a brand-check to support GraphQL errors originating from
- // other contexts.
- if (originalError && originalError.path) {
- return originalError;
- }
- var message = originalError ? originalError.message || String(originalError) : 'An unknown error occurred.';
- return new _GraphQLError.GraphQLError(message, originalError && originalError.nodes || nodes, originalError && originalError.source, originalError && originalError.positions, path, originalError);
- }
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- /***/ }),
- /* 40 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.syntaxError = syntaxError;
- var _location = __webpack_require__(25);
- var _GraphQLError = __webpack_require__(13);
- /**
- * Produces a GraphQLError representing a syntax error, containing useful
- * descriptive information about the syntax error's position in the source.
- */
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function syntaxError(source, position, description) {
- var location = (0, _location.getLocation)(source, position);
- var error = new _GraphQLError.GraphQLError('Syntax Error ' + source.name + ' (' + location.line + ':' + location.column + ') ' + description + '\n\n' + highlightSourceAtLocation(source, location), undefined, source, [position]);
- return error;
- }
- /**
- * Render a helpful description of the location of the error in the GraphQL
- * Source document.
- */
- function highlightSourceAtLocation(source, location) {
- var line = location.line;
- var prevLineNum = (line - 1).toString();
- var lineNum = line.toString();
- var nextLineNum = (line + 1).toString();
- var padLen = nextLineNum.length;
- var lines = source.body.split(/\r\n|[\n\r]/g);
- 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' : '');
- }
- function lpad(len, str) {
- return Array(len - str.length + 1).join(' ') + str;
- }
- /***/ }),
- /* 41 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- var _execute = __webpack_require__(30);
- Object.defineProperty(exports, 'execute', {
- enumerable: true,
- get: function get() {
- return _execute.execute;
- }
- });
- Object.defineProperty(exports, 'defaultFieldResolver', {
- enumerable: true,
- get: function get() {
- return _execute.defaultFieldResolver;
- }
- });
- Object.defineProperty(exports, 'responsePathAsArray', {
- enumerable: true,
- get: function get() {
- return _execute.responsePathAsArray;
- }
- });
- /***/ }),
- /* 42 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.graphql = graphql;
- var _source = __webpack_require__(26);
- var _parser = __webpack_require__(17);
- var _validate = __webpack_require__(35);
- var _execute = __webpack_require__(30);
- /**
- * This is the primary entry point function for fulfilling GraphQL operations
- * by parsing, validating, and executing a GraphQL document along side a
- * GraphQL schema.
- *
- * More sophisticated GraphQL servers, such as those which persist queries,
- * may wish to separate the validation and execution phases to a static time
- * tooling step, and a server runtime step.
- *
- * schema:
- * The GraphQL type system to use when validating and executing a query.
- * requestString:
- * A GraphQL language formatted string representing the requested operation.
- * rootValue:
- * The value provided as the first argument to resolver functions on the top
- * level type (e.g. the query object type).
- * variableValues:
- * A mapping of variable name to runtime value to use for all variables
- * defined in the requestString.
- * operationName:
- * The name of the operation to use if requestString contains multiple
- * possible operations. Can be omitted if requestString contains only
- * one operation.
- */
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function graphql(schema, requestString, rootValue, contextValue, variableValues, operationName) {
- return new Promise(function (resolve) {
- var source = new _source.Source(requestString || '', 'GraphQL request');
- var documentAST = (0, _parser.parse)(source);
- var validationErrors = (0, _validate.validate)(schema, documentAST);
- if (validationErrors.length > 0) {
- resolve({ errors: validationErrors });
- } else {
- resolve((0, _execute.execute)(schema, documentAST, rootValue, contextValue, variableValues, operationName));
- }
- }).then(undefined, function (error) {
- return { errors: [error] };
- });
- }
- /***/ }),
- /* 43 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- 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;
- var _location = __webpack_require__(25);
- Object.defineProperty(exports, 'getLocation', {
- enumerable: true,
- get: function get() {
- return _location.getLocation;
- }
- });
- var _lexer = __webpack_require__(24);
- Object.defineProperty(exports, 'createLexer', {
- enumerable: true,
- get: function get() {
- return _lexer.createLexer;
- }
- });
- Object.defineProperty(exports, 'TokenKind', {
- enumerable: true,
- get: function get() {
- return _lexer.TokenKind;
- }
- });
- var _parser = __webpack_require__(17);
- Object.defineProperty(exports, 'parse', {
- enumerable: true,
- get: function get() {
- return _parser.parse;
- }
- });
- Object.defineProperty(exports, 'parseValue', {
- enumerable: true,
- get: function get() {
- return _parser.parseValue;
- }
- });
- Object.defineProperty(exports, 'parseType', {
- enumerable: true,
- get: function get() {
- return _parser.parseType;
- }
- });
- var _printer = __webpack_require__(4);
- Object.defineProperty(exports, 'print', {
- enumerable: true,
- get: function get() {
- return _printer.print;
- }
- });
- var _source = __webpack_require__(26);
- Object.defineProperty(exports, 'Source', {
- enumerable: true,
- get: function get() {
- return _source.Source;
- }
- });
- var _visitor = __webpack_require__(15);
- Object.defineProperty(exports, 'visit', {
- enumerable: true,
- get: function get() {
- return _visitor.visit;
- }
- });
- Object.defineProperty(exports, 'visitInParallel', {
- enumerable: true,
- get: function get() {
- return _visitor.visitInParallel;
- }
- });
- Object.defineProperty(exports, 'visitWithTypeInfo', {
- enumerable: true,
- get: function get() {
- return _visitor.visitWithTypeInfo;
- }
- });
- Object.defineProperty(exports, 'BREAK', {
- enumerable: true,
- get: function get() {
- return _visitor.BREAK;
- }
- });
- var _kinds = __webpack_require__(2);
- var Kind = _interopRequireWildcard(_kinds);
- 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; } }
- exports.Kind = Kind;
- /***/ }),
- /* 44 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- var _schema = __webpack_require__(8);
- Object.defineProperty(exports, 'GraphQLSchema', {
- enumerable: true,
- get: function get() {
- return _schema.GraphQLSchema;
- }
- });
- var _definition = __webpack_require__(1);
- Object.defineProperty(exports, 'isType', {
- enumerable: true,
- get: function get() {
- return _definition.isType;
- }
- });
- Object.defineProperty(exports, 'isInputType', {
- enumerable: true,
- get: function get() {
- return _definition.isInputType;
- }
- });
- Object.defineProperty(exports, 'isOutputType', {
- enumerable: true,
- get: function get() {
- return _definition.isOutputType;
- }
- });
- Object.defineProperty(exports, 'isLeafType', {
- enumerable: true,
- get: function get() {
- return _definition.isLeafType;
- }
- });
- Object.defineProperty(exports, 'isCompositeType', {
- enumerable: true,
- get: function get() {
- return _definition.isCompositeType;
- }
- });
- Object.defineProperty(exports, 'isAbstractType', {
- enumerable: true,
- get: function get() {
- return _definition.isAbstractType;
- }
- });
- Object.defineProperty(exports, 'isNamedType', {
- enumerable: true,
- get: function get() {
- return _definition.isNamedType;
- }
- });
- Object.defineProperty(exports, 'assertType', {
- enumerable: true,
- get: function get() {
- return _definition.assertType;
- }
- });
- Object.defineProperty(exports, 'assertInputType', {
- enumerable: true,
- get: function get() {
- return _definition.assertInputType;
- }
- });
- Object.defineProperty(exports, 'assertOutputType', {
- enumerable: true,
- get: function get() {
- return _definition.assertOutputType;
- }
- });
- Object.defineProperty(exports, 'assertLeafType', {
- enumerable: true,
- get: function get() {
- return _definition.assertLeafType;
- }
- });
- Object.defineProperty(exports, 'assertCompositeType', {
- enumerable: true,
- get: function get() {
- return _definition.assertCompositeType;
- }
- });
- Object.defineProperty(exports, 'assertAbstractType', {
- enumerable: true,
- get: function get() {
- return _definition.assertAbstractType;
- }
- });
- Object.defineProperty(exports, 'assertNamedType', {
- enumerable: true,
- get: function get() {
- return _definition.assertNamedType;
- }
- });
- Object.defineProperty(exports, 'getNullableType', {
- enumerable: true,
- get: function get() {
- return _definition.getNullableType;
- }
- });
- Object.defineProperty(exports, 'getNamedType', {
- enumerable: true,
- get: function get() {
- return _definition.getNamedType;
- }
- });
- Object.defineProperty(exports, 'GraphQLScalarType', {
- enumerable: true,
- get: function get() {
- return _definition.GraphQLScalarType;
- }
- });
- Object.defineProperty(exports, 'GraphQLObjectType', {
- enumerable: true,
- get: function get() {
- return _definition.GraphQLObjectType;
- }
- });
- Object.defineProperty(exports, 'GraphQLInterfaceType', {
- enumerable: true,
- get: function get() {
- return _definition.GraphQLInterfaceType;
- }
- });
- Object.defineProperty(exports, 'GraphQLUnionType', {
- enumerable: true,
- get: function get() {
- return _definition.GraphQLUnionType;
- }
- });
- Object.defineProperty(exports, 'GraphQLEnumType', {
- enumerable: true,
- get: function get() {
- return _definition.GraphQLEnumType;
- }
- });
- Object.defineProperty(exports, 'GraphQLInputObjectType', {
- enumerable: true,
- get: function get() {
- return _definition.GraphQLInputObjectType;
- }
- });
- Object.defineProperty(exports, 'GraphQLList', {
- enumerable: true,
- get: function get() {
- return _definition.GraphQLList;
- }
- });
- Object.defineProperty(exports, 'GraphQLNonNull', {
- enumerable: true,
- get: function get() {
- return _definition.GraphQLNonNull;
- }
- });
- var _directives = __webpack_require__(5);
- Object.defineProperty(exports, 'DirectiveLocation', {
- enumerable: true,
- get: function get() {
- return _directives.DirectiveLocation;
- }
- });
- Object.defineProperty(exports, 'GraphQLDirective', {
- enumerable: true,
- get: function get() {
- return _directives.GraphQLDirective;
- }
- });
- Object.defineProperty(exports, 'specifiedDirectives', {
- enumerable: true,
- get: function get() {
- return _directives.specifiedDirectives;
- }
- });
- Object.defineProperty(exports, 'GraphQLIncludeDirective', {
- enumerable: true,
- get: function get() {
- return _directives.GraphQLIncludeDirective;
- }
- });
- Object.defineProperty(exports, 'GraphQLSkipDirective', {
- enumerable: true,
- get: function get() {
- return _directives.GraphQLSkipDirective;
- }
- });
- Object.defineProperty(exports, 'GraphQLDeprecatedDirective', {
- enumerable: true,
- get: function get() {
- return _directives.GraphQLDeprecatedDirective;
- }
- });
- Object.defineProperty(exports, 'DEFAULT_DEPRECATION_REASON', {
- enumerable: true,
- get: function get() {
- return _directives.DEFAULT_DEPRECATION_REASON;
- }
- });
- var _scalars = __webpack_require__(7);
- Object.defineProperty(exports, 'GraphQLInt', {
- enumerable: true,
- get: function get() {
- return _scalars.GraphQLInt;
- }
- });
- Object.defineProperty(exports, 'GraphQLFloat', {
- enumerable: true,
- get: function get() {
- return _scalars.GraphQLFloat;
- }
- });
- Object.defineProperty(exports, 'GraphQLString', {
- enumerable: true,
- get: function get() {
- return _scalars.GraphQLString;
- }
- });
- Object.defineProperty(exports, 'GraphQLBoolean', {
- enumerable: true,
- get: function get() {
- return _scalars.GraphQLBoolean;
- }
- });
- Object.defineProperty(exports, 'GraphQLID', {
- enumerable: true,
- get: function get() {
- return _scalars.GraphQLID;
- }
- });
- var _introspection = __webpack_require__(11);
- Object.defineProperty(exports, 'TypeKind', {
- enumerable: true,
- get: function get() {
- return _introspection.TypeKind;
- }
- });
- Object.defineProperty(exports, '__Schema', {
- enumerable: true,
- get: function get() {
- return _introspection.__Schema;
- }
- });
- Object.defineProperty(exports, '__Directive', {
- enumerable: true,
- get: function get() {
- return _introspection.__Directive;
- }
- });
- Object.defineProperty(exports, '__DirectiveLocation', {
- enumerable: true,
- get: function get() {
- return _introspection.__DirectiveLocation;
- }
- });
- Object.defineProperty(exports, '__Type', {
- enumerable: true,
- get: function get() {
- return _introspection.__Type;
- }
- });
- Object.defineProperty(exports, '__Field', {
- enumerable: true,
- get: function get() {
- return _introspection.__Field;
- }
- });
- Object.defineProperty(exports, '__InputValue', {
- enumerable: true,
- get: function get() {
- return _introspection.__InputValue;
- }
- });
- Object.defineProperty(exports, '__EnumValue', {
- enumerable: true,
- get: function get() {
- return _introspection.__EnumValue;
- }
- });
- Object.defineProperty(exports, '__TypeKind', {
- enumerable: true,
- get: function get() {
- return _introspection.__TypeKind;
- }
- });
- Object.defineProperty(exports, 'SchemaMetaFieldDef', {
- enumerable: true,
- get: function get() {
- return _introspection.SchemaMetaFieldDef;
- }
- });
- Object.defineProperty(exports, 'TypeMetaFieldDef', {
- enumerable: true,
- get: function get() {
- return _introspection.TypeMetaFieldDef;
- }
- });
- Object.defineProperty(exports, 'TypeNameMetaFieldDef', {
- enumerable: true,
- get: function get() {
- return _introspection.TypeNameMetaFieldDef;
- }
- });
- /***/ }),
- /* 45 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.buildClientSchema = buildClientSchema;
- var _invariant = __webpack_require__(3);
- var _invariant2 = _interopRequireDefault(_invariant);
- var _keyMap = __webpack_require__(12);
- var _keyMap2 = _interopRequireDefault(_keyMap);
- var _keyValMap = __webpack_require__(21);
- var _keyValMap2 = _interopRequireDefault(_keyValMap);
- var _valueFromAST = __webpack_require__(16);
- var _parser = __webpack_require__(17);
- var _schema = __webpack_require__(8);
- var _definition = __webpack_require__(1);
- var _introspection = __webpack_require__(11);
- var _scalars = __webpack_require__(7);
- var _directives = __webpack_require__(5);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- /**
- * Build a GraphQLSchema for use by client tools.
- *
- * Given the result of a client running the introspection query, creates and
- * returns a GraphQLSchema instance which can be then used with all graphql-js
- * tools, but cannot be used to execute a query, as introspection does not
- * represent the "resolver", "parse" or "serialize" functions or any other
- * server-internal mechanisms.
- */
- function buildClientSchema(introspection) {
- // Get the schema from the introspection result.
- var schemaIntrospection = introspection.__schema;
- // Converts the list of types into a keyMap based on the type names.
- var typeIntrospectionMap = (0, _keyMap2.default)(schemaIntrospection.types, function (type) {
- return type.name;
- });
- // A cache to use to store the actual GraphQLType definition objects by name.
- // Initialize to the GraphQL built in scalars. All functions below are inline
- // so that this type def cache is within the scope of the closure.
- var typeDefCache = {
- String: _scalars.GraphQLString,
- Int: _scalars.GraphQLInt,
- Float: _scalars.GraphQLFloat,
- Boolean: _scalars.GraphQLBoolean,
- ID: _scalars.GraphQLID,
- __Schema: _introspection.__Schema,
- __Directive: _introspection.__Directive,
- __DirectiveLocation: _introspection.__DirectiveLocation,
- __Type: _introspection.__Type,
- __Field: _introspection.__Field,
- __InputValue: _introspection.__InputValue,
- __EnumValue: _introspection.__EnumValue,
- __TypeKind: _introspection.__TypeKind
- };
- // Given a type reference in introspection, return the GraphQLType instance.
- // preferring cached instances before building new instances.
- function getType(typeRef) {
- if (typeRef.kind === _introspection.TypeKind.LIST) {
- var itemRef = typeRef.ofType;
- if (!itemRef) {
- throw new Error('Decorated type deeper than introspection query.');
- }
- return new _definition.GraphQLList(getType(itemRef));
- }
- if (typeRef.kind === _introspection.TypeKind.NON_NULL) {
- var nullableRef = typeRef.ofType;
- if (!nullableRef) {
- throw new Error('Decorated type deeper than introspection query.');
- }
- var nullableType = getType(nullableRef);
- (0, _invariant2.default)(!(nullableType instanceof _definition.GraphQLNonNull), 'No nesting nonnull.');
- return new _definition.GraphQLNonNull(nullableType);
- }
- return getNamedType(typeRef.name);
- }
- function getNamedType(typeName) {
- if (typeDefCache[typeName]) {
- return typeDefCache[typeName];
- }
- var typeIntrospection = typeIntrospectionMap[typeName];
- if (!typeIntrospection) {
- 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.');
- }
- var typeDef = buildType(typeIntrospection);
- typeDefCache[typeName] = typeDef;
- return typeDef;
- }
- function getInputType(typeRef) {
- var type = getType(typeRef);
- (0, _invariant2.default)((0, _definition.isInputType)(type), 'Introspection must provide input type for arguments.');
- return type;
- }
- function getOutputType(typeRef) {
- var type = getType(typeRef);
- (0, _invariant2.default)((0, _definition.isOutputType)(type), 'Introspection must provide output type for fields.');
- return type;
- }
- function getObjectType(typeRef) {
- var type = getType(typeRef);
- (0, _invariant2.default)(type instanceof _definition.GraphQLObjectType, 'Introspection must provide object type for possibleTypes.');
- return type;
- }
- function getInterfaceType(typeRef) {
- var type = getType(typeRef);
- (0, _invariant2.default)(type instanceof _definition.GraphQLInterfaceType, 'Introspection must provide interface type for interfaces.');
- return type;
- }
- // Given a type's introspection result, construct the correct
- // GraphQLType instance.
- function buildType(type) {
- switch (type.kind) {
- case _introspection.TypeKind.SCALAR:
- return buildScalarDef(type);
- case _introspection.TypeKind.OBJECT:
- return buildObjectDef(type);
- case _introspection.TypeKind.INTERFACE:
- return buildInterfaceDef(type);
- case _introspection.TypeKind.UNION:
- return buildUnionDef(type);
- case _introspection.TypeKind.ENUM:
- return buildEnumDef(type);
- case _introspection.TypeKind.INPUT_OBJECT:
- return buildInputObjectDef(type);
- default:
- 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.');
- }
- }
- function buildScalarDef(scalarIntrospection) {
- return new _definition.GraphQLScalarType({
- name: scalarIntrospection.name,
- description: scalarIntrospection.description,
- serialize: function serialize(id) {
- return id;
- },
- // Note: validation calls the parse functions to determine if a
- // literal value is correct. Returning null would cause use of custom
- // scalars to always fail validation. Returning false causes them to
- // always pass validation.
- parseValue: function parseValue() {
- return false;
- },
- parseLiteral: function parseLiteral() {
- return false;
- }
- });
- }
- function buildObjectDef(objectIntrospection) {
- return new _definition.GraphQLObjectType({
- name: objectIntrospection.name,
- description: objectIntrospection.description,
- interfaces: objectIntrospection.interfaces.map(getInterfaceType),
- fields: function fields() {
- return buildFieldDefMap(objectIntrospection);
- }
- });
- }
- function buildInterfaceDef(interfaceIntrospection) {
- return new _definition.GraphQLInterfaceType({
- name: interfaceIntrospection.name,
- description: interfaceIntrospection.description,
- fields: function fields() {
- return buildFieldDefMap(interfaceIntrospection);
- },
- resolveType: cannotExecuteClientSchema
- });
- }
- function buildUnionDef(unionIntrospection) {
- return new _definition.GraphQLUnionType({
- name: unionIntrospection.name,
- description: unionIntrospection.description,
- types: unionIntrospection.possibleTypes.map(getObjectType),
- resolveType: cannotExecuteClientSchema
- });
- }
- function buildEnumDef(enumIntrospection) {
- return new _definition.GraphQLEnumType({
- name: enumIntrospection.name,
- description: enumIntrospection.description,
- values: (0, _keyValMap2.default)(enumIntrospection.enumValues, function (valueIntrospection) {
- return valueIntrospection.name;
- }, function (valueIntrospection) {
- return {
- description: valueIntrospection.description,
- deprecationReason: valueIntrospection.deprecationReason
- };
- })
- });
- }
- function buildInputObjectDef(inputObjectIntrospection) {
- return new _definition.GraphQLInputObjectType({
- name: inputObjectIntrospection.name,
- description: inputObjectIntrospection.description,
- fields: function fields() {
- return buildInputValueDefMap(inputObjectIntrospection.inputFields);
- }
- });
- }
- function buildFieldDefMap(typeIntrospection) {
- return (0, _keyValMap2.default)(typeIntrospection.fields, function (fieldIntrospection) {
- return fieldIntrospection.name;
- }, function (fieldIntrospection) {
- return {
- description: fieldIntrospection.description,
- deprecationReason: fieldIntrospection.deprecationReason,
- type: getOutputType(fieldIntrospection.type),
- args: buildInputValueDefMap(fieldIntrospection.args)
- };
- });
- }
- function buildInputValueDefMap(inputValueIntrospections) {
- return (0, _keyValMap2.default)(inputValueIntrospections, function (inputValue) {
- return inputValue.name;
- }, buildInputValue);
- }
- function buildInputValue(inputValueIntrospection) {
- var type = getInputType(inputValueIntrospection.type);
- var defaultValue = inputValueIntrospection.defaultValue ? (0, _valueFromAST.valueFromAST)((0, _parser.parseValue)(inputValueIntrospection.defaultValue), type) : undefined;
- return {
- name: inputValueIntrospection.name,
- description: inputValueIntrospection.description,
- type: type,
- defaultValue: defaultValue
- };
- }
- function buildDirective(directiveIntrospection) {
- // Support deprecated `on****` fields for building `locations`, as this
- // is used by GraphiQL which may need to support outdated servers.
- 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]);
- return new _directives.GraphQLDirective({
- name: directiveIntrospection.name,
- description: directiveIntrospection.description,
- locations: locations,
- args: buildInputValueDefMap(directiveIntrospection.args)
- });
- }
- // Iterate through all types, getting the type definition for each, ensuring
- // that any type not directly referenced by a field will get created.
- var types = schemaIntrospection.types.map(function (typeIntrospection) {
- return getNamedType(typeIntrospection.name);
- });
- // Get the root Query, Mutation, and Subscription types.
- var queryType = getObjectType(schemaIntrospection.queryType);
- var mutationType = schemaIntrospection.mutationType ? getObjectType(schemaIntrospection.mutationType) : null;
- var subscriptionType = schemaIntrospection.subscriptionType ? getObjectType(schemaIntrospection.subscriptionType) : null;
- // Get the directives supported by Introspection, assuming empty-set if
- // directives were not queried for.
- var directives = schemaIntrospection.directives ? schemaIntrospection.directives.map(buildDirective) : [];
- // Then produce and return a Schema with these types.
- return new _schema.GraphQLSchema({
- query: queryType,
- mutation: mutationType,
- subscription: subscriptionType,
- types: types,
- directives: directives
- });
- }
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function cannotExecuteClientSchema() {
- throw new Error('Client Schema cannot use Interface or Union types for execution.');
- }
- /***/ }),
- /* 46 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.concatAST = concatAST;
- /**
- * Provided a collection of ASTs, presumably each from different files,
- * concatenate the ASTs together into batched AST, useful for validating many
- * GraphQL source files which together represent one conceptual application.
- */
- function concatAST(asts) {
- var batchDefinitions = [];
- for (var i = 0; i < asts.length; i++) {
- var definitions = asts[i].definitions;
- for (var j = 0; j < definitions.length; j++) {
- batchDefinitions.push(definitions[j]);
- }
- }
- return {
- kind: 'Document',
- definitions: batchDefinitions
- };
- }
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- /***/ }),
- /* 47 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.extendSchema = extendSchema;
- var _invariant = __webpack_require__(3);
- var _invariant2 = _interopRequireDefault(_invariant);
- var _keyMap = __webpack_require__(12);
- var _keyMap2 = _interopRequireDefault(_keyMap);
- var _keyValMap = __webpack_require__(21);
- var _keyValMap2 = _interopRequireDefault(_keyValMap);
- var _buildASTSchema = __webpack_require__(32);
- var _valueFromAST = __webpack_require__(16);
- var _GraphQLError = __webpack_require__(13);
- var _schema = __webpack_require__(8);
- var _definition = __webpack_require__(1);
- var _directives = __webpack_require__(5);
- var _introspection = __webpack_require__(11);
- var _scalars = __webpack_require__(7);
- var _kinds = __webpack_require__(2);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- /**
- * Produces a new schema given an existing schema and a document which may
- * contain GraphQL type extensions and definitions. The original schema will
- * remain unaltered.
- *
- * Because a schema represents a graph of references, a schema cannot be
- * extended without effectively making an entire copy. We do not know until it's
- * too late if subgraphs remain unchanged.
- *
- * This algorithm copies the provided schema, applying extensions while
- * producing the copy. The original schema remains unaltered.
- */
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function extendSchema(schema, documentAST) {
- (0, _invariant2.default)(schema instanceof _schema.GraphQLSchema, 'Must provide valid GraphQLSchema');
- (0, _invariant2.default)(documentAST && documentAST.kind === _kinds.DOCUMENT, 'Must provide valid Document AST');
- // Collect the type definitions and extensions found in the document.
- var typeDefinitionMap = {};
- var typeExtensionsMap = {};
- // New directives and types are separate because a directives and types can
- // have the same name. For example, a type named "skip".
- var directiveDefinitions = [];
- for (var i = 0; i < documentAST.definitions.length; i++) {
- var def = documentAST.definitions[i];
- switch (def.kind) {
- case _kinds.OBJECT_TYPE_DEFINITION:
- case _kinds.INTERFACE_TYPE_DEFINITION:
- case _kinds.ENUM_TYPE_DEFINITION:
- case _kinds.UNION_TYPE_DEFINITION:
- case _kinds.SCALAR_TYPE_DEFINITION:
- case _kinds.INPUT_OBJECT_TYPE_DEFINITION:
- // Sanity check that none of the defined types conflict with the
- // schema's existing types.
- var typeName = def.name.value;
- if (schema.getType(typeName)) {
- throw new _GraphQLError.GraphQLError('Type "' + typeName + '" already exists in the schema. It cannot also ' + 'be defined in this type definition.', [def]);
- }
- typeDefinitionMap[typeName] = def;
- break;
- case _kinds.TYPE_EXTENSION_DEFINITION:
- // Sanity check that this type extension exists within the
- // schema's existing types.
- var extendedTypeName = def.definition.name.value;
- var existingType = schema.getType(extendedTypeName);
- if (!existingType) {
- throw new _GraphQLError.GraphQLError('Cannot extend type "' + extendedTypeName + '" because it does not ' + 'exist in the existing schema.', [def.definition]);
- }
- if (!(existingType instanceof _definition.GraphQLObjectType)) {
- throw new _GraphQLError.GraphQLError('Cannot extend non-object type "' + extendedTypeName + '".', [def.definition]);
- }
- var extensions = typeExtensionsMap[extendedTypeName];
- if (extensions) {
- extensions.push(def);
- } else {
- extensions = [def];
- }
- typeExtensionsMap[extendedTypeName] = extensions;
- break;
- case _kinds.DIRECTIVE_DEFINITION:
- var directiveName = def.name.value;
- var existingDirective = schema.getDirective(directiveName);
- if (existingDirective) {
- throw new _GraphQLError.GraphQLError('Directive "' + directiveName + '" already exists in the schema. It ' + 'cannot be redefined.', [def]);
- }
- directiveDefinitions.push(def);
- break;
- }
- }
- // If this document contains no new types, extensions, or directives then
- // return the same unmodified GraphQLSchema instance.
- if (Object.keys(typeExtensionsMap).length === 0 && Object.keys(typeDefinitionMap).length === 0 && directiveDefinitions.length === 0) {
- return schema;
- }
- // A cache to use to store the actual GraphQLType definition objects by name.
- // Initialize to the GraphQL built in scalars and introspection types. All
- // functions below are inline so that this type def cache is within the scope
- // of the closure.
- var typeDefCache = {
- String: _scalars.GraphQLString,
- Int: _scalars.GraphQLInt,
- Float: _scalars.GraphQLFloat,
- Boolean: _scalars.GraphQLBoolean,
- ID: _scalars.GraphQLID,
- __Schema: _introspection.__Schema,
- __Directive: _introspection.__Directive,
- __DirectiveLocation: _introspection.__DirectiveLocation,
- __Type: _introspection.__Type,
- __Field: _introspection.__Field,
- __InputValue: _introspection.__InputValue,
- __EnumValue: _introspection.__EnumValue,
- __TypeKind: _introspection.__TypeKind
- };
- // Get the root Query, Mutation, and Subscription object types.
- var queryType = getTypeFromDef(schema.getQueryType());
- var existingMutationType = schema.getMutationType();
- var mutationType = existingMutationType ? getTypeFromDef(existingMutationType) : null;
- var existingSubscriptionType = schema.getSubscriptionType();
- var subscriptionType = existingSubscriptionType ? getTypeFromDef(existingSubscriptionType) : null;
- // Iterate through all types, getting the type definition for each, ensuring
- // that any type not directly referenced by a field will get created.
- var typeMap = schema.getTypeMap();
- var types = Object.keys(typeMap).map(function (typeName) {
- return getTypeFromDef(typeMap[typeName]);
- });
- // Do the same with new types, appending to the list of defined types.
- Object.keys(typeDefinitionMap).forEach(function (typeName) {
- types.push(getTypeFromAST(typeDefinitionMap[typeName]));
- });
- // Then produce and return a Schema with these types.
- return new _schema.GraphQLSchema({
- query: queryType,
- mutation: mutationType,
- subscription: subscriptionType,
- types: types,
- directives: getMergedDirectives()
- });
- // Below are functions used for producing this schema that have closed over
- // this scope and have access to the schema, cache, and newly defined types.
- function getMergedDirectives() {
- var existingDirectives = schema.getDirectives();
- (0, _invariant2.default)(existingDirectives, 'schema must have default directives');
- var newDirectives = directiveDefinitions.map(function (directiveNode) {
- return getDirective(directiveNode);
- });
- return existingDirectives.concat(newDirectives);
- }
- function getTypeFromDef(typeDef) {
- var type = _getNamedType(typeDef.name);
- (0, _invariant2.default)(type, 'Missing type from schema');
- return type;
- }
- function getTypeFromAST(node) {
- var type = _getNamedType(node.name.value);
- if (!type) {
- 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]);
- }
- return type;
- }
- function getObjectTypeFromAST(node) {
- var type = getTypeFromAST(node);
- (0, _invariant2.default)(type instanceof _definition.GraphQLObjectType, 'Must be Object type.');
- return type;
- }
- function getInterfaceTypeFromAST(node) {
- var type = getTypeFromAST(node);
- (0, _invariant2.default)(type instanceof _definition.GraphQLInterfaceType, 'Must be Interface type.');
- return type;
- }
- function getInputTypeFromAST(node) {
- var type = getTypeFromAST(node);
- (0, _invariant2.default)((0, _definition.isInputType)(type), 'Must be Input type.');
- return type;
- }
- function getOutputTypeFromAST(node) {
- var type = getTypeFromAST(node);
- (0, _invariant2.default)((0, _definition.isOutputType)(type), 'Must be Output type.');
- return type;
- }
- // Given a name, returns a type from either the existing schema or an
- // added type.
- function _getNamedType(typeName) {
- var cachedTypeDef = typeDefCache[typeName];
- if (cachedTypeDef) {
- return cachedTypeDef;
- }
- var existingType = schema.getType(typeName);
- if (existingType) {
- var typeDef = extendType(existingType);
- typeDefCache[typeName] = typeDef;
- return typeDef;
- }
- var typeNode = typeDefinitionMap[typeName];
- if (typeNode) {
- var _typeDef = buildType(typeNode);
- typeDefCache[typeName] = _typeDef;
- return _typeDef;
- }
- }
- // Given a type's introspection result, construct the correct
- // GraphQLType instance.
- function extendType(type) {
- if (type instanceof _definition.GraphQLObjectType) {
- return extendObjectType(type);
- }
- if (type instanceof _definition.GraphQLInterfaceType) {
- return extendInterfaceType(type);
- }
- if (type instanceof _definition.GraphQLUnionType) {
- return extendUnionType(type);
- }
- return type;
- }
- function extendObjectType(type) {
- return new _definition.GraphQLObjectType({
- name: type.name,
- description: type.description,
- interfaces: function interfaces() {
- return extendImplementedInterfaces(type);
- },
- fields: function fields() {
- return extendFieldMap(type);
- },
- isTypeOf: type.isTypeOf
- });
- }
- function extendInterfaceType(type) {
- return new _definition.GraphQLInterfaceType({
- name: type.name,
- description: type.description,
- fields: function fields() {
- return extendFieldMap(type);
- },
- resolveType: type.resolveType
- });
- }
- function extendUnionType(type) {
- return new _definition.GraphQLUnionType({
- name: type.name,
- description: type.description,
- types: type.getTypes().map(getTypeFromDef),
- resolveType: type.resolveType
- });
- }
- function extendImplementedInterfaces(type) {
- var interfaces = type.getInterfaces().map(getTypeFromDef);
- // If there are any extensions to the interfaces, apply those here.
- var extensions = typeExtensionsMap[type.name];
- if (extensions) {
- extensions.forEach(function (extension) {
- extension.definition.interfaces.forEach(function (namedType) {
- var interfaceName = namedType.name.value;
- if (interfaces.some(function (def) {
- return def.name === interfaceName;
- })) {
- throw new _GraphQLError.GraphQLError('Type "' + type.name + '" already implements "' + interfaceName + '". ' + 'It cannot also be implemented in this type extension.', [namedType]);
- }
- interfaces.push(getInterfaceTypeFromAST(namedType));
- });
- });
- }
- return interfaces;
- }
- function extendFieldMap(type) {
- var newFieldMap = {};
- var oldFieldMap = type.getFields();
- Object.keys(oldFieldMap).forEach(function (fieldName) {
- var field = oldFieldMap[fieldName];
- newFieldMap[fieldName] = {
- description: field.description,
- deprecationReason: field.deprecationReason,
- type: extendFieldType(field.type),
- args: (0, _keyMap2.default)(field.args, function (arg) {
- return arg.name;
- }),
- resolve: field.resolve
- };
- });
- // If there are any extensions to the fields, apply those here.
- var extensions = typeExtensionsMap[type.name];
- if (extensions) {
- extensions.forEach(function (extension) {
- extension.definition.fields.forEach(function (field) {
- var fieldName = field.name.value;
- if (oldFieldMap[fieldName]) {
- throw new _GraphQLError.GraphQLError('Field "' + type.name + '.' + fieldName + '" already exists in the ' + 'schema. It cannot also be defined in this type extension.', [field]);
- }
- newFieldMap[fieldName] = {
- description: (0, _buildASTSchema.getDescription)(field),
- type: buildOutputFieldType(field.type),
- args: buildInputValues(field.arguments)
- };
- });
- });
- }
- return newFieldMap;
- }
- function extendFieldType(typeDef) {
- if (typeDef instanceof _definition.GraphQLList) {
- return new _definition.GraphQLList(extendFieldType(typeDef.ofType));
- }
- if (typeDef instanceof _definition.GraphQLNonNull) {
- return new _definition.GraphQLNonNull(extendFieldType(typeDef.ofType));
- }
- return getTypeFromDef(typeDef);
- }
- function buildType(typeNode) {
- switch (typeNode.kind) {
- case _kinds.OBJECT_TYPE_DEFINITION:
- return buildObjectType(typeNode);
- case _kinds.INTERFACE_TYPE_DEFINITION:
- return buildInterfaceType(typeNode);
- case _kinds.UNION_TYPE_DEFINITION:
- return buildUnionType(typeNode);
- case _kinds.SCALAR_TYPE_DEFINITION:
- return buildScalarType(typeNode);
- case _kinds.ENUM_TYPE_DEFINITION:
- return buildEnumType(typeNode);
- case _kinds.INPUT_OBJECT_TYPE_DEFINITION:
- return buildInputObjectType(typeNode);
- }
- throw new TypeError('Unknown type kind ' + typeNode.kind);
- }
- function buildObjectType(typeNode) {
- return new _definition.GraphQLObjectType({
- name: typeNode.name.value,
- description: (0, _buildASTSchema.getDescription)(typeNode),
- interfaces: function interfaces() {
- return buildImplementedInterfaces(typeNode);
- },
- fields: function fields() {
- return buildFieldMap(typeNode);
- }
- });
- }
- function buildInterfaceType(typeNode) {
- return new _definition.GraphQLInterfaceType({
- name: typeNode.name.value,
- description: (0, _buildASTSchema.getDescription)(typeNode),
- fields: function fields() {
- return buildFieldMap(typeNode);
- },
- resolveType: cannotExecuteExtendedSchema
- });
- }
- function buildUnionType(typeNode) {
- return new _definition.GraphQLUnionType({
- name: typeNode.name.value,
- description: (0, _buildASTSchema.getDescription)(typeNode),
- types: typeNode.types.map(getObjectTypeFromAST),
- resolveType: cannotExecuteExtendedSchema
- });
- }
- function buildScalarType(typeNode) {
- return new _definition.GraphQLScalarType({
- name: typeNode.name.value,
- description: (0, _buildASTSchema.getDescription)(typeNode),
- serialize: function serialize(id) {
- return id;
- },
- // Note: validation calls the parse functions to determine if a
- // literal value is correct. Returning null would cause use of custom
- // scalars to always fail validation. Returning false causes them to
- // always pass validation.
- parseValue: function parseValue() {
- return false;
- },
- parseLiteral: function parseLiteral() {
- return false;
- }
- });
- }
- function buildEnumType(typeNode) {
- return new _definition.GraphQLEnumType({
- name: typeNode.name.value,
- description: (0, _buildASTSchema.getDescription)(typeNode),
- values: (0, _keyValMap2.default)(typeNode.values, function (v) {
- return v.name.value;
- }, function () {
- return {};
- })
- });
- }
- function buildInputObjectType(typeNode) {
- return new _definition.GraphQLInputObjectType({
- name: typeNode.name.value,
- description: (0, _buildASTSchema.getDescription)(typeNode),
- fields: function fields() {
- return buildInputValues(typeNode.fields);
- }
- });
- }
- function getDirective(directiveNode) {
- return new _directives.GraphQLDirective({
- name: directiveNode.name.value,
- locations: directiveNode.locations.map(function (node) {
- return node.value;
- }),
- args: directiveNode.arguments && buildInputValues(directiveNode.arguments)
- });
- }
- function buildImplementedInterfaces(typeNode) {
- return typeNode.interfaces && typeNode.interfaces.map(getInterfaceTypeFromAST);
- }
- function buildFieldMap(typeNode) {
- return (0, _keyValMap2.default)(typeNode.fields, function (field) {
- return field.name.value;
- }, function (field) {
- return {
- type: buildOutputFieldType(field.type),
- description: (0, _buildASTSchema.getDescription)(field),
- args: buildInputValues(field.arguments)
- };
- });
- }
- function buildInputValues(values) {
- return (0, _keyValMap2.default)(values, function (value) {
- return value.name.value;
- }, function (value) {
- var type = buildInputFieldType(value.type);
- return {
- type: type,
- description: (0, _buildASTSchema.getDescription)(value),
- defaultValue: (0, _valueFromAST.valueFromAST)(value.defaultValue, type)
- };
- });
- }
- function buildInputFieldType(typeNode) {
- if (typeNode.kind === _kinds.LIST_TYPE) {
- return new _definition.GraphQLList(buildInputFieldType(typeNode.type));
- }
- if (typeNode.kind === _kinds.NON_NULL_TYPE) {
- var nullableType = buildInputFieldType(typeNode.type);
- (0, _invariant2.default)(!(nullableType instanceof _definition.GraphQLNonNull), 'Must be nullable');
- return new _definition.GraphQLNonNull(nullableType);
- }
- return getInputTypeFromAST(typeNode);
- }
- function buildOutputFieldType(typeNode) {
- if (typeNode.kind === _kinds.LIST_TYPE) {
- return new _definition.GraphQLList(buildOutputFieldType(typeNode.type));
- }
- if (typeNode.kind === _kinds.NON_NULL_TYPE) {
- var nullableType = buildOutputFieldType(typeNode.type);
- (0, _invariant2.default)(!(nullableType instanceof _definition.GraphQLNonNull), 'Must be nullable');
- return new _definition.GraphQLNonNull(nullableType);
- }
- return getOutputTypeFromAST(typeNode);
- }
- }
- function cannotExecuteExtendedSchema() {
- throw new Error('Extended Schema cannot use Interface or Union types for execution.');
- }
- /***/ }),
- /* 48 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.BreakingChangeType = undefined;
- exports.findBreakingChanges = findBreakingChanges;
- exports.findRemovedTypes = findRemovedTypes;
- exports.findTypesThatChangedKind = findTypesThatChangedKind;
- exports.findFieldsThatChangedType = findFieldsThatChangedType;
- exports.findTypesRemovedFromUnions = findTypesRemovedFromUnions;
- exports.findValuesRemovedFromEnums = findValuesRemovedFromEnums;
- var _definition = __webpack_require__(1);
- var _schema = __webpack_require__(8);
- /**
- * Copyright (c) 2016, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- var BreakingChangeType = exports.BreakingChangeType = {
- FIELD_CHANGED_KIND: 'FIELD_CHANGED_KIND',
- FIELD_REMOVED: 'FIELD_REMOVED',
- TYPE_CHANGED_KIND: 'TYPE_CHANGED_KIND',
- TYPE_REMOVED: 'TYPE_REMOVED',
- TYPE_REMOVED_FROM_UNION: 'TYPE_REMOVED_FROM_UNION',
- VALUE_REMOVED_FROM_ENUM: 'VALUE_REMOVED_FROM_ENUM'
- };
- /**
- * Given two schemas, returns an Array containing descriptions of all the types
- * of breaking changes covered by the other functions down below.
- */
- function findBreakingChanges(oldSchema, newSchema) {
- return [].concat(findRemovedTypes(oldSchema, newSchema), findTypesThatChangedKind(oldSchema, newSchema), findFieldsThatChangedType(oldSchema, newSchema), findTypesRemovedFromUnions(oldSchema, newSchema), findValuesRemovedFromEnums(oldSchema, newSchema));
- }
- /**
- * Given two schemas, returns an Array containing descriptions of any breaking
- * changes in the newSchema related to removing an entire type.
- */
- function findRemovedTypes(oldSchema, newSchema) {
- var oldTypeMap = oldSchema.getTypeMap();
- var newTypeMap = newSchema.getTypeMap();
- var breakingChanges = [];
- Object.keys(oldTypeMap).forEach(function (typeName) {
- if (!newTypeMap[typeName]) {
- breakingChanges.push({
- type: BreakingChangeType.TYPE_REMOVED,
- description: typeName + ' was removed.'
- });
- }
- });
- return breakingChanges;
- }
- /**
- * Given two schemas, returns an Array containing descriptions of any breaking
- * changes in the newSchema related to changing the type of a type.
- */
- function findTypesThatChangedKind(oldSchema, newSchema) {
- var oldTypeMap = oldSchema.getTypeMap();
- var newTypeMap = newSchema.getTypeMap();
- var breakingChanges = [];
- Object.keys(oldTypeMap).forEach(function (typeName) {
- if (!newTypeMap[typeName]) {
- return;
- }
- var oldType = oldTypeMap[typeName];
- var newType = newTypeMap[typeName];
- if (!(oldType instanceof newType.constructor)) {
- breakingChanges.push({
- type: BreakingChangeType.TYPE_CHANGED_KIND,
- description: typeName + ' changed from ' + (typeKindName(oldType) + ' to ' + typeKindName(newType) + '.')
- });
- }
- });
- return breakingChanges;
- }
- function typeKindName(type) {
- if (type instanceof _definition.GraphQLScalarType) {
- return 'a Scalar type';
- }
- if (type instanceof _definition.GraphQLObjectType) {
- return 'an Object type';
- }
- if (type instanceof _definition.GraphQLInterfaceType) {
- return 'an Interface type';
- }
- if (type instanceof _definition.GraphQLUnionType) {
- return 'a Union type';
- }
- if (type instanceof _definition.GraphQLEnumType) {
- return 'an Enum type';
- }
- if (type instanceof _definition.GraphQLInputObjectType) {
- return 'an Input type';
- }
- throw new TypeError('Unknown type ' + type.constructor.name);
- }
- /**
- * Given two schemas, returns an Array containing descriptions of any breaking
- * changes in the newSchema related to the fields on a type. This includes if
- * a field has been removed from a type or if a field has changed type.
- */
- function findFieldsThatChangedType(oldSchema, newSchema) {
- var oldTypeMap = oldSchema.getTypeMap();
- var newTypeMap = newSchema.getTypeMap();
- var breakingFieldChanges = [];
- Object.keys(oldTypeMap).forEach(function (typeName) {
- var oldType = oldTypeMap[typeName];
- var newType = newTypeMap[typeName];
- if (!(oldType instanceof _definition.GraphQLObjectType || oldType instanceof _definition.GraphQLInterfaceType || oldType instanceof _definition.GraphQLInputObjectType) || !(newType instanceof oldType.constructor)) {
- return;
- }
- var oldTypeFieldsDef = oldType.getFields();
- var newTypeFieldsDef = newType.getFields();
- Object.keys(oldTypeFieldsDef).forEach(function (fieldName) {
- // Check if the field is missing on the type in the new schema.
- if (!(fieldName in newTypeFieldsDef)) {
- breakingFieldChanges.push({
- type: BreakingChangeType.FIELD_REMOVED,
- description: typeName + '.' + fieldName + ' was removed.'
- });
- } else {
- // Check if the field's type has changed in the new schema.
- var oldFieldType = (0, _definition.getNamedType)(oldTypeFieldsDef[fieldName].type);
- var newFieldType = (0, _definition.getNamedType)(newTypeFieldsDef[fieldName].type);
- if (oldFieldType && newFieldType && oldFieldType.name !== newFieldType.name) {
- breakingFieldChanges.push({
- type: BreakingChangeType.FIELD_CHANGED_KIND,
- description: typeName + '.' + fieldName + ' changed type from ' + (oldFieldType.name + ' to ' + newFieldType.name + '.')
- });
- }
- }
- });
- });
- return breakingFieldChanges;
- }
- /**
- * Given two schemas, returns an Array containing descriptions of any breaking
- * changes in the newSchema related to removing types from a union type.
- */
- function findTypesRemovedFromUnions(oldSchema, newSchema) {
- var oldTypeMap = oldSchema.getTypeMap();
- var newTypeMap = newSchema.getTypeMap();
- var typesRemovedFromUnion = [];
- Object.keys(oldTypeMap).forEach(function (typeName) {
- var oldType = oldTypeMap[typeName];
- var newType = newTypeMap[typeName];
- if (!(oldType instanceof _definition.GraphQLUnionType) || !(newType instanceof _definition.GraphQLUnionType)) {
- return;
- }
- var typeNamesInNewUnion = Object.create(null);
- newType.getTypes().forEach(function (type) {
- typeNamesInNewUnion[type.name] = true;
- });
- oldType.getTypes().forEach(function (type) {
- if (!typeNamesInNewUnion[type.name]) {
- typesRemovedFromUnion.push({
- type: BreakingChangeType.TYPE_REMOVED_FROM_UNION,
- description: type.name + ' was removed from union type ' + typeName + '.'
- });
- }
- });
- });
- return typesRemovedFromUnion;
- }
- /**
- * Given two schemas, returns an Array containing descriptions of any breaking
- * changes in the newSchema related to removing values from an enum type.
- */
- function findValuesRemovedFromEnums(oldSchema, newSchema) {
- var oldTypeMap = oldSchema.getTypeMap();
- var newTypeMap = newSchema.getTypeMap();
- var valuesRemovedFromEnums = [];
- Object.keys(oldTypeMap).forEach(function (typeName) {
- var oldType = oldTypeMap[typeName];
- var newType = newTypeMap[typeName];
- if (!(oldType instanceof _definition.GraphQLEnumType) || !(newType instanceof _definition.GraphQLEnumType)) {
- return;
- }
- var valuesInNewEnum = Object.create(null);
- newType.getValues().forEach(function (value) {
- valuesInNewEnum[value.name] = true;
- });
- oldType.getValues().forEach(function (value) {
- if (!valuesInNewEnum[value.name]) {
- valuesRemovedFromEnums.push({
- type: BreakingChangeType.VALUE_REMOVED_FROM_ENUM,
- description: value.name + ' was removed from enum type ' + typeName + '.'
- });
- }
- });
- });
- return valuesRemovedFromEnums;
- }
- /***/ }),
- /* 49 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.findDeprecatedUsages = findDeprecatedUsages;
- var _GraphQLError = __webpack_require__(13);
- var _visitor = __webpack_require__(15);
- var _definition = __webpack_require__(1);
- var _schema = __webpack_require__(8);
- var _TypeInfo = __webpack_require__(27);
- /**
- * A validation rule which reports deprecated usages.
- *
- * Returns a list of GraphQLError instances describing each deprecated use.
- */
- function findDeprecatedUsages(schema, ast) {
- var errors = [];
- var typeInfo = new _TypeInfo.TypeInfo(schema);
- (0, _visitor.visit)(ast, (0, _visitor.visitWithTypeInfo)(typeInfo, {
- Field: function Field(node) {
- var fieldDef = typeInfo.getFieldDef();
- if (fieldDef && fieldDef.isDeprecated) {
- var parentType = typeInfo.getParentType();
- if (parentType) {
- var reason = fieldDef.deprecationReason;
- errors.push(new _GraphQLError.GraphQLError('The field ' + parentType.name + '.' + fieldDef.name + ' is deprecated.' + (reason ? ' ' + reason : ''), [node]));
- }
- }
- },
- EnumValue: function EnumValue(node) {
- var enumVal = typeInfo.getEnumValue();
- if (enumVal && enumVal.isDeprecated) {
- var type = (0, _definition.getNamedType)(typeInfo.getInputType());
- if (type) {
- var reason = enumVal.deprecationReason;
- errors.push(new _GraphQLError.GraphQLError('The enum value ' + type.name + '.' + enumVal.name + ' is deprecated.' + (reason ? ' ' + reason : ''), [node]));
- }
- }
- }
- }));
- return errors;
- }
- /**
- * Copyright (c) Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- /***/ }),
- /* 50 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.getOperationAST = getOperationAST;
- var _kinds = __webpack_require__(2);
- /**
- * Returns an operation AST given a document AST and optionally an operation
- * name. If a name is not provided, an operation is only returned if only one is
- * provided in the document.
- */
- function getOperationAST(documentAST, operationName) {
- var operation = null;
- for (var i = 0; i < documentAST.definitions.length; i++) {
- var definition = documentAST.definitions[i];
- if (definition.kind === _kinds.OPERATION_DEFINITION) {
- if (!operationName) {
- // If no operation name was provided, only return an Operation if there
- // is one defined in the document. Upon encountering the second, return
- // null.
- if (operation) {
- return null;
- }
- operation = definition;
- } else if (definition.name && definition.name.value === operationName) {
- return definition;
- }
- }
- }
- return operation;
- }
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- /***/ }),
- /* 51 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- var _introspectionQuery = __webpack_require__(52);
- Object.defineProperty(exports, 'introspectionQuery', {
- enumerable: true,
- get: function get() {
- return _introspectionQuery.introspectionQuery;
- }
- });
- var _getOperationAST = __webpack_require__(50);
- Object.defineProperty(exports, 'getOperationAST', {
- enumerable: true,
- get: function get() {
- return _getOperationAST.getOperationAST;
- }
- });
- var _buildClientSchema = __webpack_require__(45);
- Object.defineProperty(exports, 'buildClientSchema', {
- enumerable: true,
- get: function get() {
- return _buildClientSchema.buildClientSchema;
- }
- });
- var _buildASTSchema = __webpack_require__(32);
- Object.defineProperty(exports, 'buildASTSchema', {
- enumerable: true,
- get: function get() {
- return _buildASTSchema.buildASTSchema;
- }
- });
- Object.defineProperty(exports, 'buildSchema', {
- enumerable: true,
- get: function get() {
- return _buildASTSchema.buildSchema;
- }
- });
- var _extendSchema = __webpack_require__(47);
- Object.defineProperty(exports, 'extendSchema', {
- enumerable: true,
- get: function get() {
- return _extendSchema.extendSchema;
- }
- });
- var _schemaPrinter = __webpack_require__(53);
- Object.defineProperty(exports, 'printSchema', {
- enumerable: true,
- get: function get() {
- return _schemaPrinter.printSchema;
- }
- });
- Object.defineProperty(exports, 'printType', {
- enumerable: true,
- get: function get() {
- return _schemaPrinter.printType;
- }
- });
- Object.defineProperty(exports, 'printIntrospectionSchema', {
- enumerable: true,
- get: function get() {
- return _schemaPrinter.printIntrospectionSchema;
- }
- });
- var _typeFromAST = __webpack_require__(9);
- Object.defineProperty(exports, 'typeFromAST', {
- enumerable: true,
- get: function get() {
- return _typeFromAST.typeFromAST;
- }
- });
- var _valueFromAST = __webpack_require__(16);
- Object.defineProperty(exports, 'valueFromAST', {
- enumerable: true,
- get: function get() {
- return _valueFromAST.valueFromAST;
- }
- });
- var _astFromValue = __webpack_require__(29);
- Object.defineProperty(exports, 'astFromValue', {
- enumerable: true,
- get: function get() {
- return _astFromValue.astFromValue;
- }
- });
- var _TypeInfo = __webpack_require__(27);
- Object.defineProperty(exports, 'TypeInfo', {
- enumerable: true,
- get: function get() {
- return _TypeInfo.TypeInfo;
- }
- });
- var _isValidJSValue = __webpack_require__(33);
- Object.defineProperty(exports, 'isValidJSValue', {
- enumerable: true,
- get: function get() {
- return _isValidJSValue.isValidJSValue;
- }
- });
- var _isValidLiteralValue = __webpack_require__(18);
- Object.defineProperty(exports, 'isValidLiteralValue', {
- enumerable: true,
- get: function get() {
- return _isValidLiteralValue.isValidLiteralValue;
- }
- });
- var _concatAST = __webpack_require__(46);
- Object.defineProperty(exports, 'concatAST', {
- enumerable: true,
- get: function get() {
- return _concatAST.concatAST;
- }
- });
- var _separateOperations = __webpack_require__(54);
- Object.defineProperty(exports, 'separateOperations', {
- enumerable: true,
- get: function get() {
- return _separateOperations.separateOperations;
- }
- });
- var _typeComparators = __webpack_require__(19);
- Object.defineProperty(exports, 'isEqualType', {
- enumerable: true,
- get: function get() {
- return _typeComparators.isEqualType;
- }
- });
- Object.defineProperty(exports, 'isTypeSubTypeOf', {
- enumerable: true,
- get: function get() {
- return _typeComparators.isTypeSubTypeOf;
- }
- });
- Object.defineProperty(exports, 'doTypesOverlap', {
- enumerable: true,
- get: function get() {
- return _typeComparators.doTypesOverlap;
- }
- });
- var _assertValidName = __webpack_require__(28);
- Object.defineProperty(exports, 'assertValidName', {
- enumerable: true,
- get: function get() {
- return _assertValidName.assertValidName;
- }
- });
- var _findBreakingChanges = __webpack_require__(48);
- Object.defineProperty(exports, 'findBreakingChanges', {
- enumerable: true,
- get: function get() {
- return _findBreakingChanges.findBreakingChanges;
- }
- });
- var _findDeprecatedUsages = __webpack_require__(49);
- Object.defineProperty(exports, 'findDeprecatedUsages', {
- enumerable: true,
- get: function get() {
- return _findDeprecatedUsages.findDeprecatedUsages;
- }
- });
- /***/ }),
- /* 52 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- 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';
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- /***/ }),
- /* 53 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.printSchema = printSchema;
- exports.printIntrospectionSchema = printIntrospectionSchema;
- exports.printType = printType;
- var _invariant = __webpack_require__(3);
- var _invariant2 = _interopRequireDefault(_invariant);
- var _isNullish = __webpack_require__(6);
- var _isNullish2 = _interopRequireDefault(_isNullish);
- var _isInvalid = __webpack_require__(14);
- var _isInvalid2 = _interopRequireDefault(_isInvalid);
- var _astFromValue = __webpack_require__(29);
- var _printer = __webpack_require__(4);
- var _definition = __webpack_require__(1);
- var _scalars = __webpack_require__(7);
- var _directives = __webpack_require__(5);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function printSchema(schema) {
- return printFilteredSchema(schema, function (n) {
- return !isSpecDirective(n);
- }, isDefinedType);
- }
- function printIntrospectionSchema(schema) {
- return printFilteredSchema(schema, isSpecDirective, isIntrospectionType);
- }
- function isSpecDirective(directiveName) {
- return directiveName === 'skip' || directiveName === 'include' || directiveName === 'deprecated';
- }
- function isDefinedType(typename) {
- return !isIntrospectionType(typename) && !isBuiltInScalar(typename);
- }
- function isIntrospectionType(typename) {
- return typename.indexOf('__') === 0;
- }
- function isBuiltInScalar(typename) {
- return typename === 'String' || typename === 'Boolean' || typename === 'Int' || typename === 'Float' || typename === 'ID';
- }
- function printFilteredSchema(schema, directiveFilter, typeFilter) {
- var directives = schema.getDirectives().filter(function (directive) {
- return directiveFilter(directive.name);
- });
- var typeMap = schema.getTypeMap();
- var types = Object.keys(typeMap).filter(typeFilter).sort(function (name1, name2) {
- return name1.localeCompare(name2);
- }).map(function (typeName) {
- return typeMap[typeName];
- });
- return [printSchemaDefinition(schema)].concat(directives.map(printDirective), types.map(printType)).filter(Boolean).join('\n\n') + '\n';
- }
- function printSchemaDefinition(schema) {
- if (isSchemaOfCommonNames(schema)) {
- return;
- }
- var operationTypes = [];
- var queryType = schema.getQueryType();
- if (queryType) {
- operationTypes.push(' query: ' + queryType.name);
- }
- var mutationType = schema.getMutationType();
- if (mutationType) {
- operationTypes.push(' mutation: ' + mutationType.name);
- }
- var subscriptionType = schema.getSubscriptionType();
- if (subscriptionType) {
- operationTypes.push(' subscription: ' + subscriptionType.name);
- }
- return 'schema {\n' + operationTypes.join('\n') + '\n}';
- }
- /**
- * GraphQL schema define root types for each type of operation. These types are
- * the same as any other type and can be named in any manner, however there is
- * a common naming convention:
- *
- * schema {
- * query: Query
- * mutation: Mutation
- * }
- *
- * When using this naming convention, the schema description can be omitted.
- */
- function isSchemaOfCommonNames(schema) {
- var queryType = schema.getQueryType();
- if (queryType && queryType.name !== 'Query') {
- return false;
- }
- var mutationType = schema.getMutationType();
- if (mutationType && mutationType.name !== 'Mutation') {
- return false;
- }
- var subscriptionType = schema.getSubscriptionType();
- if (subscriptionType && subscriptionType.name !== 'Subscription') {
- return false;
- }
- return true;
- }
- function printType(type) {
- if (type instanceof _definition.GraphQLScalarType) {
- return printScalar(type);
- } else if (type instanceof _definition.GraphQLObjectType) {
- return printObject(type);
- } else if (type instanceof _definition.GraphQLInterfaceType) {
- return printInterface(type);
- } else if (type instanceof _definition.GraphQLUnionType) {
- return printUnion(type);
- } else if (type instanceof _definition.GraphQLEnumType) {
- return printEnum(type);
- }
- (0, _invariant2.default)(type instanceof _definition.GraphQLInputObjectType);
- return printInputObject(type);
- }
- function printScalar(type) {
- return printDescription(type) + ('scalar ' + type.name);
- }
- function printObject(type) {
- var interfaces = type.getInterfaces();
- var implementedInterfaces = interfaces.length ? ' implements ' + interfaces.map(function (i) {
- return i.name;
- }).join(', ') : '';
- return printDescription(type) + ('type ' + type.name + implementedInterfaces + ' {\n') + printFields(type) + '\n' + '}';
- }
- function printInterface(type) {
- return printDescription(type) + ('interface ' + type.name + ' {\n') + printFields(type) + '\n' + '}';
- }
- function printUnion(type) {
- return printDescription(type) + ('union ' + type.name + ' = ' + type.getTypes().join(' | '));
- }
- function printEnum(type) {
- return printDescription(type) + ('enum ' + type.name + ' {\n') + printEnumValues(type.getValues()) + '\n' + '}';
- }
- function printEnumValues(values) {
- return values.map(function (value, i) {
- return printDescription(value, ' ', !i) + ' ' + value.name + printDeprecated(value);
- }).join('\n');
- }
- function printInputObject(type) {
- var fieldMap = type.getFields();
- var fields = Object.keys(fieldMap).map(function (fieldName) {
- return fieldMap[fieldName];
- });
- return printDescription(type) + ('input ' + type.name + ' {\n') + fields.map(function (f, i) {
- return printDescription(f, ' ', !i) + ' ' + printInputValue(f);
- }).join('\n') + '\n' + '}';
- }
- function printFields(type) {
- var fieldMap = type.getFields();
- var fields = Object.keys(fieldMap).map(function (fieldName) {
- return fieldMap[fieldName];
- });
- return fields.map(function (f, i) {
- return printDescription(f, ' ', !i) + ' ' + f.name + printArgs(f.args, ' ') + ': ' + String(f.type) + printDeprecated(f);
- }).join('\n');
- }
- function printArgs(args) {
- var indentation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
- if (args.length === 0) {
- return '';
- }
- // If every arg does not have a description, print them on one line.
- if (args.every(function (arg) {
- return !arg.description;
- })) {
- return '(' + args.map(printInputValue).join(', ') + ')';
- }
- return '(\n' + args.map(function (arg, i) {
- return printDescription(arg, ' ' + indentation, !i) + ' ' + indentation + printInputValue(arg);
- }).join('\n') + '\n' + indentation + ')';
- }
- function printInputValue(arg) {
- var argDecl = arg.name + ': ' + String(arg.type);
- if (!(0, _isInvalid2.default)(arg.defaultValue)) {
- argDecl += ' = ' + (0, _printer.print)((0, _astFromValue.astFromValue)(arg.defaultValue, arg.type));
- }
- return argDecl;
- }
- function printDirective(directive) {
- return printDescription(directive) + 'directive @' + directive.name + printArgs(directive.args) + ' on ' + directive.locations.join(' | ');
- }
- function printDeprecated(fieldOrEnumVal) {
- var reason = fieldOrEnumVal.deprecationReason;
- if ((0, _isNullish2.default)(reason)) {
- return '';
- }
- if (reason === '' || reason === _directives.DEFAULT_DEPRECATION_REASON) {
- return ' @deprecated';
- }
- return ' @deprecated(reason: ' + (0, _printer.print)((0, _astFromValue.astFromValue)(reason, _scalars.GraphQLString)) + ')';
- }
- function printDescription(def) {
- var indentation = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
- var firstInBlock = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
- if (!def.description) {
- return '';
- }
- var lines = def.description.split('\n');
- var description = indentation && !firstInBlock ? '\n' : '';
- for (var i = 0; i < lines.length; i++) {
- if (lines[i] === '') {
- description += indentation + '#\n';
- } else {
- // For > 120 character long lines, cut at space boundaries into sublines
- // of ~80 chars.
- var sublines = breakLine(lines[i], 120 - indentation.length);
- for (var j = 0; j < sublines.length; j++) {
- description += indentation + '# ' + sublines[j] + '\n';
- }
- }
- }
- return description;
- }
- function breakLine(line, len) {
- if (line.length < len + 5) {
- return [line];
- }
- var parts = line.split(new RegExp('((?: |^).{15,' + (len - 40) + '}(?= |$))'));
- if (parts.length < 4) {
- return [line];
- }
- var sublines = [parts[0] + parts[1] + parts[2]];
- for (var i = 3; i < parts.length; i += 2) {
- sublines.push(parts[i].slice(1) + parts[i + 1]);
- }
- return sublines;
- }
- /***/ }),
- /* 54 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.separateOperations = separateOperations;
- var _visitor = __webpack_require__(15);
- /**
- * separateOperations accepts a single AST document which may contain many
- * operations and fragments and returns a collection of AST documents each of
- * which contains a single operation as well the fragment definitions it
- * refers to.
- */
- function separateOperations(documentAST) {
- var operations = [];
- var depGraph = Object.create(null);
- var fromName = void 0;
- // Populate the list of operations and build a dependency graph.
- (0, _visitor.visit)(documentAST, {
- OperationDefinition: function OperationDefinition(node) {
- operations.push(node);
- fromName = opName(node);
- },
- FragmentDefinition: function FragmentDefinition(node) {
- fromName = node.name.value;
- },
- FragmentSpread: function FragmentSpread(node) {
- var toName = node.name.value;
- (depGraph[fromName] || (depGraph[fromName] = Object.create(null)))[toName] = true;
- }
- });
- // For each operation, produce a new synthesized AST which includes only what
- // is necessary for completing that operation.
- var separatedDocumentASTs = Object.create(null);
- operations.forEach(function (operation) {
- var operationName = opName(operation);
- var dependencies = Object.create(null);
- collectTransitiveDependencies(dependencies, depGraph, operationName);
- separatedDocumentASTs[operationName] = {
- kind: 'Document',
- definitions: documentAST.definitions.filter(function (def) {
- return def === operation || def.kind === 'FragmentDefinition' && dependencies[def.name.value];
- })
- };
- });
- return separatedDocumentASTs;
- }
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- // Provides the empty string for anonymous operations.
- function opName(operation) {
- return operation.name ? operation.name.value : '';
- }
- // From a dependency graph, collects a list of transitive dependencies by
- // recursing through a dependency graph.
- function collectTransitiveDependencies(collected, depGraph, fromName) {
- var immediateDeps = depGraph[fromName];
- if (immediateDeps) {
- Object.keys(immediateDeps).forEach(function (toName) {
- if (!collected[toName]) {
- collected[toName] = true;
- collectTransitiveDependencies(collected, depGraph, toName);
- }
- });
- }
- }
- /***/ }),
- /* 55 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- var _validate = __webpack_require__(35);
- Object.defineProperty(exports, 'validate', {
- enumerable: true,
- get: function get() {
- return _validate.validate;
- }
- });
- Object.defineProperty(exports, 'ValidationContext', {
- enumerable: true,
- get: function get() {
- return _validate.ValidationContext;
- }
- });
- var _specifiedRules = __webpack_require__(34);
- Object.defineProperty(exports, 'specifiedRules', {
- enumerable: true,
- get: function get() {
- return _specifiedRules.specifiedRules;
- }
- });
- /***/ }),
- /* 56 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.badValueMessage = badValueMessage;
- exports.ArgumentsOfCorrectType = ArgumentsOfCorrectType;
- var _error = __webpack_require__(0);
- var _printer = __webpack_require__(4);
- var _isValidLiteralValue = __webpack_require__(18);
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function badValueMessage(argName, type, value, verboseErrors) {
- var message = verboseErrors ? '\n' + verboseErrors.join('\n') : '';
- return 'Argument "' + argName + '" has invalid value ' + value + '.' + message;
- }
- /**
- * Argument values of correct type
- *
- * A GraphQL document is only valid if all field argument literal values are
- * of the type expected by their position.
- */
- function ArgumentsOfCorrectType(context) {
- return {
- Argument: function Argument(node) {
- var argDef = context.getArgument();
- if (argDef) {
- var errors = (0, _isValidLiteralValue.isValidLiteralValue)(argDef.type, node.value);
- if (errors && errors.length > 0) {
- context.reportError(new _error.GraphQLError(badValueMessage(node.name.value, argDef.type, (0, _printer.print)(node.value), errors), [node.value]));
- }
- }
- return false;
- }
- };
- }
- /***/ }),
- /* 57 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.defaultForNonNullArgMessage = defaultForNonNullArgMessage;
- exports.badValueForDefaultArgMessage = badValueForDefaultArgMessage;
- exports.DefaultValuesOfCorrectType = DefaultValuesOfCorrectType;
- var _error = __webpack_require__(0);
- var _printer = __webpack_require__(4);
- var _definition = __webpack_require__(1);
- var _isValidLiteralValue = __webpack_require__(18);
- function defaultForNonNullArgMessage(varName, type, guessType) {
- return 'Variable "$' + varName + '" of type "' + String(type) + '" is required and ' + 'will not use the default value. ' + ('Perhaps you meant to use type "' + String(guessType) + '".');
- }
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function badValueForDefaultArgMessage(varName, type, value, verboseErrors) {
- var message = verboseErrors ? '\n' + verboseErrors.join('\n') : '';
- return 'Variable "$' + varName + '" of type "' + String(type) + '" has invalid ' + ('default value ' + value + '.' + message);
- }
- /**
- * Variable default values of correct type
- *
- * A GraphQL document is only valid if all variable default values are of the
- * type expected by their definition.
- */
- function DefaultValuesOfCorrectType(context) {
- return {
- VariableDefinition: function VariableDefinition(node) {
- var name = node.variable.name.value;
- var defaultValue = node.defaultValue;
- var type = context.getInputType();
- if (type instanceof _definition.GraphQLNonNull && defaultValue) {
- context.reportError(new _error.GraphQLError(defaultForNonNullArgMessage(name, type, type.ofType), [defaultValue]));
- }
- if (type && defaultValue) {
- var errors = (0, _isValidLiteralValue.isValidLiteralValue)(type, defaultValue);
- if (errors && errors.length > 0) {
- context.reportError(new _error.GraphQLError(badValueForDefaultArgMessage(name, type, (0, _printer.print)(defaultValue), errors), [defaultValue]));
- }
- }
- return false;
- },
- SelectionSet: function SelectionSet() {
- return false;
- },
- FragmentDefinition: function FragmentDefinition() {
- return false;
- }
- };
- }
- /***/ }),
- /* 58 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.undefinedFieldMessage = undefinedFieldMessage;
- exports.FieldsOnCorrectType = FieldsOnCorrectType;
- var _error = __webpack_require__(0);
- var _suggestionList = __webpack_require__(23);
- var _suggestionList2 = _interopRequireDefault(_suggestionList);
- var _quotedOrList = __webpack_require__(22);
- var _quotedOrList2 = _interopRequireDefault(_quotedOrList);
- var _definition = __webpack_require__(1);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- function undefinedFieldMessage(fieldName, type, suggestedTypeNames, suggestedFieldNames) {
- var message = 'Cannot query field "' + fieldName + '" on type "' + type + '".';
- if (suggestedTypeNames.length !== 0) {
- var suggestions = (0, _quotedOrList2.default)(suggestedTypeNames);
- message += ' Did you mean to use an inline fragment on ' + suggestions + '?';
- } else if (suggestedFieldNames.length !== 0) {
- message += ' Did you mean ' + (0, _quotedOrList2.default)(suggestedFieldNames) + '?';
- }
- return message;
- }
- /**
- * Fields on correct type
- *
- * A GraphQL document is only valid if all fields selected are defined by the
- * parent type, or are an allowed meta field such as __typename.
- */
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function FieldsOnCorrectType(context) {
- return {
- Field: function Field(node) {
- var type = context.getParentType();
- if (type) {
- var fieldDef = context.getFieldDef();
- if (!fieldDef) {
- // This field doesn't exist, lets look for suggestions.
- var schema = context.getSchema();
- var fieldName = node.name.value;
- // First determine if there are any suggested types to condition on.
- var suggestedTypeNames = getSuggestedTypeNames(schema, type, fieldName);
- // If there are no suggested types, then perhaps this was a typo?
- var suggestedFieldNames = suggestedTypeNames.length !== 0 ? [] : getSuggestedFieldNames(schema, type, fieldName);
- // Report an error, including helpful suggestions.
- context.reportError(new _error.GraphQLError(undefinedFieldMessage(fieldName, type.name, suggestedTypeNames, suggestedFieldNames), [node]));
- }
- }
- }
- };
- }
- /**
- * Go through all of the implementations of type, as well as the interfaces
- * that they implement. If any of those types include the provided field,
- * suggest them, sorted by how often the type is referenced, starting
- * with Interfaces.
- */
- function getSuggestedTypeNames(schema, type, fieldName) {
- if (type instanceof _definition.GraphQLInterfaceType || type instanceof _definition.GraphQLUnionType) {
- var _ret = function () {
- var suggestedObjectTypes = [];
- var interfaceUsageCount = Object.create(null);
- schema.getPossibleTypes(type).forEach(function (possibleType) {
- if (!possibleType.getFields()[fieldName]) {
- return;
- }
- // This object type defines this field.
- suggestedObjectTypes.push(possibleType.name);
- possibleType.getInterfaces().forEach(function (possibleInterface) {
- if (!possibleInterface.getFields()[fieldName]) {
- return;
- }
- // This interface type defines this field.
- interfaceUsageCount[possibleInterface.name] = (interfaceUsageCount[possibleInterface.name] || 0) + 1;
- });
- });
- // Suggest interface types based on how common they are.
- var suggestedInterfaceTypes = Object.keys(interfaceUsageCount).sort(function (a, b) {
- return interfaceUsageCount[b] - interfaceUsageCount[a];
- });
- // Suggest both interface and object types.
- return {
- v: suggestedInterfaceTypes.concat(suggestedObjectTypes)
- };
- }();
- if (typeof _ret === "object") return _ret.v;
- }
- // Otherwise, must be an Object type, which does not have possible fields.
- return [];
- }
- /**
- * For the field name provided, determine if there are any similar field names
- * that may be the result of a typo.
- */
- function getSuggestedFieldNames(schema, type, fieldName) {
- if (type instanceof _definition.GraphQLObjectType || type instanceof _definition.GraphQLInterfaceType) {
- var possibleFieldNames = Object.keys(type.getFields());
- return (0, _suggestionList2.default)(fieldName, possibleFieldNames);
- }
- // Otherwise, must be a Union type, which does not define fields.
- return [];
- }
- /***/ }),
- /* 59 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.inlineFragmentOnNonCompositeErrorMessage = inlineFragmentOnNonCompositeErrorMessage;
- exports.fragmentOnNonCompositeErrorMessage = fragmentOnNonCompositeErrorMessage;
- exports.FragmentsOnCompositeTypes = FragmentsOnCompositeTypes;
- var _error = __webpack_require__(0);
- var _printer = __webpack_require__(4);
- var _definition = __webpack_require__(1);
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function inlineFragmentOnNonCompositeErrorMessage(type) {
- return 'Fragment cannot condition on non composite type "' + String(type) + '".';
- }
- function fragmentOnNonCompositeErrorMessage(fragName, type) {
- return 'Fragment "' + fragName + '" cannot condition on non composite ' + ('type "' + String(type) + '".');
- }
- /**
- * Fragments on composite type
- *
- * Fragments use a type condition to determine if they apply, since fragments
- * can only be spread into a composite type (object, interface, or union), the
- * type condition must also be a composite type.
- */
- function FragmentsOnCompositeTypes(context) {
- return {
- InlineFragment: function InlineFragment(node) {
- var type = context.getType();
- if (node.typeCondition && type && !(0, _definition.isCompositeType)(type)) {
- context.reportError(new _error.GraphQLError(inlineFragmentOnNonCompositeErrorMessage((0, _printer.print)(node.typeCondition)), [node.typeCondition]));
- }
- },
- FragmentDefinition: function FragmentDefinition(node) {
- var type = context.getType();
- if (type && !(0, _definition.isCompositeType)(type)) {
- context.reportError(new _error.GraphQLError(fragmentOnNonCompositeErrorMessage(node.name.value, (0, _printer.print)(node.typeCondition)), [node.typeCondition]));
- }
- }
- };
- }
- /***/ }),
- /* 60 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.unknownArgMessage = unknownArgMessage;
- exports.unknownDirectiveArgMessage = unknownDirectiveArgMessage;
- exports.KnownArgumentNames = KnownArgumentNames;
- var _error = __webpack_require__(0);
- var _find = __webpack_require__(10);
- var _find2 = _interopRequireDefault(_find);
- var _invariant = __webpack_require__(3);
- var _invariant2 = _interopRequireDefault(_invariant);
- var _suggestionList = __webpack_require__(23);
- var _suggestionList2 = _interopRequireDefault(_suggestionList);
- var _quotedOrList = __webpack_require__(22);
- var _quotedOrList2 = _interopRequireDefault(_quotedOrList);
- var _kinds = __webpack_require__(2);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- function unknownArgMessage(argName, fieldName, type, suggestedArgs) {
- var message = 'Unknown argument "' + argName + '" on field "' + fieldName + '" of ' + ('type "' + String(type) + '".');
- if (suggestedArgs.length) {
- message += ' Did you mean ' + (0, _quotedOrList2.default)(suggestedArgs) + '?';
- }
- return message;
- }
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function unknownDirectiveArgMessage(argName, directiveName, suggestedArgs) {
- var message = 'Unknown argument "' + argName + '" on directive "@' + directiveName + '".';
- if (suggestedArgs.length) {
- message += ' Did you mean ' + (0, _quotedOrList2.default)(suggestedArgs) + '?';
- }
- return message;
- }
- /**
- * Known argument names
- *
- * A GraphQL field is only valid if all supplied arguments are defined by
- * that field.
- */
- function KnownArgumentNames(context) {
- return {
- Argument: function Argument(node, key, parent, path, ancestors) {
- var argumentOf = ancestors[ancestors.length - 1];
- if (argumentOf.kind === _kinds.FIELD) {
- var fieldDef = context.getFieldDef();
- if (fieldDef) {
- var fieldArgDef = (0, _find2.default)(fieldDef.args, function (arg) {
- return arg.name === node.name.value;
- });
- if (!fieldArgDef) {
- var parentType = context.getParentType();
- (0, _invariant2.default)(parentType);
- context.reportError(new _error.GraphQLError(unknownArgMessage(node.name.value, fieldDef.name, parentType.name, (0, _suggestionList2.default)(node.name.value, fieldDef.args.map(function (arg) {
- return arg.name;
- }))), [node]));
- }
- }
- } else if (argumentOf.kind === _kinds.DIRECTIVE) {
- var directive = context.getDirective();
- if (directive) {
- var directiveArgDef = (0, _find2.default)(directive.args, function (arg) {
- return arg.name === node.name.value;
- });
- if (!directiveArgDef) {
- context.reportError(new _error.GraphQLError(unknownDirectiveArgMessage(node.name.value, directive.name, (0, _suggestionList2.default)(node.name.value, directive.args.map(function (arg) {
- return arg.name;
- }))), [node]));
- }
- }
- }
- }
- };
- }
- /***/ }),
- /* 61 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.unknownDirectiveMessage = unknownDirectiveMessage;
- exports.misplacedDirectiveMessage = misplacedDirectiveMessage;
- exports.KnownDirectives = KnownDirectives;
- var _error = __webpack_require__(0);
- var _find = __webpack_require__(10);
- var _find2 = _interopRequireDefault(_find);
- var _kinds = __webpack_require__(2);
- var _directives = __webpack_require__(5);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- function unknownDirectiveMessage(directiveName) {
- return 'Unknown directive "' + directiveName + '".';
- }
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function misplacedDirectiveMessage(directiveName, location) {
- return 'Directive "' + directiveName + '" may not be used on ' + location + '.';
- }
- /**
- * Known directives
- *
- * A GraphQL document is only valid if all `@directives` are known by the
- * schema and legally positioned.
- */
- function KnownDirectives(context) {
- return {
- Directive: function Directive(node, key, parent, path, ancestors) {
- var directiveDef = (0, _find2.default)(context.getSchema().getDirectives(), function (def) {
- return def.name === node.name.value;
- });
- if (!directiveDef) {
- context.reportError(new _error.GraphQLError(unknownDirectiveMessage(node.name.value), [node]));
- return;
- }
- var candidateLocation = getDirectiveLocationForASTPath(ancestors);
- if (!candidateLocation) {
- context.reportError(new _error.GraphQLError(misplacedDirectiveMessage(node.name.value, node.type), [node]));
- } else if (directiveDef.locations.indexOf(candidateLocation) === -1) {
- context.reportError(new _error.GraphQLError(misplacedDirectiveMessage(node.name.value, candidateLocation), [node]));
- }
- }
- };
- }
- function getDirectiveLocationForASTPath(ancestors) {
- var appliedTo = ancestors[ancestors.length - 1];
- switch (appliedTo.kind) {
- case _kinds.OPERATION_DEFINITION:
- switch (appliedTo.operation) {
- case 'query':
- return _directives.DirectiveLocation.QUERY;
- case 'mutation':
- return _directives.DirectiveLocation.MUTATION;
- case 'subscription':
- return _directives.DirectiveLocation.SUBSCRIPTION;
- }
- break;
- case _kinds.FIELD:
- return _directives.DirectiveLocation.FIELD;
- case _kinds.FRAGMENT_SPREAD:
- return _directives.DirectiveLocation.FRAGMENT_SPREAD;
- case _kinds.INLINE_FRAGMENT:
- return _directives.DirectiveLocation.INLINE_FRAGMENT;
- case _kinds.FRAGMENT_DEFINITION:
- return _directives.DirectiveLocation.FRAGMENT_DEFINITION;
- case _kinds.SCHEMA_DEFINITION:
- return _directives.DirectiveLocation.SCHEMA;
- case _kinds.SCALAR_TYPE_DEFINITION:
- return _directives.DirectiveLocation.SCALAR;
- case _kinds.OBJECT_TYPE_DEFINITION:
- return _directives.DirectiveLocation.OBJECT;
- case _kinds.FIELD_DEFINITION:
- return _directives.DirectiveLocation.FIELD_DEFINITION;
- case _kinds.INTERFACE_TYPE_DEFINITION:
- return _directives.DirectiveLocation.INTERFACE;
- case _kinds.UNION_TYPE_DEFINITION:
- return _directives.DirectiveLocation.UNION;
- case _kinds.ENUM_TYPE_DEFINITION:
- return _directives.DirectiveLocation.ENUM;
- case _kinds.ENUM_VALUE_DEFINITION:
- return _directives.DirectiveLocation.ENUM_VALUE;
- case _kinds.INPUT_OBJECT_TYPE_DEFINITION:
- return _directives.DirectiveLocation.INPUT_OBJECT;
- case _kinds.INPUT_VALUE_DEFINITION:
- var parentNode = ancestors[ancestors.length - 3];
- return parentNode.kind === _kinds.INPUT_OBJECT_TYPE_DEFINITION ? _directives.DirectiveLocation.INPUT_FIELD_DEFINITION : _directives.DirectiveLocation.ARGUMENT_DEFINITION;
- }
- }
- /***/ }),
- /* 62 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.unknownFragmentMessage = unknownFragmentMessage;
- exports.KnownFragmentNames = KnownFragmentNames;
- var _error = __webpack_require__(0);
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function unknownFragmentMessage(fragName) {
- return 'Unknown fragment "' + fragName + '".';
- }
- /**
- * Known fragment names
- *
- * A GraphQL document is only valid if all `...Fragment` fragment spreads refer
- * to fragments defined in the same document.
- */
- function KnownFragmentNames(context) {
- return {
- FragmentSpread: function FragmentSpread(node) {
- var fragmentName = node.name.value;
- var fragment = context.getFragment(fragmentName);
- if (!fragment) {
- context.reportError(new _error.GraphQLError(unknownFragmentMessage(fragmentName), [node.name]));
- }
- }
- };
- }
- /***/ }),
- /* 63 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.unknownTypeMessage = unknownTypeMessage;
- exports.KnownTypeNames = KnownTypeNames;
- var _error = __webpack_require__(0);
- var _suggestionList = __webpack_require__(23);
- var _suggestionList2 = _interopRequireDefault(_suggestionList);
- var _quotedOrList = __webpack_require__(22);
- var _quotedOrList2 = _interopRequireDefault(_quotedOrList);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function unknownTypeMessage(type, suggestedTypes) {
- var message = 'Unknown type "' + String(type) + '".';
- if (suggestedTypes.length) {
- message += ' Did you mean ' + (0, _quotedOrList2.default)(suggestedTypes) + '?';
- }
- return message;
- }
- /**
- * Known type names
- *
- * A GraphQL document is only valid if referenced types (specifically
- * variable definitions and fragment conditions) are defined by the type schema.
- */
- function KnownTypeNames(context) {
- return {
- // TODO: when validating IDL, re-enable these. Experimental version does not
- // add unreferenced types, resulting in false-positive errors. Squelched
- // errors for now.
- ObjectTypeDefinition: function ObjectTypeDefinition() {
- return false;
- },
- InterfaceTypeDefinition: function InterfaceTypeDefinition() {
- return false;
- },
- UnionTypeDefinition: function UnionTypeDefinition() {
- return false;
- },
- InputObjectTypeDefinition: function InputObjectTypeDefinition() {
- return false;
- },
- NamedType: function NamedType(node) {
- var schema = context.getSchema();
- var typeName = node.name.value;
- var type = schema.getType(typeName);
- if (!type) {
- context.reportError(new _error.GraphQLError(unknownTypeMessage(typeName, (0, _suggestionList2.default)(typeName, Object.keys(schema.getTypeMap()))), [node]));
- }
- }
- };
- }
- /***/ }),
- /* 64 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.anonOperationNotAloneMessage = anonOperationNotAloneMessage;
- exports.LoneAnonymousOperation = LoneAnonymousOperation;
- var _error = __webpack_require__(0);
- var _kinds = __webpack_require__(2);
- function anonOperationNotAloneMessage() {
- return 'This anonymous operation must be the only defined operation.';
- }
- /**
- * Lone anonymous operation
- *
- * A GraphQL document is only valid if when it contains an anonymous operation
- * (the query short-hand) that it contains only that one operation definition.
- */
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function LoneAnonymousOperation(context) {
- var operationCount = 0;
- return {
- Document: function Document(node) {
- operationCount = node.definitions.filter(function (definition) {
- return definition.kind === _kinds.OPERATION_DEFINITION;
- }).length;
- },
- OperationDefinition: function OperationDefinition(node) {
- if (!node.name && operationCount > 1) {
- context.reportError(new _error.GraphQLError(anonOperationNotAloneMessage(), [node]));
- }
- }
- };
- }
- /***/ }),
- /* 65 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.cycleErrorMessage = cycleErrorMessage;
- exports.NoFragmentCycles = NoFragmentCycles;
- var _error = __webpack_require__(0);
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function cycleErrorMessage(fragName, spreadNames) {
- var via = spreadNames.length ? ' via ' + spreadNames.join(', ') : '';
- return 'Cannot spread fragment "' + fragName + '" within itself' + via + '.';
- }
- function NoFragmentCycles(context) {
- // Tracks already visited fragments to maintain O(N) and to ensure that cycles
- // are not redundantly reported.
- var visitedFrags = Object.create(null);
- // Array of AST nodes used to produce meaningful errors
- var spreadPath = [];
- // Position in the spread path
- var spreadPathIndexByName = Object.create(null);
- return {
- OperationDefinition: function OperationDefinition() {
- return false;
- },
- FragmentDefinition: function FragmentDefinition(node) {
- if (!visitedFrags[node.name.value]) {
- detectCycleRecursive(node);
- }
- return false;
- }
- };
- // This does a straight-forward DFS to find cycles.
- // It does not terminate when a cycle was found but continues to explore
- // the graph to find all possible cycles.
- function detectCycleRecursive(fragment) {
- var fragmentName = fragment.name.value;
- visitedFrags[fragmentName] = true;
- var spreadNodes = context.getFragmentSpreads(fragment.selectionSet);
- if (spreadNodes.length === 0) {
- return;
- }
- spreadPathIndexByName[fragmentName] = spreadPath.length;
- for (var i = 0; i < spreadNodes.length; i++) {
- var spreadNode = spreadNodes[i];
- var spreadName = spreadNode.name.value;
- var cycleIndex = spreadPathIndexByName[spreadName];
- if (cycleIndex === undefined) {
- spreadPath.push(spreadNode);
- if (!visitedFrags[spreadName]) {
- var spreadFragment = context.getFragment(spreadName);
- if (spreadFragment) {
- detectCycleRecursive(spreadFragment);
- }
- }
- spreadPath.pop();
- } else {
- var cyclePath = spreadPath.slice(cycleIndex);
- context.reportError(new _error.GraphQLError(cycleErrorMessage(spreadName, cyclePath.map(function (s) {
- return s.name.value;
- })), cyclePath.concat(spreadNode)));
- }
- }
- spreadPathIndexByName[fragmentName] = undefined;
- }
- }
- /***/ }),
- /* 66 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.undefinedVarMessage = undefinedVarMessage;
- exports.NoUndefinedVariables = NoUndefinedVariables;
- var _error = __webpack_require__(0);
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function undefinedVarMessage(varName, opName) {
- return opName ? 'Variable "$' + varName + '" is not defined by operation "' + opName + '".' : 'Variable "$' + varName + '" is not defined.';
- }
- /**
- * No undefined variables
- *
- * A GraphQL operation is only valid if all variables encountered, both directly
- * and via fragment spreads, are defined by that operation.
- */
- function NoUndefinedVariables(context) {
- var variableNameDefined = Object.create(null);
- return {
- OperationDefinition: {
- enter: function enter() {
- variableNameDefined = Object.create(null);
- },
- leave: function leave(operation) {
- var usages = context.getRecursiveVariableUsages(operation);
- usages.forEach(function (_ref) {
- var node = _ref.node;
- var varName = node.name.value;
- if (variableNameDefined[varName] !== true) {
- context.reportError(new _error.GraphQLError(undefinedVarMessage(varName, operation.name && operation.name.value), [node, operation]));
- }
- });
- }
- },
- VariableDefinition: function VariableDefinition(node) {
- variableNameDefined[node.variable.name.value] = true;
- }
- };
- }
- /***/ }),
- /* 67 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.unusedFragMessage = unusedFragMessage;
- exports.NoUnusedFragments = NoUnusedFragments;
- var _error = __webpack_require__(0);
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function unusedFragMessage(fragName) {
- return 'Fragment "' + fragName + '" is never used.';
- }
- /**
- * No unused fragments
- *
- * A GraphQL document is only valid if all fragment definitions are spread
- * within operations, or spread within other fragments spread within operations.
- */
- function NoUnusedFragments(context) {
- var operationDefs = [];
- var fragmentDefs = [];
- return {
- OperationDefinition: function OperationDefinition(node) {
- operationDefs.push(node);
- return false;
- },
- FragmentDefinition: function FragmentDefinition(node) {
- fragmentDefs.push(node);
- return false;
- },
- Document: {
- leave: function leave() {
- var fragmentNameUsed = Object.create(null);
- operationDefs.forEach(function (operation) {
- context.getRecursivelyReferencedFragments(operation).forEach(function (fragment) {
- fragmentNameUsed[fragment.name.value] = true;
- });
- });
- fragmentDefs.forEach(function (fragmentDef) {
- var fragName = fragmentDef.name.value;
- if (fragmentNameUsed[fragName] !== true) {
- context.reportError(new _error.GraphQLError(unusedFragMessage(fragName), [fragmentDef]));
- }
- });
- }
- }
- };
- }
- /***/ }),
- /* 68 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.unusedVariableMessage = unusedVariableMessage;
- exports.NoUnusedVariables = NoUnusedVariables;
- var _error = __webpack_require__(0);
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function unusedVariableMessage(varName, opName) {
- return opName ? 'Variable "$' + varName + '" is never used in operation "' + opName + '".' : 'Variable "$' + varName + '" is never used.';
- }
- /**
- * No unused variables
- *
- * A GraphQL operation is only valid if all variables defined by an operation
- * are used, either directly or within a spread fragment.
- */
- function NoUnusedVariables(context) {
- var variableDefs = [];
- return {
- OperationDefinition: {
- enter: function enter() {
- variableDefs = [];
- },
- leave: function leave(operation) {
- var variableNameUsed = Object.create(null);
- var usages = context.getRecursiveVariableUsages(operation);
- var opName = operation.name ? operation.name.value : null;
- usages.forEach(function (_ref) {
- var node = _ref.node;
- variableNameUsed[node.name.value] = true;
- });
- variableDefs.forEach(function (variableDef) {
- var variableName = variableDef.variable.name.value;
- if (variableNameUsed[variableName] !== true) {
- context.reportError(new _error.GraphQLError(unusedVariableMessage(variableName, opName), [variableDef]));
- }
- });
- }
- },
- VariableDefinition: function VariableDefinition(def) {
- variableDefs.push(def);
- }
- };
- }
- /***/ }),
- /* 69 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.fieldsConflictMessage = fieldsConflictMessage;
- exports.OverlappingFieldsCanBeMerged = OverlappingFieldsCanBeMerged;
- var _error = __webpack_require__(0);
- var _find = __webpack_require__(10);
- var _find2 = _interopRequireDefault(_find);
- var _kinds = __webpack_require__(2);
- var _printer = __webpack_require__(4);
- var _definition = __webpack_require__(1);
- var _typeFromAST = __webpack_require__(9);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function fieldsConflictMessage(responseName, reason) {
- return 'Fields "' + responseName + '" conflict because ' + reasonMessage(reason) + '. Use different aliases on the fields to fetch both if this was ' + 'intentional.';
- }
- function reasonMessage(reason) {
- if (Array.isArray(reason)) {
- return reason.map(function (_ref) {
- var responseName = _ref[0],
- subreason = _ref[1];
- return 'subfields "' + responseName + '" conflict because ' + reasonMessage(subreason);
- }).join(' and ');
- }
- return reason;
- }
- /**
- * Overlapping fields can be merged
- *
- * A selection set is only valid if all fields (including spreading any
- * fragments) either correspond to distinct response names or can be merged
- * without ambiguity.
- */
- function OverlappingFieldsCanBeMerged(context) {
- // A memoization for when two fragments are compared "between" each other for
- // conflicts. Two fragments may be compared many times, so memoizing this can
- // dramatically improve the performance of this validator.
- var comparedFragments = new PairSet();
- // A cache for the "field map" and list of fragment names found in any given
- // selection set. Selection sets may be asked for this information multiple
- // times, so this improves the performance of this validator.
- var cachedFieldsAndFragmentNames = new Map();
- return {
- SelectionSet: function SelectionSet(selectionSet) {
- var conflicts = findConflictsWithinSelectionSet(context, cachedFieldsAndFragmentNames, comparedFragments, context.getParentType(), selectionSet);
- conflicts.forEach(function (_ref2) {
- var _ref2$ = _ref2[0],
- responseName = _ref2$[0],
- reason = _ref2$[1],
- fields1 = _ref2[1],
- fields2 = _ref2[2];
- return context.reportError(new _error.GraphQLError(fieldsConflictMessage(responseName, reason), fields1.concat(fields2)));
- });
- }
- };
- }
- // Field name and reason.
- // Reason is a string, or a nested list of conflicts.
- // Tuple defining a field node in a context.
- // Map of array of those.
- /**
- * Algorithm:
- *
- * Conflicts occur when two fields exist in a query which will produce the same
- * response name, but represent differing values, thus creating a conflict.
- * The algorithm below finds all conflicts via making a series of comparisons
- * between fields. In order to compare as few fields as possible, this makes
- * a series of comparisons "within" sets of fields and "between" sets of fields.
- *
- * Given any selection set, a collection produces both a set of fields by
- * also including all inline fragments, as well as a list of fragments
- * referenced by fragment spreads.
- *
- * A) Each selection set represented in the document first compares "within" its
- * collected set of fields, finding any conflicts between every pair of
- * overlapping fields.
- * Note: This is the *only time* that a the fields "within" a set are compared
- * to each other. After this only fields "between" sets are compared.
- *
- * B) Also, if any fragment is referenced in a selection set, then a
- * comparison is made "between" the original set of fields and the
- * referenced fragment.
- *
- * C) Also, if multiple fragments are referenced, then comparisons
- * are made "between" each referenced fragment.
- *
- * D) When comparing "between" a set of fields and a referenced fragment, first
- * a comparison is made between each field in the original set of fields and
- * each field in the the referenced set of fields.
- *
- * E) Also, if any fragment is referenced in the referenced selection set,
- * then a comparison is made "between" the original set of fields and the
- * referenced fragment (recursively referring to step D).
- *
- * F) When comparing "between" two fragments, first a comparison is made between
- * each field in the first referenced set of fields and each field in the the
- * second referenced set of fields.
- *
- * G) Also, any fragments referenced by the first must be compared to the
- * second, and any fragments referenced by the second must be compared to the
- * first (recursively referring to step F).
- *
- * H) When comparing two fields, if both have selection sets, then a comparison
- * is made "between" both selection sets, first comparing the set of fields in
- * the first selection set with the set of fields in the second.
- *
- * I) Also, if any fragment is referenced in either selection set, then a
- * comparison is made "between" the other set of fields and the
- * referenced fragment.
- *
- * J) Also, if two fragments are referenced in both selection sets, then a
- * comparison is made "between" the two fragments.
- *
- */
- // Find all conflicts found "within" a selection set, including those found
- // via spreading in fragments. Called when visiting each SelectionSet in the
- // GraphQL Document.
- function findConflictsWithinSelectionSet(context, cachedFieldsAndFragmentNames, comparedFragments, parentType, selectionSet) {
- var conflicts = [];
- var _getFieldsAndFragment = getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, parentType, selectionSet),
- fieldMap = _getFieldsAndFragment[0],
- fragmentNames = _getFieldsAndFragment[1];
- // (A) Find find all conflicts "within" the fields of this selection set.
- // Note: this is the *only place* `collectConflictsWithin` is called.
- collectConflictsWithin(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, fieldMap);
- // (B) Then collect conflicts between these fields and those represented by
- // each spread fragment name found.
- for (var i = 0; i < fragmentNames.length; i++) {
- collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, false, fieldMap, fragmentNames[i]);
- // (C) Then compare this fragment with all other fragments found in this
- // selection set to collect conflicts between fragments spread together.
- // This compares each item in the list of fragment names to every other item
- // in that same list (except for itself).
- for (var j = i + 1; j < fragmentNames.length; j++) {
- collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, false, fragmentNames[i], fragmentNames[j]);
- }
- }
- return conflicts;
- }
- // Collect all conflicts found between a set of fields and a fragment reference
- // including via spreading in any nested fragments.
- function collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fieldMap, fragmentName) {
- var fragment = context.getFragment(fragmentName);
- if (!fragment) {
- return;
- }
- var _getReferencedFieldsA = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment),
- fieldMap2 = _getReferencedFieldsA[0],
- fragmentNames2 = _getReferencedFieldsA[1];
- // (D) First collect any conflicts between the provided collection of fields
- // and the collection of fields represented by the given fragment.
- collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fieldMap, fieldMap2);
- // (E) Then collect any conflicts between the provided collection of fields
- // and any fragment names found in the given fragment.
- for (var i = 0; i < fragmentNames2.length; i++) {
- collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fieldMap, fragmentNames2[i]);
- }
- }
- // Collect all conflicts found between two fragments, including via spreading in
- // any nested fragments.
- function collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fragmentName1, fragmentName2) {
- var fragment1 = context.getFragment(fragmentName1);
- var fragment2 = context.getFragment(fragmentName2);
- if (!fragment1 || !fragment2) {
- return;
- }
- // No need to compare a fragment to itself.
- if (fragment1 === fragment2) {
- return;
- }
- // Memoize so two fragments are not compared for conflicts more than once.
- if (comparedFragments.has(fragmentName1, fragmentName2, areMutuallyExclusive)) {
- return;
- }
- comparedFragments.add(fragmentName1, fragmentName2, areMutuallyExclusive);
- var _getReferencedFieldsA2 = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment1),
- fieldMap1 = _getReferencedFieldsA2[0],
- fragmentNames1 = _getReferencedFieldsA2[1];
- var _getReferencedFieldsA3 = getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment2),
- fieldMap2 = _getReferencedFieldsA3[0],
- fragmentNames2 = _getReferencedFieldsA3[1];
- // (F) First, collect all conflicts between these two collections of fields
- // (not including any nested fragments).
- collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fieldMap1, fieldMap2);
- // (G) Then collect conflicts between the first fragment and any nested
- // fragments spread in the second fragment.
- for (var j = 0; j < fragmentNames2.length; j++) {
- collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fragmentName1, fragmentNames2[j]);
- }
- // (G) Then collect conflicts between the second fragment and any nested
- // fragments spread in the first fragment.
- for (var i = 0; i < fragmentNames1.length; i++) {
- collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fragmentNames1[i], fragmentName2);
- }
- }
- // Find all conflicts found between two selection sets, including those found
- // via spreading in fragments. Called when determining if conflicts exist
- // between the sub-fields of two overlapping fields.
- function findConflictsBetweenSubSelectionSets(context, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, parentType1, selectionSet1, parentType2, selectionSet2) {
- var conflicts = [];
- var _getFieldsAndFragment2 = getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, parentType1, selectionSet1),
- fieldMap1 = _getFieldsAndFragment2[0],
- fragmentNames1 = _getFieldsAndFragment2[1];
- var _getFieldsAndFragment3 = getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, parentType2, selectionSet2),
- fieldMap2 = _getFieldsAndFragment3[0],
- fragmentNames2 = _getFieldsAndFragment3[1];
- // (H) First, collect all conflicts between these two collections of field.
- collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fieldMap1, fieldMap2);
- // (I) Then collect conflicts between the first collection of fields and
- // those referenced by each fragment name associated with the second.
- for (var j = 0; j < fragmentNames2.length; j++) {
- collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fieldMap1, fragmentNames2[j]);
- }
- // (I) Then collect conflicts between the second collection of fields and
- // those referenced by each fragment name associated with the first.
- for (var i = 0; i < fragmentNames1.length; i++) {
- collectConflictsBetweenFieldsAndFragment(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fieldMap2, fragmentNames1[i]);
- }
- // (J) Also collect conflicts between any fragment names by the first and
- // fragment names by the second. This compares each item in the first set of
- // names to each item in the second set of names.
- for (var _i = 0; _i < fragmentNames1.length; _i++) {
- for (var _j = 0; _j < fragmentNames2.length; _j++) {
- collectConflictsBetweenFragments(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, fragmentNames1[_i], fragmentNames2[_j]);
- }
- }
- return conflicts;
- }
- // Collect all Conflicts "within" one collection of fields.
- function collectConflictsWithin(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, fieldMap) {
- // A field map is a keyed collection, where each key represents a response
- // name and the value at that key is a list of all fields which provide that
- // response name. For every response name, if there are multiple fields, they
- // must be compared to find a potential conflict.
- Object.keys(fieldMap).forEach(function (responseName) {
- var fields = fieldMap[responseName];
- // This compares every field in the list to every other field in this list
- // (except to itself). If the list only has one item, nothing needs to
- // be compared.
- if (fields.length > 1) {
- for (var i = 0; i < fields.length; i++) {
- for (var j = i + 1; j < fields.length; j++) {
- var conflict = findConflict(context, cachedFieldsAndFragmentNames, comparedFragments, false, // within one collection is never mutually exclusive
- responseName, fields[i], fields[j]);
- if (conflict) {
- conflicts.push(conflict);
- }
- }
- }
- }
- });
- }
- // Collect all Conflicts between two collections of fields. This is similar to,
- // but different from the `collectConflictsWithin` function above. This check
- // assumes that `collectConflictsWithin` has already been called on each
- // provided collection of fields. This is true because this validator traverses
- // each individual selection set.
- function collectConflictsBetween(context, conflicts, cachedFieldsAndFragmentNames, comparedFragments, parentFieldsAreMutuallyExclusive, fieldMap1, fieldMap2) {
- // A field map is a keyed collection, where each key represents a response
- // name and the value at that key is a list of all fields which provide that
- // response name. For any response name which appears in both provided field
- // maps, each field from the first field map must be compared to every field
- // in the second field map to find potential conflicts.
- Object.keys(fieldMap1).forEach(function (responseName) {
- var fields2 = fieldMap2[responseName];
- if (fields2) {
- var fields1 = fieldMap1[responseName];
- for (var i = 0; i < fields1.length; i++) {
- for (var j = 0; j < fields2.length; j++) {
- var conflict = findConflict(context, cachedFieldsAndFragmentNames, comparedFragments, parentFieldsAreMutuallyExclusive, responseName, fields1[i], fields2[j]);
- if (conflict) {
- conflicts.push(conflict);
- }
- }
- }
- }
- });
- }
- // Determines if there is a conflict between two particular fields, including
- // comparing their sub-fields.
- function findConflict(context, cachedFieldsAndFragmentNames, comparedFragments, parentFieldsAreMutuallyExclusive, responseName, field1, field2) {
- var parentType1 = field1[0],
- node1 = field1[1],
- def1 = field1[2];
- var parentType2 = field2[0],
- node2 = field2[1],
- def2 = field2[2];
- // If it is known that two fields could not possibly apply at the same
- // time, due to the parent types, then it is safe to permit them to diverge
- // in aliased field or arguments used as they will not present any ambiguity
- // by differing.
- // It is known that two parent types could never overlap if they are
- // different Object types. Interface or Union types might overlap - if not
- // in the current state of the schema, then perhaps in some future version,
- // thus may not safely diverge.
- var areMutuallyExclusive = parentFieldsAreMutuallyExclusive || parentType1 !== parentType2 && parentType1 instanceof _definition.GraphQLObjectType && parentType2 instanceof _definition.GraphQLObjectType;
- // The return type for each field.
- var type1 = def1 && def1.type;
- var type2 = def2 && def2.type;
- if (!areMutuallyExclusive) {
- // Two aliases must refer to the same field.
- var name1 = node1.name.value;
- var name2 = node2.name.value;
- if (name1 !== name2) {
- return [[responseName, name1 + ' and ' + name2 + ' are different fields'], [node1], [node2]];
- }
- // Two field calls must have the same arguments.
- if (!sameArguments(node1.arguments || [], node2.arguments || [])) {
- return [[responseName, 'they have differing arguments'], [node1], [node2]];
- }
- }
- if (type1 && type2 && doTypesConflict(type1, type2)) {
- return [[responseName, 'they return conflicting types ' + String(type1) + ' and ' + String(type2)], [node1], [node2]];
- }
- // Collect and compare sub-fields. Use the same "visited fragment names" list
- // for both collections so fields in a fragment reference are never
- // compared to themselves.
- var selectionSet1 = node1.selectionSet;
- var selectionSet2 = node2.selectionSet;
- if (selectionSet1 && selectionSet2) {
- var conflicts = findConflictsBetweenSubSelectionSets(context, cachedFieldsAndFragmentNames, comparedFragments, areMutuallyExclusive, (0, _definition.getNamedType)(type1), selectionSet1, (0, _definition.getNamedType)(type2), selectionSet2);
- return subfieldConflicts(conflicts, responseName, node1, node2);
- }
- }
- function sameArguments(arguments1, arguments2) {
- if (arguments1.length !== arguments2.length) {
- return false;
- }
- return arguments1.every(function (argument1) {
- var argument2 = (0, _find2.default)(arguments2, function (argument) {
- return argument.name.value === argument1.name.value;
- });
- if (!argument2) {
- return false;
- }
- return sameValue(argument1.value, argument2.value);
- });
- }
- function sameValue(value1, value2) {
- return !value1 && !value2 || (0, _printer.print)(value1) === (0, _printer.print)(value2);
- }
- // Two types conflict if both types could not apply to a value simultaneously.
- // Composite types are ignored as their individual field types will be compared
- // later recursively. However List and Non-Null types must match.
- function doTypesConflict(type1, type2) {
- if (type1 instanceof _definition.GraphQLList) {
- return type2 instanceof _definition.GraphQLList ? doTypesConflict(type1.ofType, type2.ofType) : true;
- }
- if (type2 instanceof _definition.GraphQLList) {
- return type1 instanceof _definition.GraphQLList ? doTypesConflict(type1.ofType, type2.ofType) : true;
- }
- if (type1 instanceof _definition.GraphQLNonNull) {
- return type2 instanceof _definition.GraphQLNonNull ? doTypesConflict(type1.ofType, type2.ofType) : true;
- }
- if (type2 instanceof _definition.GraphQLNonNull) {
- return type1 instanceof _definition.GraphQLNonNull ? doTypesConflict(type1.ofType, type2.ofType) : true;
- }
- if ((0, _definition.isLeafType)(type1) || (0, _definition.isLeafType)(type2)) {
- return type1 !== type2;
- }
- return false;
- }
- // Given a selection set, return the collection of fields (a mapping of response
- // name to field nodes and definitions) as well as a list of fragment names
- // referenced via fragment spreads.
- function getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, parentType, selectionSet) {
- var cached = cachedFieldsAndFragmentNames.get(selectionSet);
- if (!cached) {
- var nodeAndDefs = {};
- var fragmentNames = {};
- _collectFieldsAndFragmentNames(context, parentType, selectionSet, nodeAndDefs, fragmentNames);
- cached = [nodeAndDefs, Object.keys(fragmentNames)];
- cachedFieldsAndFragmentNames.set(selectionSet, cached);
- }
- return cached;
- }
- // Given a reference to a fragment, return the represented collection of fields
- // as well as a list of nested fragment names referenced via fragment spreads.
- function getReferencedFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragment) {
- // Short-circuit building a type from the node if possible.
- var cached = cachedFieldsAndFragmentNames.get(fragment.selectionSet);
- if (cached) {
- return cached;
- }
- var fragmentType = (0, _typeFromAST.typeFromAST)(context.getSchema(), fragment.typeCondition);
- return getFieldsAndFragmentNames(context, cachedFieldsAndFragmentNames, fragmentType, fragment.selectionSet);
- }
- function _collectFieldsAndFragmentNames(context, parentType, selectionSet, nodeAndDefs, fragmentNames) {
- for (var i = 0; i < selectionSet.selections.length; i++) {
- var selection = selectionSet.selections[i];
- switch (selection.kind) {
- case _kinds.FIELD:
- var fieldName = selection.name.value;
- var fieldDef = void 0;
- if (parentType instanceof _definition.GraphQLObjectType || parentType instanceof _definition.GraphQLInterfaceType) {
- fieldDef = parentType.getFields()[fieldName];
- }
- var responseName = selection.alias ? selection.alias.value : fieldName;
- if (!nodeAndDefs[responseName]) {
- nodeAndDefs[responseName] = [];
- }
- nodeAndDefs[responseName].push([parentType, selection, fieldDef]);
- break;
- case _kinds.FRAGMENT_SPREAD:
- fragmentNames[selection.name.value] = true;
- break;
- case _kinds.INLINE_FRAGMENT:
- var typeCondition = selection.typeCondition;
- var inlineFragmentType = typeCondition ? (0, _typeFromAST.typeFromAST)(context.getSchema(), typeCondition) : parentType;
- _collectFieldsAndFragmentNames(context, inlineFragmentType, selection.selectionSet, nodeAndDefs, fragmentNames);
- break;
- }
- }
- }
- // Given a series of Conflicts which occurred between two sub-fields, generate
- // a single Conflict.
- function subfieldConflicts(conflicts, responseName, node1, node2) {
- if (conflicts.length > 0) {
- return [[responseName, conflicts.map(function (_ref3) {
- var reason = _ref3[0];
- return reason;
- })], conflicts.reduce(function (allFields, _ref4) {
- var fields1 = _ref4[1];
- return allFields.concat(fields1);
- }, [node1]), conflicts.reduce(function (allFields, _ref5) {
- var fields2 = _ref5[2];
- return allFields.concat(fields2);
- }, [node2])];
- }
- }
- /**
- * A way to keep track of pairs of things when the ordering of the pair does
- * not matter. We do this by maintaining a sort of double adjacency sets.
- */
- var PairSet = function () {
- function PairSet() {
- _classCallCheck(this, PairSet);
- this._data = Object.create(null);
- }
- PairSet.prototype.has = function has(a, b, areMutuallyExclusive) {
- var first = this._data[a];
- var result = first && first[b];
- if (result === undefined) {
- return false;
- }
- // areMutuallyExclusive being false is a superset of being true,
- // hence if we want to know if this PairSet "has" these two with no
- // exclusivity, we have to ensure it was added as such.
- if (areMutuallyExclusive === false) {
- return result === false;
- }
- return true;
- };
- PairSet.prototype.add = function add(a, b, areMutuallyExclusive) {
- _pairSetAdd(this._data, a, b, areMutuallyExclusive);
- _pairSetAdd(this._data, b, a, areMutuallyExclusive);
- };
- return PairSet;
- }();
- function _pairSetAdd(data, a, b, areMutuallyExclusive) {
- var map = data[a];
- if (!map) {
- map = Object.create(null);
- data[a] = map;
- }
- map[b] = areMutuallyExclusive;
- }
- /***/ }),
- /* 70 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.typeIncompatibleSpreadMessage = typeIncompatibleSpreadMessage;
- exports.typeIncompatibleAnonSpreadMessage = typeIncompatibleAnonSpreadMessage;
- exports.PossibleFragmentSpreads = PossibleFragmentSpreads;
- var _error = __webpack_require__(0);
- var _typeComparators = __webpack_require__(19);
- var _typeFromAST = __webpack_require__(9);
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function typeIncompatibleSpreadMessage(fragName, parentType, fragType) {
- return 'Fragment "' + fragName + '" cannot be spread here as objects of ' + ('type "' + String(parentType) + '" can never be of type "' + String(fragType) + '".');
- }
- function typeIncompatibleAnonSpreadMessage(parentType, fragType) {
- return 'Fragment cannot be spread here as objects of ' + ('type "' + String(parentType) + '" can never be of type "' + String(fragType) + '".');
- }
- /**
- * Possible fragment spread
- *
- * A fragment spread is only valid if the type condition could ever possibly
- * be true: if there is a non-empty intersection of the possible parent types,
- * and possible types which pass the type condition.
- */
- function PossibleFragmentSpreads(context) {
- return {
- InlineFragment: function InlineFragment(node) {
- var fragType = context.getType();
- var parentType = context.getParentType();
- if (fragType && parentType && !(0, _typeComparators.doTypesOverlap)(context.getSchema(), fragType, parentType)) {
- context.reportError(new _error.GraphQLError(typeIncompatibleAnonSpreadMessage(parentType, fragType), [node]));
- }
- },
- FragmentSpread: function FragmentSpread(node) {
- var fragName = node.name.value;
- var fragType = getFragmentType(context, fragName);
- var parentType = context.getParentType();
- if (fragType && parentType && !(0, _typeComparators.doTypesOverlap)(context.getSchema(), fragType, parentType)) {
- context.reportError(new _error.GraphQLError(typeIncompatibleSpreadMessage(fragName, parentType, fragType), [node]));
- }
- }
- };
- }
- function getFragmentType(context, name) {
- var frag = context.getFragment(name);
- return frag && (0, _typeFromAST.typeFromAST)(context.getSchema(), frag.typeCondition);
- }
- /***/ }),
- /* 71 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.missingFieldArgMessage = missingFieldArgMessage;
- exports.missingDirectiveArgMessage = missingDirectiveArgMessage;
- exports.ProvidedNonNullArguments = ProvidedNonNullArguments;
- var _error = __webpack_require__(0);
- var _keyMap = __webpack_require__(12);
- var _keyMap2 = _interopRequireDefault(_keyMap);
- var _definition = __webpack_require__(1);
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function missingFieldArgMessage(fieldName, argName, type) {
- return 'Field "' + fieldName + '" argument "' + argName + '" of type ' + ('"' + String(type) + '" is required but not provided.');
- }
- function missingDirectiveArgMessage(directiveName, argName, type) {
- return 'Directive "@' + directiveName + '" argument "' + argName + '" of type ' + ('"' + String(type) + '" is required but not provided.');
- }
- /**
- * Provided required arguments
- *
- * A field or directive is only valid if all required (non-null) field arguments
- * have been provided.
- */
- function ProvidedNonNullArguments(context) {
- return {
- Field: {
- // Validate on leave to allow for deeper errors to appear first.
- leave: function leave(node) {
- var fieldDef = context.getFieldDef();
- if (!fieldDef) {
- return false;
- }
- var argNodes = node.arguments || [];
- var argNodeMap = (0, _keyMap2.default)(argNodes, function (arg) {
- return arg.name.value;
- });
- fieldDef.args.forEach(function (argDef) {
- var argNode = argNodeMap[argDef.name];
- if (!argNode && argDef.type instanceof _definition.GraphQLNonNull) {
- context.reportError(new _error.GraphQLError(missingFieldArgMessage(node.name.value, argDef.name, argDef.type), [node]));
- }
- });
- }
- },
- Directive: {
- // Validate on leave to allow for deeper errors to appear first.
- leave: function leave(node) {
- var directiveDef = context.getDirective();
- if (!directiveDef) {
- return false;
- }
- var argNodes = node.arguments || [];
- var argNodeMap = (0, _keyMap2.default)(argNodes, function (arg) {
- return arg.name.value;
- });
- directiveDef.args.forEach(function (argDef) {
- var argNode = argNodeMap[argDef.name];
- if (!argNode && argDef.type instanceof _definition.GraphQLNonNull) {
- context.reportError(new _error.GraphQLError(missingDirectiveArgMessage(node.name.value, argDef.name, argDef.type), [node]));
- }
- });
- }
- }
- };
- }
- /***/ }),
- /* 72 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.noSubselectionAllowedMessage = noSubselectionAllowedMessage;
- exports.requiredSubselectionMessage = requiredSubselectionMessage;
- exports.ScalarLeafs = ScalarLeafs;
- var _error = __webpack_require__(0);
- var _definition = __webpack_require__(1);
- function noSubselectionAllowedMessage(fieldName, type) {
- return 'Field "' + fieldName + '" must not have a selection since ' + ('type "' + String(type) + '" has no subfields.');
- }
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function requiredSubselectionMessage(fieldName, type) {
- return 'Field "' + fieldName + '" of type "' + String(type) + '" must have a ' + ('selection of subfields. Did you mean "' + fieldName + ' { ... }"?');
- }
- /**
- * Scalar leafs
- *
- * A GraphQL document is valid only if all leaf fields (fields without
- * sub selections) are of scalar or enum types.
- */
- function ScalarLeafs(context) {
- return {
- Field: function Field(node) {
- var type = context.getType();
- if (type) {
- if ((0, _definition.isLeafType)(type)) {
- if (node.selectionSet) {
- context.reportError(new _error.GraphQLError(noSubselectionAllowedMessage(node.name.value, type), [node.selectionSet]));
- }
- } else if (!node.selectionSet) {
- context.reportError(new _error.GraphQLError(requiredSubselectionMessage(node.name.value, type), [node]));
- }
- }
- }
- };
- }
- /***/ }),
- /* 73 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.duplicateArgMessage = duplicateArgMessage;
- exports.UniqueArgumentNames = UniqueArgumentNames;
- var _error = __webpack_require__(0);
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function duplicateArgMessage(argName) {
- return 'There can be only one argument named "' + argName + '".';
- }
- /**
- * Unique argument names
- *
- * A GraphQL field or directive is only valid if all supplied arguments are
- * uniquely named.
- */
- function UniqueArgumentNames(context) {
- var knownArgNames = Object.create(null);
- return {
- Field: function Field() {
- knownArgNames = Object.create(null);
- },
- Directive: function Directive() {
- knownArgNames = Object.create(null);
- },
- Argument: function Argument(node) {
- var argName = node.name.value;
- if (knownArgNames[argName]) {
- context.reportError(new _error.GraphQLError(duplicateArgMessage(argName), [knownArgNames[argName], node.name]));
- } else {
- knownArgNames[argName] = node.name;
- }
- return false;
- }
- };
- }
- /***/ }),
- /* 74 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.duplicateDirectiveMessage = duplicateDirectiveMessage;
- exports.UniqueDirectivesPerLocation = UniqueDirectivesPerLocation;
- var _error = __webpack_require__(0);
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function duplicateDirectiveMessage(directiveName) {
- return 'The directive "' + directiveName + '" can only be used once at ' + 'this location.';
- }
- /**
- * Unique directive names per location
- *
- * A GraphQL document is only valid if all directives at a given location
- * are uniquely named.
- */
- function UniqueDirectivesPerLocation(context) {
- return {
- // Many different AST nodes may contain directives. Rather than listing
- // them all, just listen for entering any node, and check to see if it
- // defines any directives.
- enter: function enter(node) {
- if (node.directives) {
- (function () {
- var knownDirectives = Object.create(null);
- node.directives.forEach(function (directive) {
- var directiveName = directive.name.value;
- if (knownDirectives[directiveName]) {
- context.reportError(new _error.GraphQLError(duplicateDirectiveMessage(directiveName), [knownDirectives[directiveName], directive]));
- } else {
- knownDirectives[directiveName] = directive;
- }
- });
- })();
- }
- }
- };
- }
- /***/ }),
- /* 75 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.duplicateFragmentNameMessage = duplicateFragmentNameMessage;
- exports.UniqueFragmentNames = UniqueFragmentNames;
- var _error = __webpack_require__(0);
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function duplicateFragmentNameMessage(fragName) {
- return 'There can only be one fragment named "' + fragName + '".';
- }
- /**
- * Unique fragment names
- *
- * A GraphQL document is only valid if all defined fragments have unique names.
- */
- function UniqueFragmentNames(context) {
- var knownFragmentNames = Object.create(null);
- return {
- OperationDefinition: function OperationDefinition() {
- return false;
- },
- FragmentDefinition: function FragmentDefinition(node) {
- var fragmentName = node.name.value;
- if (knownFragmentNames[fragmentName]) {
- context.reportError(new _error.GraphQLError(duplicateFragmentNameMessage(fragmentName), [knownFragmentNames[fragmentName], node.name]));
- } else {
- knownFragmentNames[fragmentName] = node.name;
- }
- return false;
- }
- };
- }
- /***/ }),
- /* 76 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.duplicateInputFieldMessage = duplicateInputFieldMessage;
- exports.UniqueInputFieldNames = UniqueInputFieldNames;
- var _error = __webpack_require__(0);
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function duplicateInputFieldMessage(fieldName) {
- return 'There can be only one input field named "' + fieldName + '".';
- }
- /**
- * Unique input field names
- *
- * A GraphQL input object value is only valid if all supplied fields are
- * uniquely named.
- */
- function UniqueInputFieldNames(context) {
- var knownNameStack = [];
- var knownNames = Object.create(null);
- return {
- ObjectValue: {
- enter: function enter() {
- knownNameStack.push(knownNames);
- knownNames = Object.create(null);
- },
- leave: function leave() {
- knownNames = knownNameStack.pop();
- }
- },
- ObjectField: function ObjectField(node) {
- var fieldName = node.name.value;
- if (knownNames[fieldName]) {
- context.reportError(new _error.GraphQLError(duplicateInputFieldMessage(fieldName), [knownNames[fieldName], node.name]));
- } else {
- knownNames[fieldName] = node.name;
- }
- return false;
- }
- };
- }
- /***/ }),
- /* 77 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.duplicateOperationNameMessage = duplicateOperationNameMessage;
- exports.UniqueOperationNames = UniqueOperationNames;
- var _error = __webpack_require__(0);
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function duplicateOperationNameMessage(operationName) {
- return 'There can only be one operation named "' + operationName + '".';
- }
- /**
- * Unique operation names
- *
- * A GraphQL document is only valid if all defined operations have unique names.
- */
- function UniqueOperationNames(context) {
- var knownOperationNames = Object.create(null);
- return {
- OperationDefinition: function OperationDefinition(node) {
- var operationName = node.name;
- if (operationName) {
- if (knownOperationNames[operationName.value]) {
- context.reportError(new _error.GraphQLError(duplicateOperationNameMessage(operationName.value), [knownOperationNames[operationName.value], operationName]));
- } else {
- knownOperationNames[operationName.value] = operationName;
- }
- }
- return false;
- },
- FragmentDefinition: function FragmentDefinition() {
- return false;
- }
- };
- }
- /***/ }),
- /* 78 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.duplicateVariableMessage = duplicateVariableMessage;
- exports.UniqueVariableNames = UniqueVariableNames;
- var _error = __webpack_require__(0);
- function duplicateVariableMessage(variableName) {
- return 'There can be only one variable named "' + variableName + '".';
- }
- /**
- * Unique variable names
- *
- * A GraphQL operation is only valid if all its variables are uniquely named.
- */
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function UniqueVariableNames(context) {
- var knownVariableNames = Object.create(null);
- return {
- OperationDefinition: function OperationDefinition() {
- knownVariableNames = Object.create(null);
- },
- VariableDefinition: function VariableDefinition(node) {
- var variableName = node.variable.name.value;
- if (knownVariableNames[variableName]) {
- context.reportError(new _error.GraphQLError(duplicateVariableMessage(variableName), [knownVariableNames[variableName], node.variable.name]));
- } else {
- knownVariableNames[variableName] = node.variable.name;
- }
- }
- };
- }
- /***/ }),
- /* 79 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.nonInputTypeOnVarMessage = nonInputTypeOnVarMessage;
- exports.VariablesAreInputTypes = VariablesAreInputTypes;
- var _error = __webpack_require__(0);
- var _printer = __webpack_require__(4);
- var _definition = __webpack_require__(1);
- var _typeFromAST = __webpack_require__(9);
- function nonInputTypeOnVarMessage(variableName, typeName) {
- return 'Variable "$' + variableName + '" cannot be non-input type "' + typeName + '".';
- }
- /**
- * Variables are input types
- *
- * A GraphQL operation is only valid if all the variables it defines are of
- * input types (scalar, enum, or input object).
- */
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function VariablesAreInputTypes(context) {
- return {
- VariableDefinition: function VariableDefinition(node) {
- var type = (0, _typeFromAST.typeFromAST)(context.getSchema(), node.type);
- // If the variable type is not an input type, return an error.
- if (type && !(0, _definition.isInputType)(type)) {
- var variableName = node.variable.name.value;
- context.reportError(new _error.GraphQLError(nonInputTypeOnVarMessage(variableName, (0, _printer.print)(node.type)), [node.type]));
- }
- }
- };
- }
- /***/ }),
- /* 80 */
- /***/ (function(module, exports, __webpack_require__) {
- "use strict";
- Object.defineProperty(exports, "__esModule", {
- value: true
- });
- exports.badVarPosMessage = badVarPosMessage;
- exports.VariablesInAllowedPosition = VariablesInAllowedPosition;
- var _error = __webpack_require__(0);
- var _definition = __webpack_require__(1);
- var _typeComparators = __webpack_require__(19);
- var _typeFromAST = __webpack_require__(9);
- function badVarPosMessage(varName, varType, expectedType) {
- return 'Variable "$' + varName + '" of type "' + String(varType) + '" used in ' + ('position expecting type "' + String(expectedType) + '".');
- }
- /**
- * Variables passed to field arguments conform to type
- */
- /**
- * Copyright (c) 2015, Facebook, Inc.
- * All rights reserved.
- *
- * This source code is licensed under the BSD-style license found in the
- * LICENSE file in the root directory of this source tree. An additional grant
- * of patent rights can be found in the PATENTS file in the same directory.
- */
- function VariablesInAllowedPosition(context) {
- var varDefMap = Object.create(null);
- return {
- OperationDefinition: {
- enter: function enter() {
- varDefMap = Object.create(null);
- },
- leave: function leave(operation) {
- var usages = context.getRecursiveVariableUsages(operation);
- usages.forEach(function (_ref) {
- var node = _ref.node,
- type = _ref.type;
- var varName = node.name.value;
- var varDef = varDefMap[varName];
- if (varDef && type) {
- // A var type is allowed if it is the same or more strict (e.g. is
- // a subtype of) than the expected type. It can be more strict if
- // the variable type is non-null when the expected type is nullable.
- // If both are list types, the variable item type can be more strict
- // than the expected item type (contravariant).
- var schema = context.getSchema();
- var varType = (0, _typeFromAST.typeFromAST)(schema, varDef.type);
- if (varType && !(0, _typeComparators.isTypeSubTypeOf)(schema, effectiveType(varType, varDef), type)) {
- context.reportError(new _error.GraphQLError(badVarPosMessage(varName, varType, type), [varDef, node]));
- }
- }
- });
- }
- },
- VariableDefinition: function VariableDefinition(node) {
- varDefMap[node.variable.name.value] = node;
- }
- };
- }
- // If a variable definition has a default value, it's effectively non-null.
- function effectiveType(varType, varDef) {
- return !varDef.defaultValue || varType instanceof _definition.GraphQLNonNull ? varType : new _definition.GraphQLNonNull(varType);
- }
- /***/ })
- /******/ ]);
|