Skip to content

Commit

Permalink
Upgrade elm dependencies, to latest http & elm-graphql (#82)
Browse files Browse the repository at this point in the history
* chore(*): elm-graphql 2.0.0 upgrade

* chore(*): elm-graphql 4.2.0 upgrade

* fix(*): target self on external links
  • Loading branch information
tbash authored Feb 10, 2019
1 parent 10910bf commit 11fee03
Show file tree
Hide file tree
Showing 24 changed files with 1,180 additions and 684 deletions.
12 changes: 6 additions & 6 deletions assets/elm.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@
"direct": {
"Skinney/murmur3": "2.0.8",
"elm/browser": "1.0.1",
"elm/core": "1.0.0",
"elm/core": "1.0.2",
"elm/html": "1.0.0",
"elm/http": "1.0.0",
"elm/http": "2.0.0",
"elm/json": "1.1.2",
"elm/parser": "1.1.0",
"elm/regex": "1.0.0",
"elm/svg": "1.0.1",
"elm/time": "1.0.0",
"elm/url": "1.0.0",
"elm-community/list-extra": "8.1.0",
"folkertdev/elm-deque": "3.0.0",
"jinjor/elm-debounce": "3.0.0",
"lukewestby/elm-http-builder": "6.0.0",
"lukewestby/elm-string-interpolate": "1.0.3",
"lukewestby/http-extra": "2.0.1",
"rtfeldman/elm-css": "16.0.0"
},
"indirect": {
"elm/bytes": "1.0.7",
"elm/file": "1.0.3",
"elm/regex": "1.0.0",
"elm/virtual-dom": "1.0.2",
"rtfeldman/elm-hex": "1.0.0"
}
Expand All @@ -36,4 +36,4 @@
"direct": {},
"indirect": {}
}
}
}
13 changes: 6 additions & 7 deletions assets/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@babel/core": "7.0.0-beta.46",
"@babel/preset-env": "7.0.0-beta.46",
"@babel/preset-stage-2": "7.0.0-beta.46",
"@dillonkearns/elm-graphql": "^1.0.7",
"@dillonkearns/elm-graphql": "^3.2.0",
"@webcomponents/custom-elements": "1.1.0",
"babel-loader": "8.0.0-beta.4",
"codemirror": "5.27.4",
Expand Down
6 changes: 3 additions & 3 deletions assets/src/Data/Jwt.elm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Data.Jwt exposing (Jwt, decoder, encoder, field, fromString, toString, withTokenHeader)

import Graphql.Field
import Graphql.Http
import Graphql.SelectionSet as SelectionSet exposing (SelectionSet)
import Json.Decode as Decode exposing (Decoder)
import Json.Encode as Encode exposing (Value)

Expand Down Expand Up @@ -35,6 +35,6 @@ withTokenHeader (Jwt token) =
Graphql.Http.withHeader "authorization" ("Bearer " ++ token)


field : Graphql.Field.Field String a -> Graphql.Field.Field Jwt a
field : SelectionSet String a -> SelectionSet Jwt a
field stringField =
Graphql.Field.map Jwt stringField
SelectionSet.map Jwt stringField
10 changes: 6 additions & 4 deletions assets/src/Effect/Program.elm
Original file line number Diff line number Diff line change
Expand Up @@ -133,31 +133,33 @@ runCmd config state cmd =
|> maybeWithToken token
|> withCaching cache
|> Graphql.Http.send identity
|> Cmd.map (Result.mapError Graphql.Http.ignoreParsedErrorData)
-- |> Cmd.map (Result.mapError Graphql.Http.ignoreParsedErrorData)
|> Cmd.map
(\result ->
case result of
Ok msg ->
UserMsg msg

Err str ->
UserMsg (onError str)
-- UserMsg (onError str)
NoOp
)
|> maybeWithDebounce state debounce

Command.GraphqlMutation { url, token, selection, onError, debounce } ->
Graphql.Http.mutationRequest url selection
|> maybeWithToken token
|> Graphql.Http.send identity
|> Cmd.map (Result.mapError Graphql.Http.ignoreParsedErrorData)
-- |> Cmd.map (Result.mapError Graphql.Http.ignoreParsedErrorData)
|> Cmd.map
(\result ->
case result of
Ok msg ->
UserMsg msg

Err str ->
UserMsg (onError str)
-- UserMsg (onError str)
NoOp
)
|> maybeWithDebounce state debounce

