https://www.prisma.io/ logo
Join SlackCommunities
Powered by
# prisma-whats-new
  • d

    daniele

    11/12/2017, 9:43 PM
    Copy code
    public addAirline(airline: AddAirline): Observable<any> {
            return this.apollo.mutate({
                mutation: gql`
                    mutation($name: String!, $color: String!) {
                        createAirline(name: $name, color: $color){
                            id,
                            name,
                            color
                        }
                    }
                `,
                variables: {
                    name: airline.name,
                    color: airline.color
                },
                update: (proxy, { data: { createAirline } }) => {
                    // Read the data from our cache for this query.
                    const data: IAirlines = proxy.readQuery({query: this.getAirlines});
                    data.allAirlines.push(createAirline);
    
                    // Write our data back to the cache.
                    proxy.writeQuery({ query: this.getAirlines, data });
                }
            });
        }
  • d

    daniele

    11/12/2017, 9:43 PM
    is a function?
  • d

    daniele

    11/12/2017, 9:44 PM
    and how to implement it?
    i
    • 2
    • 5
  • b

    Bung55

    11/13/2017, 2:14 AM
    I think I already asked this, but can't find it (over a week ago!), so I've just come back to it. I've worked through the quickstart tutorial for Vue.js (on my Mac) and all OK (after getting over the package.json license error. So the last two commands are yarn install and yarn start & I get the program running, but when I add a new post and enter some info, it does not save - nothing happens, it just returns to the popup entry dialog - any thoughts ? TIA, Dave
  • r

    russell

    11/13/2017, 3:04 AM
    https://github.com/graphcool/framework/issues/143 <= Any status on this?
  • r

    rahulkukadiya

    11/13/2017, 7:57 AM
    should i go with graphcool for chat application? Anyone have thoughts and idead or suggestion please share it. Thanks in advance
  • k

    kaaerreeene

    11/13/2017, 8:42 AM
    Hi channel! I've got a problem trying to query a list of events by a range (I want a list of events which are before or after a date, so I can filter passed events or events in the future) My schema is:
    Copy code
    type Event @model {
      id: ID! @isUnique
      title: String!
      description: String!
      type: String
      dateTime: DateTime!
      location: String!
      image: String
      attendants: [Attendant!]! @relation(name: "EventHasAttendant")
      minAttendants: Int!
      maxAttendants: Int!
      updatedAt: DateTime!
      createdAt: DateTime!
    }
    My query is something like:
    Copy code
    {
      allEvents(filter: {dateTime: "2017-11-18T23:00:00.000Z"}) {
        id
        title
        description
        type
        dateTime
        location
        image
        attendants {
          id
          email
          name
        }
        minAttendants
        maxAttendants
      }
    }
    Could you help me? I don't know if in this case I should use Graphcool Functions.
    e
    • 2
    • 2
  • b

    bwoodlt

    11/13/2017, 10:27 AM
    I can’t seem to get my
    graphql subscriptions
    to work. I believe I set it up correctly, but it keep returning null. Here’s my setup
    Copy code
    const Subscription = new GraphQLObjectType({
        name: 'RootSubscription',
        description: 'All FathCircle Subscriptions',
        fields: {
            userCreated: {
                type: UserLoginType,
                subscribe: withFilter(
                    () => pubsub.asyncIterator(SUB.USER_CREATED, SUB.USER_LOGGED_IN),
                    (payload, args) => {
                        console.log(payload);
                        return payload.userCreated.id === args.id;
                    }
                ),
                resolve: st => {
                    console.log(st);
                    console.log('Nothing shows!!!');
                }
            }})
  • b

    bwoodlt

    11/13/2017, 10:28 AM
    Any thought’s appreciated
  • v

    Vinnie

    11/13/2017, 10:29 AM
    So, I edited my permissions for User.* and required authorisation for all CRUD ops. If I use the basic mutation
    createUser
    without authorisation, I get stopped with an error for insufficient permissions, which is what I expect. However, when using the authorisation template providing the basic email/passwd auth, invoking the mutation
    signupUser
    doesn’t yield any error, but actually creates the user, even though I can see the source code is (obviously) using the basic
    createUser
    mutation. Thoughts?
  • d

    daniele

    11/13/2017, 11:04 AM
    Hi guys sorry probably I'm becoming annoying but whetever response I receive it doesn't help me to understand when to use functions. At the moment the thing that I did is 1 table:
    Airline
    on this table I perform CRUD operations. The CRUD operations are defined in my client project (angular with apollo). So my graphcool project atm contain just the schema definition:
  • d

    daniele

    11/13/2017, 11:04 AM
    - in types.graphql:
  • d

    daniele

    11/13/2017, 11:04 AM
    Copy code
    type Airline @model {
      id: ID! @isUnique
      name: String!
      color: String!
    }
  • d

    daniele

    11/13/2017, 11:05 AM
    In my client: SELECT, UPDATE, DELETE, ADD
  • d

    daniele

    11/13/2017, 11:05 AM
    Now I'm keep looking all the xamples on the
    <https://github.com/graphcool/framework/tree/master/examples>
    but I don't find any example to put the CRUD in functions or not
  • d

    daniele

    11/13/2017, 11:05 AM
    can someone point me please in the right direction?
  • v

    Vinnie

    11/13/2017, 11:07 AM
    Not quite sure I follow what you say there, @daniele — graphcool automatically creates CRUD queries/mutations for you, so your client is supposed to use those for CRUD
  • v

    Vinnie

    11/13/2017, 11:08 AM
    (maybe I am misunderstanding you)
  • d

    daniele

    11/13/2017, 11:08 AM
    @Vinnie examples in my angular-appollo project:
    i
    • 2
    • 4
  • d

    daniele

    11/13/2017, 11:08 AM
    Copy code
    return this.apollo.mutate({
                mutation: gql`
                    mutation($name: String!, $color: String!) {
                        createAirline(name: $name, color: $color){
                            id,
                            name,
                            color
                        }
                    }
                `,
                variables: {
                    name: airline.name,
                    color: airline.color
                },
                update: (proxy, { data: { createAirline } }) => {
                    // Read the data from our cache for this query.
                    const data: IAirlines = proxy.readQuery({query: this.getAirlines});
                    data.allAirlines.push(createAirline);
    
                    // Write our data back to the cache.
                    proxy.writeQuery({ query: this.getAirlines, data });
                }
            });
  • d

    daniele

    11/13/2017, 11:09 AM
    Copy code
    return this.apollo.mutate({
                mutation: gql`
                    mutation($id:ID!, $name: String!, $color: String!) {
                        updateAirline(id: $id, name: $name, color: $color){
                            id,
                            name,
                            color
                        }
                    }
                `,
                variables: {
                    id: airline.id,
                    name: airline.name,
                    color: airline.color
                },
                update: (proxy, { data: { updateAirline } }) => {
                    // Read the data from our cache for this query.
                    const data: IAirlines = proxy.readQuery({query: this.getAirlines});
    
                    // Write our data back to the cache.
                    proxy.writeQuery({ query: this.getAirlines, data });
                }
            });
  • d

    daniele

    11/13/2017, 11:09 AM
    Copy code
    return this.apollo.mutate({
                mutation: gql`
                    mutation($id:ID!) {
                        deleteAirline(id: $id){
                            id
                        }
                    }
                `,
                variables: {
                    id: airline.id
                },
                update: (proxy, { data: { deleteAirline } }) => {
                    // Read the data from our cache for this query.
                    const data: IAirlines = proxy.readQuery({query: this.getAirlines});
                    const itemToDelete = data.allAirlines.findIndex((airlineToFilter) => airlineToFilter.id === deleteAirline.id);
                    data.allAirlines.splice(itemToDelete, 1);
    
                    // Write our data back to the cache.
                    proxy.writeQuery({ query: this.getAirlines, data });
                }
            });
  • d

    daniele

    11/13/2017, 11:09 AM
    Copy code
    /* Retrieve the airline list */
        private getAirlines = gql`{
            allAirlines {
                id
                name
                color
            }
        }`;
  • n

    nilan

    11/13/2017, 11:34 AM
    If your conversation reaches a point where you need to share a lot of code snippets, it's a good sign that the Forum is a better place to have it: https://graph.cool/forum.
    👍 1
  • v

    Vinnie

    11/13/2017, 12:19 PM
    Sharing this again, in case there was no one around when I first posted it…
    a
    • 2
    • 27
  • j

    joar

    11/13/2017, 12:21 PM
    I just cant seem to get authentication over websockets to work, using apollo 2.0 / apollo link
  • j

    joar

    11/13/2017, 12:22 PM
    does anyone have some code they feel like sharing?
  • m

    Maslov

    11/13/2017, 1:09 PM
    Which client type should I use for cordova (ios app) auth both with web auth?
  • m

    Maslov

    11/13/2017, 1:09 PM
    native?
  • m

    Maslov

    11/13/2017, 1:13 PM
    oh sorry, mixed auth0 and graph.cool conference
1...424425426...637Latest