Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced graphql-request + refactored error handling #5

Merged
merged 15 commits into from
Feb 15, 2019

Conversation

bmullan91
Copy link
Contributor

@bmullan91 bmullan91 commented Feb 14, 2019

Fixes: #1, #2

⚠️ Breaking Changes ⚠️

  • createClient -> GraphQLClient class
    • config changes
    • endpoint -> url
    • fetch: optional function to specify the fetch implementation | defaults to global fetch

Additions

  • New config options to new GraphQLClient(config):
    • logErrors: Boolean | default true
    • onError: Function - custom error handler will receive ({ result, operation }) as the argument
  • New properties available on the result object from all hooks:
    • fetchError: if an error occurred during the fetch call it will be available here
    • httpError: if a http error occurred it will be available here
    • graphQLErrors: The array of GraphQL errors from the server response
    • error: Boolean set to true if any of the above errors have been set
    • cacheHit: Boolean set to true if the result came from the cache, useful for debugging
  • operationName can now be set:
    • useQuery(query, { variables: {...}, operationName: 'MyOperation' })
    • useMutation(mutation, { variables: {...}, operationName: 'MyOperation' })
    • const [myMutation] = useMutation(mutation); myMutation({ variables: {}, operationName: 'MyOperation' })

src/GraphQLClient.js Outdated Show resolved Hide resolved
src/GraphQLClient.js Outdated Show resolved Hide resolved
src/useQuery.js Outdated Show resolved Hide resolved
@bmullan91 bmullan91 changed the title [WIP] Replaced graphql-request + refactored error handling Replaced graphql-request + refactored error handling Feb 14, 2019
README.md Outdated Show resolved Hide resolved
src/GraphQLClient.js Outdated Show resolved Hide resolved
src/GraphQLClient.js Outdated Show resolved Hide resolved
src/GraphQLClient.js Outdated Show resolved Hide resolved
src/useClientRequest.js Outdated Show resolved Hide resolved
jackdclark
jackdclark previously approved these changes Feb 15, 2019
Copy link
Member

@jackdclark jackdclark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome 👍

README.md Outdated
endpoint: '/graphql'
const client = new GraphQLClient({
url: '/graphql',
fetch // pass your preferred polyfill here
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe state that it's optional?

@bmullan91 bmullan91 merged commit 10d8d8a into master Feb 15, 2019
@bmullan91 bmullan91 deleted the replace_graphql_request branch February 15, 2019 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants