Skip to content

Commit 1e961be

Browse files
Merge pull request #44 from primait/fix_travis
Update .travis.yml
2 parents 0c733de + 3ae23df commit 1e961be

File tree

17 files changed

+239
-331
lines changed

17 files changed

+239
-331
lines changed

.travis.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,24 @@
11
sudo: false
22

3+
dist: focal
34
language: node_js
45
node_js: node
56

67
cache:
78
directories:
8-
- elm-stuff/build-artifacts
9-
- elm-stuff/packages
109
- sysconfcpus
1110
os:
1211
- linux
1312

14-
env: ELM_VERSION=0.19.0
13+
env: ELM_VERSION=0.19.1
1514

1615
before_install:
1716
- echo -e "Host github.com\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
1817

1918
install:
2019
- node --version
2120
- npm --version
22-
- npm install -g elm@$ELM_VERSION elm-test@0.19.0-beta4
21+
- npm install elm@$ELM_VERSION elm-test@$ELM_VERSION [email protected]
2322
# Faster compile on Travis.
2423
- |
2524
if [ ! -d sysconfcpus/bin ];
@@ -32,4 +31,5 @@ install:
3231
fi
3332
3433
script:
35-
- $TRAVIS_BUILD_DIR/sysconfcpus/bin/sysconfcpus -n 2 elm-test
34+
- $TRAVIS_BUILD_DIR/sysconfcpus/bin/sysconfcpus -n 2 ./node_modules/.bin/elm-test --compiler $TRAVIS_BUILD_DIR/node_modules/.bin/elm
35+
- $TRAVIS_BUILD_DIR/sysconfcpus/bin/sysconfcpus -n 2 ./node_modules/.bin/elm-format --validate .

example/Main.elm

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
module Main exposing (..)
22

3-
import Html exposing (Html, div, text)
3+
import GraphQL.Client.Http as GraphQLClient
44
import GraphQL.Request.Builder exposing (..)
55
import GraphQL.Request.Builder.Arg as Arg
66
import GraphQL.Request.Builder.Variable as Var
7-
import GraphQL.Client.Http as GraphQLClient
7+
import Html exposing (Html, div, text)
88
import Task exposing (Task)
99

1010

@@ -20,6 +20,7 @@ type alias FilmSummary =
2020
{-| The definition of `starWarsRequest` builds up a query request value that
2121
will later be encoded into the following GraphQL query document:
2222
23+
```graphql
2324
fragment filmPlanetsFragment on Film {
2425
planetConnection(first: $pageSize) {
2526
edges {
@@ -43,9 +44,11 @@ query ($filmID: ID!, $pageSize: Int = 3) {
4344
...filmPlanetsFragment
4445
}
4546
}
47+
```
4648
4749
This query is sent along with variable values extracted from the record passed
4850
to `request`, and the response is decoded into a `FilmSummary`.
51+
4952
-}
5053
starWarsRequest : Request Query FilmSummary
5154
starWarsRequest =
@@ -66,24 +69,24 @@ starWarsRequest =
6669
)
6770
)
6871
in
69-
extract
70-
(field "film"
71-
[ ( "filmID", Arg.variable filmID ) ]
72-
(object FilmSummary
73-
|> with (field "title" [] (nullable string))
74-
|> with
75-
(field "characterConnection"
76-
[ ( "first", Arg.variable pageSize ) ]
77-
(connectionNodes (extract (field "name" [] (nullable string))))
78-
)
79-
|> with (fragmentSpread planetsFragment)
80-
)
72+
extract
73+
(field "film"
74+
[ ( "filmID", Arg.variable filmID ) ]
75+
(object FilmSummary
76+
|> with (field "title" [] (nullable string))
77+
|> with
78+
(field "characterConnection"
79+
[ ( "first", Arg.variable pageSize ) ]
80+
(connectionNodes (extract (field "name" [] (nullable string))))
81+
)
82+
|> with (fragmentSpread planetsFragment)
8183
)
82-
|> queryDocument
83-
|> request
84-
{ filmID = "1"
85-
, pageSize = Nothing
86-
}
84+
)
85+
|> queryDocument
86+
|> request
87+
{ filmID = "1"
88+
, pageSize = Nothing
89+
}
8790

8891

8992
{-| A function that helps you extract node objects from paginated Relay connections.

src/GraphQL/Client/Http.elm

Lines changed: 31 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
1-
module GraphQL.Client.Http
2-
exposing
3-
( RequestError
4-
, DocumentLocation
5-
, Error(..)
6-
, RequestOptions
7-
, sendQuery
8-
, sendMutation
9-
, customSendQuery
10-
, customSendQueryRaw
11-
, customSendMutation
12-
, customSendMutationRaw
13-
)
1+
module GraphQL.Client.Http exposing (Error(..), RequestError, DocumentLocation, sendQuery, sendMutation, RequestOptions, customSendQuery, customSendMutation, customSendQueryRaw, customSendMutationRaw)
142

153
{-| The functions in this module let you perform HTTP requests to conventional GraphQL server endpoints.
164
17-
@docs Error, RequestError, DocumentLocation, sendQuery, sendMutation, RequestOptions, customSendQuery, customSendMutation, customSendQueryRaw, customSendMutationRaw
5+
@docs Error, RequestError, DocumentLocation, sendQuery, sendMutation, RequestOptions, customSendQuery, customSendMutation, customSendQueryRaw, customSendMutationRaw
6+
187
-}
198

209
import GraphQL.Client.Http.Util as Util
@@ -126,17 +115,18 @@ Example of response decoding:
126115
, withCredentials = False
127116
}
128117
in
129-
request
130-
|> GraphQL.Client.Http.customSendQueryRaw options
131-
|> Task.andThen
132-
(\response ->
133-
case Json.Decode.decodeString decoder response.body of
134-
Err err ->
135-
Task.fail <| GraphQL.Client.Http.HttpError <| Http.BadPayload err response
136-
137-
Ok decodedValue ->
138-
Task.succeed decodedValue
139-
)
118+
request
119+
|> GraphQL.Client.Http.customSendQueryRaw options
120+
|> Task.andThen
121+
(\response ->
122+
case Json.Decode.decodeString decoder response.body of
123+
Err err ->
124+
Task.fail <| GraphQL.Client.Http.HttpError <| Http.BadPayload err response
125+
126+
Ok decodedValue ->
127+
Task.succeed decodedValue
128+
)
129+
140130
-}
141131
customSendQueryRaw :
142132
RequestOptions
@@ -175,17 +165,17 @@ Example of response decoding:
175165
, withCredentials = False
176166
}
177167
in
178-
mutationRequest
179-
|> GraphQL.Client.Http.customSendMutationRaw options
180-
|> Task.andThen
181-
(\response ->
182-
case Json.Decode.decodeString decoder response.body of
183-
Err err ->
184-
Task.fail <| GraphQL.Client.Http.HttpError <| Http.BadPayload err response
185-
186-
Ok decodedValue ->
187-
Task.succeed decodedValue
188-
)
168+
mutationRequest
169+
|> GraphQL.Client.Http.customSendMutationRaw options
170+
|> Task.andThen
171+
(\response ->
172+
case Json.Decode.decodeString decoder response.body of
173+
Err err ->
174+
Task.fail <| GraphQL.Client.Http.HttpError <| Http.BadPayload err response
175+
176+
Ok decodedValue ->
177+
Task.succeed decodedValue
178+
)
189179
190180
-}
191181
customSendMutationRaw :
@@ -210,7 +200,7 @@ send options request =
210200
expect =
211201
Util.defaultExpect (Builder.responseDataDecoder request)
212202
in
213-
sendExpecting expect options request
203+
sendExpecting expect options request
214204