Expand Down
22 changes: 11 additions & 11 deletions assets/src/Ellie/Api/Helpers.elm
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,36 @@ module Ellie.Api.Helpers exposing (defaultField, nameField, projectIdField, unit
import Ellie.Api.Scalar as ApiScalar
import Elm.Name as Name exposing (Name)
import Elm.Version as Version exposing (Version)
import Graphql.Field as Field exposing (Field)
import Graphql.Http exposing (Request)
import Graphql.SelectionSet as SelectionSet exposing (SelectionSet)


versionField : Field ApiScalar.ElmVersion a -> Field Version a
versionField : SelectionSet ApiScalar.ElmVersion a -> SelectionSet Version a
versionField =
Field.mapOrFail <|
SelectionSet.mapOrFail <|
\(ApiScalar.ElmVersion string) -> Version.fromString string


unitField : Field ApiScalar.Unit a -> Field () a
unitField : SelectionSet ApiScalar.Unit a -> SelectionSet () a
unitField =
Field.map <| \_ -> ()
SelectionSet.map <| \_ -> ()


projectIdField : Field ApiScalar.PrettyId a -> Field String a
projectIdField : SelectionSet ApiScalar.PrettyId a -> SelectionSet String a
projectIdField =
Field.map <|
SelectionSet.map <|
\(ApiScalar.PrettyId string) -> string


nameField : Field ApiScalar.ElmName a -> Field Name a
nameField : SelectionSet ApiScalar.ElmName a -> SelectionSet Name a
nameField =
Field.mapOrFail <|
SelectionSet.mapOrFail <|
\(ApiScalar.ElmName string) -> Name.fromString string


defaultField : a -> Field (Maybe a) b -> Field a b
defaultField : a -> SelectionSet (Maybe a) b -> SelectionSet a b
defaultField default =
Field.map (Maybe.withDefault default)
SelectionSet.map (Maybe.withDefault default)


withMaybe : (a -> Request b -> Request b) -> Maybe a -> Request b -> Request b
Expand Down
63 changes: 31 additions & 32 deletions assets/src/Elm/Docs.elm
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ import Ellie.Api.Object.ElmDocsUnion as ElmDocsUnion
import Ellie.Api.Object.ElmDocsValue as ElmDocsValue
import Ellie.Api.Scalar as Scalar
import Elm.Package as Package exposing (Package)
import Graphql.Field as Field
import Graphql.SelectionSet exposing (SelectionSet, hardcoded, with)
import Graphql.SelectionSet as SelectionSet exposing (SelectionSet)



Expand Down Expand Up @@ -194,46 +193,46 @@ selection : SelectionSet (Package -> Module) ElmDocsModule
selection =
let
selection_ =
ElmDocsModule.selection Module
|> with ElmDocsModule.name
|> with ElmDocsModule.comment
|> with (ElmDocsModule.unions unionSelection)
|> with (ElmDocsModule.aliases aliasSelection)
|> with (ElmDocsModule.values valueSelection)
|> with (ElmDocsModule.binops binopSelection)
SelectionSet.succeed Module
|> SelectionSet.with ElmDocsModule.name
|> SelectionSet.with ElmDocsModule.comment
|> SelectionSet.with (ElmDocsModule.unions unionSelection)
|> SelectionSet.with (ElmDocsModule.aliases aliasSelection)
|> SelectionSet.with (ElmDocsModule.values valueSelection)
|> SelectionSet.with (ElmDocsModule.binops binopSelection)

unionSelection =
ElmDocsUnion.selection Union
|> with ElmDocsUnion.name
|> with ElmDocsUnion.comment
|> with ElmDocsUnion.args
|> with (ElmDocsUnion.tags tagSelection)
SelectionSet.succeed Union
|> SelectionSet.with ElmDocsUnion.name
|> SelectionSet.with ElmDocsUnion.comment
|> SelectionSet.with ElmDocsUnion.args
|> SelectionSet.with (ElmDocsUnion.tags tagSelection)

aliasSelection =
ElmDocsAlias.selection Alias
|> with ElmDocsAlias.name
|> with ElmDocsAlias.comment
|> with ElmDocsAlias.args
|> with (Field.map (\(Scalar.ElmDocsType t) -> t) ElmDocsAlias.type_)
SelectionSet.succeed Alias
|> SelectionSet.with ElmDocsAlias.name
|> SelectionSet.with ElmDocsAlias.comment
|> SelectionSet.with ElmDocsAlias.args
|> SelectionSet.with (SelectionSet.map (\(Scalar.ElmDocsType t) -> t) ElmDocsAlias.type_)

valueSelection =
ElmDocsValue.selection Value
|> with ElmDocsValue.name
|> with ElmDocsValue.comment
|> with (Field.map (\(Scalar.ElmDocsType t) -> t) ElmDocsValue.type_)
SelectionSet.succeed Value
|> SelectionSet.with ElmDocsValue.name
|> SelectionSet.with ElmDocsValue.comment
|> SelectionSet.with (SelectionSet.map (\(Scalar.ElmDocsType t) -> t) ElmDocsValue.type_)

binopSelection =
ElmDocsBinop.selection Binop
|> with ElmDocsBinop.name
|> with ElmDocsBinop.comment
|> with (Field.map (\(Scalar.ElmDocsType t) -> t) ElmDocsBinop.type_)
|> with (Field.map makeAssociativity ElmDocsBinop.associativity)
|> with ElmDocsBinop.precedence
SelectionSet.succeed Binop
|> SelectionSet.with ElmDocsBinop.name
|> SelectionSet.with ElmDocsBinop.comment
|> SelectionSet.with (SelectionSet.map (\(Scalar.ElmDocsType t) -> t) ElmDocsBinop.type_)
|> SelectionSet.with (SelectionSet.map makeAssociativity ElmDocsBinop.associativity)
|> SelectionSet.with ElmDocsBinop.precedence

tagSelection =
ElmDocsTag.selection (\a b -> ( a, b ))
|> with ElmDocsTag.name
|> with (Field.map (List.map (\(Scalar.ElmDocsType t) -> t)) ElmDocsTag.args)
SelectionSet.succeed Tuple.pair
|> SelectionSet.with ElmDocsTag.name
|> SelectionSet.with (SelectionSet.map (List.map (\(Scalar.ElmDocsType t) -> t)) ElmDocsTag.args)

makeAssociativity a =
case a of
Expand Down
65 changes: 32 additions & 33 deletions assets/src/Elm/Error.elm
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ import Ellie.Api.Object.ElmErrorRegion as ElmErrorRegion
import Ellie.Api.Object.ElmErrorStyle as ElmErrorStyle
import Ellie.Api.Union as ApiUnion
import Ellie.Api.Union.ElmError as ElmError
import Graphql.Field as Field
import Graphql.SelectionSet exposing (SelectionSet, with)
import Graphql.SelectionSet as SelectionSet exposing (SelectionSet)


type Error
Expand Down Expand Up @@ -106,31 +105,31 @@ selection : SelectionSet Error ApiUnion.ElmError
selection =
let
badModuleSelection =
ElmErrorBadModule.selection BadModule
|> with ElmErrorBadModule.path
|> with ElmErrorBadModule.name
|> with (ElmErrorBadModule.problems problemSelection)
SelectionSet.succeed BadModule
|> SelectionSet.with ElmErrorBadModule.path
|> SelectionSet.with ElmErrorBadModule.name
|> SelectionSet.with (ElmErrorBadModule.problems problemSelection)

problemSelection =
ElmErrorProblem.selection Problem
|> with ElmErrorProblem.title
|> with (ElmErrorProblem.region regionSelection)
|> with (ElmErrorProblem.message chunkSelection)
SelectionSet.succeed Problem
|> SelectionSet.with ElmErrorProblem.title
|> SelectionSet.with (ElmErrorProblem.region regionSelection)
|> SelectionSet.with (ElmErrorProblem.message chunkSelection)

regionSelection =
ElmErrorRegion.selection Region
|> with (ElmErrorRegion.start positionSelection)
|> with (ElmErrorRegion.end positionSelection)
SelectionSet.succeed Region
|> SelectionSet.with (ElmErrorRegion.start positionSelection)
|> SelectionSet.with (ElmErrorRegion.end positionSelection)

positionSelection =
ElmErrorPosition.selection Position
|> with ElmErrorPosition.line
|> with ElmErrorPosition.column
SelectionSet.succeed Position
|> SelectionSet.with ElmErrorPosition.line
|> SelectionSet.with ElmErrorPosition.column

chunkSelection =
ElmErrorChunk.selection makeChunk
|> with ElmErrorChunk.string
|> with (ElmErrorChunk.style styleSelection)
SelectionSet.succeed makeChunk
|> SelectionSet.with ElmErrorChunk.string
|> SelectionSet.with (ElmErrorChunk.style styleSelection)

makeChunk string maybeStyle =
case maybeStyle of
Expand All @@ -141,10 +140,10 @@ selection =
Unstyled string

styleSelection =
ElmErrorStyle.selection Style
|> with ElmErrorStyle.bold
|> with ElmErrorStyle.underline
|> with (Field.map (Maybe.map makeColor) ElmErrorStyle.color)
SelectionSet.succeed Style
|> SelectionSet.with ElmErrorStyle.bold
|> SelectionSet.with ElmErrorStyle.underline
|> SelectionSet.with (SelectionSet.map (Maybe.map makeColor) ElmErrorStyle.color)

makeColor color =
case color of
Expand Down Expand Up @@ -196,13 +195,13 @@ selection =
ElmErrorColor.VividBlack ->
BLACK
in
ElmError.selection (Maybe.withDefault (ModuleProblems []))
[ ElmErrorGeneralProblem.selection (\path title message -> GeneralProblem { path = path, title = title, message = message })
|> with ElmErrorGeneralProblem.path
|> with ElmErrorGeneralProblem.title
|> with (ElmErrorGeneralProblem.message chunkSelection)
|> ElmError.onElmErrorGeneralProblem
, ElmErrorModuleProblems.selection ModuleProblems
|> with (ElmErrorModuleProblems.errors badModuleSelection)
|> ElmError.onElmErrorModuleProblems
]
ElmError.fragments
{ onElmErrorGeneralProblem =
SelectionSet.succeed (\path title message -> GeneralProblem { path = path, title = title, message = message })
|> SelectionSet.with ElmErrorGeneralProblem.path
|> SelectionSet.with ElmErrorGeneralProblem.title
|> SelectionSet.with (ElmErrorGeneralProblem.message chunkSelection)
, onElmErrorModuleProblems =
SelectionSet.succeed ModuleProblems
|> SelectionSet.with (ElmErrorModuleProblems.errors badModuleSelection)
}
Loading

0 comments on commit 11fee03

Please sign in to comment.