-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from AtB-AS/master
- Loading branch information
Showing
27 changed files
with
8,201 additions
and
2,178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
include: 'src/**/*.ts' | ||
extensions: | ||
endpoints: | ||
Entur: | ||
url: https://api.entur.io/journey-planner/v2/graphql |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
overwrite: true | ||
schema: 'https://api.entur.io/journey-planner/v2/graphql' | ||
documents: ./src/**/*.graphql | ||
generates: | ||
src/graphql/types.ts: | ||
config: | ||
maybeValue: T | ||
skipTypename: true | ||
exportFragmentSpreadSubTypes: true | ||
preResolveTypes: true | ||
plugins: | ||
- typescript | ||
src/: | ||
preset: near-operation-file | ||
presetConfig: | ||
extension: .graphql-gen.ts | ||
baseTypesPath: graphql/types.ts | ||
config: | ||
withHooks: false | ||
withComponent: false | ||
withHOC: false | ||
withResultType: false | ||
skipTypename: true | ||
# This causes some types to be wrong (e.g. in departure query dates are any type) | ||
# but it makes using the types waay easier. Necessary evil in my mind. | ||
preResolveTypes: true | ||
exportFragmentSpreadSubTypes: true | ||
# Looks like almost all types in the GraphQL server is optional but actually are set. The Maybe combinator | ||
# is a pain to work with when traversing the types. | ||
maybeValue: T | ||
plugins: | ||
- 'typescript-operations' | ||
- 'typescript-react-apollo' |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import ApolloClient, { DefaultOptions } from 'apollo-client'; | ||
import { InMemoryCache } from 'apollo-cache-inmemory'; | ||
import { HttpLink } from 'apollo-link-http'; | ||
import fetch from 'node-fetch'; | ||
|
||
const link = new HttpLink({ | ||
uri: 'https://api.entur.io/journey-planner/v2/graphql', | ||
|
||
// node-fetch uses a different signature than the browser implemented fetch | ||
// But we use node-fetch's agent option in other parts of the project. | ||
// The functionallity overlaps so this works as expected. | ||
fetch: (fetch as unknown) as WindowOrWorkerGlobalScope['fetch'] | ||
}); | ||
|
||
const defaultOptions: DefaultOptions = { | ||
watchQuery: { | ||
fetchPolicy: 'cache-and-network', | ||
errorPolicy: 'ignore' | ||
}, | ||
query: { | ||
fetchPolicy: 'network-only', | ||
errorPolicy: 'all' | ||
} | ||
}; | ||
|
||
export default new ApolloClient({ | ||
link, | ||
cache: new InMemoryCache(), | ||
defaultOptions | ||
}); |
Oops, something went wrong.