215205

216206
sendExpecting :
@@ -226,7 +216,7 @@ sendExpecting expect requestOptions request =
226216
variableValues =
227217
Builder.jsonVariableValues request
228218
in
229-
Util.requestConfig requestOptions documentString expect variableValues
230-
|> Http.request
231-
|> Http.toTask
232-
|> Task.mapError (Util.convertHttpError HttpError GraphQLError)
219+
Util.requestConfig requestOptions documentString expect variableValues
220+
|> Http.request
221+
|> Http.toTask
222+
|> Task.mapError (Util.convertHttpError HttpError GraphQLError)

src/GraphQL/Client/Http/Util.elm

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ postBodyJson documentString variableValues =
1818
|> Maybe.map (\obj -> [ ( "variables", obj ) ])
1919
|> Maybe.withDefault []
2020
in
21-
Json.Encode.object ([ ( "query", documentValue ) ] ++ extraParams)
21+
Json.Encode.object ([ ( "query", documentValue ) ] ++ extraParams)
2222

2323

2424
postBody : String -> Maybe Json.Encode.Value -> Http.Body
@@ -32,6 +32,7 @@ parameterizedUrl url documentString variableValues =
3232
firstParamPrefix =
3333
if String.contains "?" url then
3434
"&"
35+
3536
else
3637
"?"
3738

@@ -46,7 +47,7 @@ parameterizedUrl url documentString variableValues =
4647
)
4748
|> Maybe.withDefault ""
4849
in
49-
url ++ queryParam ++ variablesParam
50+
url ++ queryParam ++ variablesParam
5051

5152

5253
type alias RequestOptions =
@@ -107,17 +108,18 @@ requestConfig requestOptions documentString expect variableValues =
107108
( url, body ) =
108109
if requestOptions.method == "GET" then
109110
( parameterizedUrl requestOptions.url documentString variableValues, Http.emptyBody )
111+
110112
else
111113
( requestOptions.url, postBody documentString variableValues )
112114
in
113-
{ method = requestOptions.method
114-
, headers = requestOptions.headers
115-
, url = url
116-
, body = body
117-
, expect = expect
118-
, timeout = requestOptions.timeout
119-
, withCredentials = requestOptions.withCredentials
120-
}
115+
{ method = requestOptions.method
116+
, headers = requestOptions.headers
117+
, url = url
118+
, body = body
119+
, expect = expect
120+
, timeout = requestOptions.timeout
121+
, withCredentials = requestOptions.withCredentials
122+
}
121123

122124

123125
defaultExpect : Json.Decode.Decoder result -> Http.Expect result
@@ -139,12 +141,12 @@ convertHttpError wrapHttpError wrapGraphQLError httpError =
139141
|> Result.map wrapGraphQLError
140142
|> Result.withDefault (wrapHttpError httpError)
141143
in
142-
case httpError of
143-
Http.BadStatus { body } ->
144-
handleErrorWithResponseBody body
144+
case httpError of
145+
Http.BadStatus { body } ->
146+
handleErrorWithResponseBody body
145147

146-
Http.BadPayload _ { body } ->
147-
handleErrorWithResponseBody body
148+
Http.BadPayload _ { body } ->
149+
handleErrorWithResponseBody body
148150

149-
_ ->
150-
wrapHttpError httpError
151+
_ ->
152+
wrapHttpError httpError

src/GraphQL/Request.elm

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
module GraphQL.Request
2-
exposing
3-
( Document
4-
, Request
5-
)
1+
module GraphQL.Request exposing
2+
( Document
3+
, Request
4+
)
65

76
import GraphQL.Request.Document.AST as AST
87
import GraphQL.Request.Document.AST.Serialize exposing (serializeDocument)

0 commit comments

Comments
 (0)